summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsanga17 <sausekar@msystechnologies.com>2021-05-06 19:42:57 +0530
committersanga17 <sausekar@msystechnologies.com>2021-07-02 19:38:09 +0530
commit58ae290452c9dc898c4b41a3baeda51b5eb1660a (patch)
treee2a80a7f56625e9a1ffb787b8bd01403a3698340
parentec33c4b9b46f6905e14aef7deda2cd9637af5078 (diff)
downloadchef-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.rb2
-rw-r--r--knife/lib/chef/knife/bootstrap/train_connector.rb7
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