diff options
author | sanga17 <sausekar@msystechnologies.com> | 2021-05-06 19:42:57 +0530 |
---|---|---|
committer | sanga17 <sausekar@msystechnologies.com> | 2021-07-02 19:38:09 +0530 |
commit | 58ae290452c9dc898c4b41a3baeda51b5eb1660a (patch) | |
tree | e2a80a7f56625e9a1ffb787b8bd01403a3698340 | |
parent | ec33c4b9b46f6905e14aef7deda2cd9637af5078 (diff) | |
download | chef-58ae290452c9dc898c4b41a3baeda51b5eb1660a.tar.gz |
Fixed issues facing while bootstrapping the node using ssh config file
Signed-off-by: sanga17 <sausekar@msystechnologies.com>
-rw-r--r-- | knife/lib/chef/knife/bootstrap.rb | 2 | ||||
-rw-r--r-- | knife/lib/chef/knife/bootstrap/train_connector.rb | 7 |
2 files changed, 6 insertions, 3 deletions
diff --git a/knife/lib/chef/knife/bootstrap.rb b/knife/lib/chef/knife/bootstrap.rb index d57614cb3d..7317fdc34b 100644 --- a/knife/lib/chef/knife/bootstrap.rb +++ b/knife/lib/chef/knife/bootstrap.rb @@ -974,7 +974,7 @@ class Chef # Reference: https://github.com/chef/chef/blob/master/lib/chef/knife/ssh.rb#L272 opts[:keys_only] = config.key?(:connection_password) == false else - opts[:key_files] = [] + opts[:key_files] = nil opts[:keys_only] = false end diff --git a/knife/lib/chef/knife/bootstrap/train_connector.rb b/knife/lib/chef/knife/bootstrap/train_connector.rb index f155e32225..ecc7a80302 100644 --- a/knife/lib/chef/knife/bootstrap/train_connector.rb +++ b/knife/lib/chef/knife/bootstrap/train_connector.rb @@ -127,8 +127,11 @@ class Chef # running with sudo right now - so this directory would be owned by root. # File upload is performed over SCP as the current logged-in user, # so we'll set ownership to ensure that works. - run_command!("chown #{config[:user]} '#{dir}'") if config[:sudo] - + if config[:sudo] + # While using ssh config file user might present in ssh file + user = config[:user] || ssh_config_for_host(config[:host])[:user] + run_command!("chown #{config[:user]} '#{dir}'") + end dir end end |