diff options
author | Tim Smith <tsmith84@gmail.com> | 2020-03-24 12:03:49 -0700 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2020-03-24 12:03:49 -0700 |
commit | 44a3d003e789ea0a605bba59647272ebe3390637 (patch) | |
tree | f81f0ab7f3813f857b858b441bacc4bc7cb9f3c6 | |
parent | aa7ef36c0f8cab2703683981b8b56189daee650e (diff) | |
download | chef-44a3d003e789ea0a605bba59647272ebe3390637.tar.gz |
Set append_log_file property to true by defaultchef_client_cron
This is from a convo in slack where it was determined that we can safely append due to log rotation that occurs in mixlib-log
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | lib/chef/resource/chef_client_cron.rb | 4 | ||||
-rw-r--r-- | spec/unit/resource/chef_client_cron_spec.rb | 16 |
2 files changed, 10 insertions, 10 deletions
diff --git a/lib/chef/resource/chef_client_cron.rb b/lib/chef/resource/chef_client_cron.rb index 670bffe839..a6d0c61f57 100644 --- a/lib/chef/resource/chef_client_cron.rb +++ b/lib/chef/resource/chef_client_cron.rb @@ -117,8 +117,8 @@ class Chef description: "The name of the log file to use." property :append_log_file, [true, false], - default: false, - description: "Append to the log file instead of creating a new file on each run." + default: true, + description: "Append to the log file instead of overwriting the log file on each run." property :chef_binary_path, String, default: "/opt/#{Chef::Dist::DIR_SUFFIX}/bin/#{Chef::Dist::CLIENT}", diff --git a/spec/unit/resource/chef_client_cron_spec.rb b/spec/unit/resource/chef_client_cron_spec.rb index 5ce3db84dd..85472d6f09 100644 --- a/spec/unit/resource/chef_client_cron_spec.rb +++ b/spec/unit/resource/chef_client_cron_spec.rb @@ -77,33 +77,33 @@ describe Chef::Resource::ChefClientCron do end it "creates a valid command if using all default properties" do - expect(provider.cron_command).to eql("/bin/sleep 123; /opt/chef/bin/chef-client > /var/log/chef/client.log 2>&1") + expect(provider.cron_command).to eql("/bin/sleep 123; /opt/chef/bin/chef-client -L /var/log/chef/client.log") end it "uses daemon_options if set" do resource.daemon_options ["--foo 1", "--bar 2"] - expect(provider.cron_command).to eql("/bin/sleep 123; /opt/chef/bin/chef-client --foo 1 --bar 2 > /var/log/chef/client.log 2>&1") + expect(provider.cron_command).to eql("/bin/sleep 123; /opt/chef/bin/chef-client --foo 1 --bar 2 -L /var/log/chef/client.log") end it "uses custom log files / paths if set" do resource.log_file_name "my-client.log" resource.log_directory "/var/log/my-chef/" - expect(provider.cron_command).to eql("/bin/sleep 123; /opt/chef/bin/chef-client > /var/log/my-chef/my-client.log 2>&1") + expect(provider.cron_command).to eql("/bin/sleep 123; /opt/chef/bin/chef-client -L /var/log/my-chef/my-client.log") end it "uses mailto if set" do resource.mailto "bob@example.com" - expect(provider.cron_command).to eql("/bin/sleep 123; /opt/chef/bin/chef-client > /var/log/chef/client.log 2>&1 || echo \"Chef Infra Client execution failed\"") + expect(provider.cron_command).to eql("/bin/sleep 123; /opt/chef/bin/chef-client -L /var/log/chef/client.log || echo \"Chef Infra Client execution failed\"") end it "uses custom chef-client binary if set" do resource.chef_binary_path "/usr/local/bin/chef-client" - expect(provider.cron_command).to eql("/bin/sleep 123; /usr/local/bin/chef-client > /var/log/chef/client.log 2>&1") + expect(provider.cron_command).to eql("/bin/sleep 123; /usr/local/bin/chef-client -L /var/log/chef/client.log") end - it "appends to the log file appending if set" do - resource.append_log_file true - expect(provider.cron_command).to eql("/bin/sleep 123; /opt/chef/bin/chef-client -L /var/log/chef/client.log") + it "appends to the log file appending if set to false" do + resource.append_log_file false + expect(provider.cron_command).to eql("/bin/sleep 123; /opt/chef/bin/chef-client > /var/log/chef/client.log 2>&1") end end end |