diff options
author | Vivek Singh <vivek.singh@msystechnologies.com> | 2019-08-14 09:02:56 +0530 |
---|---|---|
committer | Vivek Singh <vivek.singh@msystechnologies.com> | 2019-08-14 09:02:56 +0530 |
commit | 75234876e5dada09707f2b8d04d5c968e905b364 (patch) | |
tree | 97bbc6ea06acbd9d8d6121c2beaec0e738fb500a /lib/chef/knife | |
parent | 9cdf03ee25d0349459474e33f42c64d68bd900e1 (diff) | |
download | chef-75234876e5dada09707f2b8d04d5c968e905b364.tar.gz |
Fix always require sudo to change ownership
- Add check to append sudo only if require sudo privilege.
- Work fine with Ubuntu, CentOS, AIX nodes.
Signed-off-by: Vivek Singh <vivek.singh@msystechnologies.com>
Diffstat (limited to 'lib/chef/knife')
-rw-r--r-- | lib/chef/knife/bootstrap/train_connector.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/chef/knife/bootstrap/train_connector.rb b/lib/chef/knife/bootstrap/train_connector.rb index a3611470d1..3f5ea9b94a 100644 --- a/lib/chef/knife/bootstrap/train_connector.rb +++ b/lib/chef/knife/bootstrap/train_connector.rb @@ -128,7 +128,9 @@ 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. - cmd += " && sudo chown #{config[:user]} '#{dir}'" + ownership = config[:sudo] ? "sudo chown" : "chown" + cmd += " && #{ownership} #{config[:user]} '#{dir}'" + run_command!(cmd) dir end |