From b6cc8a908482997ecd84ac6bbce0607bd759df47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20B=C3=A9rtoli?= Date: Fri, 25 Mar 2022 07:23:11 -0300 Subject: [PATCH 1/3] fix(conf): add 'monthly' interval --- logrotate/templates/logrotate.conf.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logrotate/templates/logrotate.conf.tmpl b/logrotate/templates/logrotate.conf.tmpl index 865e04c..db62268 100644 --- a/logrotate/templates/logrotate.conf.tmpl +++ b/logrotate/templates/logrotate.conf.tmpl @@ -23,7 +23,7 @@ no{{ parameter }} # See "man logrotate" for details. # log files rotation period -{% for period in ['hourly', 'daily', 'weekly', 'yearly'] -%} +{% for period in ['hourly', 'daily', 'weekly', 'monthly', 'yearly'] -%} {{ set_parameter(period) }} {%- endfor %} From 957e6897c052840a16bdd281b3e96132c4f37c01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20B=C3=A9rtoli?= Date: Sun, 27 Mar 2022 20:52:36 -0300 Subject: [PATCH 2/3] test(jobs): add a monthly job test --- pillar.example | 12 ++++++++++++ test/integration/default/controls/jobs.rb | 16 ++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/pillar.example b/pillar.example index ca4fcb7..b86337f 100644 --- a/pillar.example +++ b/pillar.example @@ -35,6 +35,18 @@ logrotate: - notifempty - create 640 root adm - sharedscripts + a_monthly_job: + path: + - /tmp/var/log/a_service/*.log + config: + - monthly + - missingok + - rotate 12 + - compress + - delaycompress + - notifempty + - create 640 root adm + - sharedscripts syslog: path: - /var/log/cron diff --git a/test/integration/default/controls/jobs.rb b/test/integration/default/controls/jobs.rb index a2d94e4..462424d 100644 --- a/test/integration/default/controls/jobs.rb +++ b/test/integration/default/controls/jobs.rb @@ -88,3 +88,19 @@ describe file('/etc/logrotate.hourly.d/nginx_high_traf') do its('content') { should include 'postrotate' } its('content') { should include 'kill -USR1 $(cat /var/run/nginx_high_traf.pid)' } end + +describe file('/etc/logrotate.d/a_monthly_job') do + it { should be_file } + it { should be_owned_by 'root' } + it { should be_grouped_into 'root' } + its('mode') { should cmp '0644' } + its('content') { should include '/var/log/a_service/*.log' } + its('content') { should include 'monthly' } + its('content') { should include 'rotate 12' } + its('content') { should include 'missingok' } + its('content') { should include 'compress' } + its('content') { should include 'delaycompress' } + its('content') { should include 'notifempty' } + its('content') { should include 'sharedscripts' } +end + From 3bdc11b5c2b2f2b60d8dfe7b3a493fce532b0c6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20B=C3=A9rtoli?= Date: Mon, 28 Mar 2022 09:38:54 -0300 Subject: [PATCH 3/3] test(jobs): reorder parameters to match pillar --- test/integration/default/controls/jobs.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/integration/default/controls/jobs.rb b/test/integration/default/controls/jobs.rb index 462424d..46cc91a 100644 --- a/test/integration/default/controls/jobs.rb +++ b/test/integration/default/controls/jobs.rb @@ -96,11 +96,11 @@ describe file('/etc/logrotate.d/a_monthly_job') do its('mode') { should cmp '0644' } its('content') { should include '/var/log/a_service/*.log' } its('content') { should include 'monthly' } - its('content') { should include 'rotate 12' } its('content') { should include 'missingok' } + its('content') { should include 'rotate 12' } its('content') { should include 'compress' } its('content') { should include 'delaycompress' } its('content') { should include 'notifempty' } + its('content') { should include 'create 640 root adm' } its('content') { should include 'sharedscripts' } end -