diff options
author | Paul Mooring <paul@chef.io> | 2015-06-12 14:55:26 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2015-10-24 17:55:23 -0700 |
commit | 92e10007ace4269050aa12b184613617a5122cb7 (patch) | |
tree | 17529c463d3766f86f3e69575fa38c664950d15c /lib/chef/knife/bootstrap.rb | |
parent | 0af405931884c3fa2cd30c54074e98fa78ea7235 (diff) | |
download | chef-92e10007ace4269050aa12b184613617a5122cb7.tar.gz |
Added '--sudo-preserve-home' option to knife bootstrap to allow
ENV['HOME'] to not be set to root's home folder.
Diffstat (limited to 'lib/chef/knife/bootstrap.rb')
-rw-r--r-- | lib/chef/knife/bootstrap.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/chef/knife/bootstrap.rb b/lib/chef/knife/bootstrap.rb index 767fe4297f..387f1c90fa 100644 --- a/lib/chef/knife/bootstrap.rb +++ b/lib/chef/knife/bootstrap.rb @@ -122,6 +122,11 @@ class Chef :description => "Execute the bootstrap via sudo", :boolean => true + option :preserve_home, + :long => "--sudo-preserve-home", + :description => "Preserve non-root user HOME environment variable with sudo", + :boolean => true + option :use_sudo_password, :long => "--use-sudo-password", :description => "Execute the bootstrap via sudo with password", @@ -424,7 +429,8 @@ class Chef command = render_template if config[:use_sudo] - command = config[:use_sudo_password] ? "echo '#{config[:ssh_password]}' | sudo -SH #{command}" : "sudo -H #{command}" + sudo_prefix = config[:use_sudo_password] ? "echo '#{config[:ssh_password]}' | sudo -S " : "sudo " + command = config[:preserve_home] ? "#{sudo_prefix} #{command}" : "#{sudo_prefix} -H #{command}" end command |