summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/chef/resource/chef_client_launchd.rb21
-rw-r--r--spec/unit/resource/chef_client_launchd_spec.rb10
2 files changed, 14 insertions, 17 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
diff --git a/spec/unit/resource/chef_client_launchd_spec.rb b/spec/unit/resource/chef_client_launchd_spec.rb
index 1d66da3e39..1d0015cb0d 100644
--- a/spec/unit/resource/chef_client_launchd_spec.rb
+++ b/spec/unit/resource/chef_client_launchd_spec.rb
@@ -91,28 +91,28 @@ describe Chef::Resource::ChefClientLaunchd do
it "creates a valid command if using all default properties" do
expect(provider.client_command).to eql(
- ["/bin/sleep", "123;", "/opt/chef/bin/chef-client", "-c", root_path, "-L", "/Library/Logs/Chef/client.log"]
+ "/bin/sleep 123; /opt/chef/bin/chef-client -c #{root_path} -L /Library/Logs/Chef/client.log"
)
end
it "adds custom daemon options from daemon_options property" do
resource.daemon_options %w{foo bar}
expect(provider.client_command).to eql(
- ["/bin/sleep", "123;", "/opt/chef/bin/chef-client", "foo", "bar", "-c", root_path, "-L", "/Library/Logs/Chef/client.log"]
+ "/bin/sleep 123; /opt/chef/bin/chef-client foo bar -c #{root_path} -L /Library/Logs/Chef/client.log"
)
end
it "adds license acceptance flags if the property is set" do
resource.accept_chef_license true
expect(provider.client_command).to eql(
- ["/bin/sleep", "123;", "/opt/chef/bin/chef-client", "-c", root_path, "-L", "/Library/Logs/Chef/client.log", "--chef-license", "accept"]
+ "/bin/sleep 123; /opt/chef/bin/chef-client -c #{root_path} -L /Library/Logs/Chef/client.log --chef-license accept"
)
end
it "uses custom config dir if set" do
resource.config_directory "/etc/some_other_dir"
expect(provider.client_command).to eql(
- ["/bin/sleep", "123;", "/opt/chef/bin/chef-client", "-c", "/etc/some_other_dir/client.rb", "-L", "/Library/Logs/Chef/client.log"]
+ "/bin/sleep 123; /opt/chef/bin/chef-client -c /etc/some_other_dir/client.rb -L /Library/Logs/Chef/client.log"
)
end
@@ -120,7 +120,7 @@ describe Chef::Resource::ChefClientLaunchd do
resource.log_file_name "my-client.log"
resource.log_directory "/var/log/my-chef/"
expect(provider.client_command).to eql(
- ["/bin/sleep", "123;", "/opt/chef/bin/chef-client", "-c", root_path, "-L", "/var/log/my-chef/my-client.log"]
+ "/bin/sleep 123; /opt/chef/bin/chef-client -c #{root_path} -L /var/log/my-chef/my-client.log"
)
end
end