summaryrefslogtreecommitdiff
path: root/lib/chef
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2020-08-27 16:13:40 -0700
committerTim Smith <tsmith84@gmail.com>2020-08-27 16:13:40 -0700
commit1ebf2e1f232af535ff2c4cb78579de62707362cb (patch)
treedc163b7d8364f0c208cd4936e7e828b311ba15db /lib/chef
parent20ce378890ca7991a23391000d6f7135a2c52841 (diff)
downloadchef-1ebf2e1f232af535ff2c4cb78579de62707362cb.tar.gz
Use bash to run sleep/chef-client in chef_client_launchdclient_updates
My googling tells me this is the recommended way to run multiple commands. Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'lib/chef')
-rw-r--r--lib/chef/resource/chef_client_launchd.rb21
1 files changed, 9 insertions, 12 deletions
diff --git a/lib/chef/resource/chef_client_launchd.rb b/lib/chef/resource/chef_client_launchd.rb
index 43d7e9bb8f..a2b024c030 100644
--- a/lib/chef/resource/chef_client_launchd.rb
+++ b/lib/chef/resource/chef_client_launchd.rb
@@ -114,7 +114,7 @@ class Chef
username new_resource.user
working_directory new_resource.working_directory
start_interval new_resource.interval * 60
- program_arguments client_command
+ program_arguments ["/bin/bash", "-c", client_command]
environment_variables new_resource.environment unless new_resource.environment.empty?
nice new_resource.nice
low_priority_io true
@@ -146,19 +146,16 @@ class Chef
#
# random sleep time + chef-client + daemon option properties + license acceptance
#
- # @return [Array]
+ # @return [String]
#
def client_command
- cmd = ["/bin/sleep",
- "#{splay_sleep_time(new_resource.splay)};",
- new_resource.chef_binary_path] +
- new_resource.daemon_options +
- ["-c",
- ::File.join(new_resource.config_directory, "client.rb"),
- "-L",
- ::File.join(new_resource.log_directory, new_resource.log_file_name),
- ]
- cmd.append("--chef-license", "accept") if new_resource.accept_chef_license
+ cmd = ""
+ cmd << "/bin/sleep #{splay_sleep_time(new_resource.splay)};"
+ cmd << " #{new_resource.chef_binary_path}"
+ cmd << " #{new_resource.daemon_options.join(" ")}" unless new_resource.daemon_options.empty?
+ cmd << " -c #{::File.join(new_resource.config_directory, "client.rb")}"
+ cmd << " -L #{::File.join(new_resource.log_directory, new_resource.log_file_name)}"
+ cmd << " --chef-license accept" if new_resource.accept_chef_license
cmd
end
end