diff options
author | Noah Kantrowitz <noah@coderanger.net> | 2018-08-21 12:45:38 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-21 12:45:38 -0700 |
commit | 07dae712141fb21a041bb04f4ed0ddc7a0674fab (patch) | |
tree | 3cf0c3ab477f90ae406ab2c5af2e16d9322aeef1 | |
parent | 516ac6f892b0068fbfa450b0d18ae958303ac8ca (diff) | |
parent | fda14962c003f6f43d1a2656951dfebccf0845c4 (diff) | |
download | chef-07dae712141fb21a041bb04f4ed0ddc7a0674fab.tar.gz |
Merge pull request #7562 from coderanger/validatorless-fix
Validatorless bootstrap fix
-rw-r--r-- | chef-config/lib/chef-config/workstation_config_loader.rb | 6 | ||||
-rw-r--r-- | lib/chef/knife/core/bootstrap_context.rb | 2 |
2 files changed, 5 insertions, 3 deletions
diff --git a/chef-config/lib/chef-config/workstation_config_loader.rb b/chef-config/lib/chef-config/workstation_config_loader.rb index 65940102fc..af0c438ca1 100644 --- a/chef-config/lib/chef-config/workstation_config_loader.rb +++ b/chef-config/lib/chef-config/workstation_config_loader.rb @@ -225,12 +225,14 @@ module ChefConfig Config[:node_name] ||= Etc.getlogin # If we don't have a key (path or inline) check user.pem and $node_name.pem. unless Config.key?(:client_key) || Config.key?(:client_key_contents) - Config[:client_key] = find_default_key(["#{Config[:node_name]}.pem", "user.pem"]) + key_path = find_default_key(["#{Config[:node_name]}.pem", "user.pem"]) + Config[:client_key] = key_path if key_path end # Similarly look for a validation key file, though this should be less # common these days. unless Config.key?(:validation_key) || Config.key?(:validation_key_contents) - Config[:validation_key] = find_default_key(["#{Config[:validation_client_name]}.pem", "validator.pem", "validation.pem"]) + key_path = find_default_key(["#{Config[:validation_client_name]}.pem", "validator.pem", "validation.pem"]) + Config[:validation_key] = key_path if key_path end end diff --git a/lib/chef/knife/core/bootstrap_context.rb b/lib/chef/knife/core/bootstrap_context.rb index 4e21564c52..5c736ab01b 100644 --- a/lib/chef/knife/core/bootstrap_context.rb +++ b/lib/chef/knife/core/bootstrap_context.rb @@ -45,7 +45,7 @@ class Chef end def validation_key - if @chef_config.key?(:validation_key) && + if @chef_config[:validation_key] && File.exist?(File.expand_path(@chef_config[:validation_key])) IO.read(File.expand_path(@chef_config[:validation_key])) else |