From 61bfe685a5c122a8f00f4e9c12a313a990f338f1 Mon Sep 17 00:00:00 2001 From: vineethp08 Date: Sun, 30 Aug 2020 08:59:33 -0400 Subject: [PATCH 1/4] Make the onbootsec parameter to attribute Signed-off-by: vineethp08 --- attributes/default.rb | 1 + recipes/systemd_service.rb | 2 +- resources/systemd_timer.rb | 2 +- test/integration/timer_systemd/timer_systemd_spec.rb | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/attributes/default.rb b/attributes/default.rb index 87bee218..5075bfac 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -36,6 +36,7 @@ default['chef_client']['log_file'] = 'client.log' default['chef_client']['interval'] = '1800' default['chef_client']['splay'] = '300' +default['chef_client']['delay_after_boot'] = '60' default['chef_client']['conf_dir'] = '/etc/chef' default['chef_client']['bin'] = '/opt/chef/bin/chef-client' diff --git a/recipes/systemd_service.rb b/recipes/systemd_service.rb index b7fb5710..ca117b50 100644 --- a/recipes/systemd_service.rb +++ b/recipes/systemd_service.rb @@ -81,7 +81,7 @@ class ::Chef::Recipe 'Unit' => { 'Description' => 'chef-client periodic run' }, 'Install' => { 'WantedBy' => 'timers.target' }, 'Timer' => { - 'OnBootSec' => '1min', + 'OnBootSec' => "#{node['chef_client']['delay_after_boot']}sec", 'OnUnitInactiveSec' => "#{node['chef_client']['interval']}sec", 'RandomizedDelaySec' => "#{node['chef_client']['splay']}sec", } diff --git a/resources/systemd_timer.rb b/resources/systemd_timer.rb index 70b8b0cd..5c6439f7 100644 --- a/resources/systemd_timer.rb +++ b/resources/systemd_timer.rb @@ -27,7 +27,7 @@ property :user, String, default: 'root' -property :delay_after_boot, String, default: '1min' +property :delay_after_boot, String, default: '60sec' property :interval, String, default: '30min' property :splay, [Integer, String], default: 300, coerce: proc { |x| Integer(x) }, diff --git a/test/integration/timer_systemd/timer_systemd_spec.rb b/test/integration/timer_systemd/timer_systemd_spec.rb index a6ef5a78..b7a87baa 100644 --- a/test/integration/timer_systemd/timer_systemd_spec.rb +++ b/test/integration/timer_systemd/timer_systemd_spec.rb @@ -7,7 +7,7 @@ control 'has expected unit content' do describe file('/etc/systemd/system/chef-client.timer') do - its('content') { should match 'OnBootSec = 1min' } + its('content') { should match 'OnBootSec = 60sec' } its('content') { should match 'OnUnitInactiveSec = 1800sec' } its('content') { should match 'RandomizedDelaySec = 300sec' } end From 253c7be291399a6f6b8c764ddf3fc99a78765098 Mon Sep 17 00:00:00 2001 From: vineethp088 <70474789+vineethp088@users.noreply.github.com> Date: Fri, 11 Sep 2020 13:51:36 +0530 Subject: [PATCH 2/4] Make the onbootsec parameter to attribute --- resources/systemd_timer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/systemd_timer.rb b/resources/systemd_timer.rb index 5c6439f7..70b8b0cd 100644 --- a/resources/systemd_timer.rb +++ b/resources/systemd_timer.rb @@ -27,7 +27,7 @@ property :user, String, default: 'root' -property :delay_after_boot, String, default: '60sec' +property :delay_after_boot, String, default: '1min' property :interval, String, default: '30min' property :splay, [Integer, String], default: 300, coerce: proc { |x| Integer(x) }, From af2ea6d333f2db66f41b4ee8df17d11a1b84ccfd Mon Sep 17 00:00:00 2001 From: vineethp088 <70474789+vineethp088@users.noreply.github.com> Date: Fri, 11 Sep 2020 14:04:48 +0530 Subject: [PATCH 3/4] Update systemd_timer.rb --- resources/systemd_timer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/systemd_timer.rb b/resources/systemd_timer.rb index 70b8b0cd..48acf616 100644 --- a/resources/systemd_timer.rb +++ b/resources/systemd_timer.rb @@ -27,7 +27,7 @@ property :user, String, default: 'root' -property :delay_after_boot, String, default: '1min' +property :delay_after_boot, String, default: '60Sec' property :interval, String, default: '30min' property :splay, [Integer, String], default: 300, coerce: proc { |x| Integer(x) }, From 5fc0b14717dde27e384473b0cb3f9739933ccfcc Mon Sep 17 00:00:00 2001 From: vineethp088 <70474789+vineethp088@users.noreply.github.com> Date: Fri, 11 Sep 2020 14:05:41 +0530 Subject: [PATCH 4/4] Signed-off-by: vineethp08 --- resources/systemd_timer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/systemd_timer.rb b/resources/systemd_timer.rb index 48acf616..70b8b0cd 100644 --- a/resources/systemd_timer.rb +++ b/resources/systemd_timer.rb @@ -27,7 +27,7 @@ property :user, String, default: 'root' -property :delay_after_boot, String, default: '60Sec' +property :delay_after_boot, String, default: '1min' property :interval, String, default: '30min' property :splay, [Integer, String], default: 300, coerce: proc { |x| Integer(x) },