logrorate_app skips only_if evaluation
ArjunHariharan opened this issue · 1 comments
ArjunHariharan commented
logrorate_app skips only_if evaluation.
Ex-
node.set['logrotate']['enable'] = false
logrotate_app 'reactor' do
path "/tmp/log/tomcat/reactor*log"
size '64M'
frequency 'weekly'
rotate 9
options %w(copytruncate compress notifempty missingok)
only_if { node['logrotate']['enable'] }
end
Output-
- logrotate
Compiling Cookbooks...
Converging 3 resources
Recipe: logrotate::default
* yum_package[logrotate] action install[2015-02-08T02:31:51-05:00] INFO: Processing yum_package[logrotate] action install (logrotate::default line 20)
(up to date)
* directory[/etc/logrotate.d] action create[2015-02-08T02:32:03-05:00] INFO: Processing directory[/etc/logrotate.d] action create (logrotate::default line 22)
(up to date)
Recipe: test::default
* template[/etc/logrotate.d/reactor] action create[2015-02-08T02:32:03-05:00] INFO: Processing template[/etc/logrotate.d/reactor] action create (test::default line 50)
[2015-02-08T02:32:03-05:00] INFO: template[/etc/logrotate.d/reactor] created file /etc/logrotate.d/reactor
- create new file /etc/logrotate.d/reactor[2015-02-08T02:32:03-05:00] INFO: template[/etc/logrotate.d/reactor] updated file contents /etc/logrotate.d/reactor
- update content in file /etc/logrotate.d/reactor from none to 8c8d02
--- /etc/logrotate.d/reactor 2015-02-08 02:32:03.533364451 -0500
+++ /tmp/chef-rendered-template20150208-17186-x77msp 2015-02-08 02:32:03.532364451 -0500
@@ -1 +1,13 @@
+# This file was generated by Chef for .
+# Do not modify this file by hand!
+
+"/tmp/log/tomcat/reactor*log" {
+ weekly
+ size 64M
+ rotate 9
+ copytruncate
+ compress
+ notifempty
+ missingok
+}[2015-02-08T02:32:03-05:00] INFO: template[/etc/logrotate.d/reactor] owner changed to 0
[2015-02-08T02:32:03-05:00] INFO: template[/etc/logrotate.d/reactor] group changed to 0
[2015-02-08T02:32:03-05:00] INFO: template[/etc/logrotate.d/reactor] mode changed to 440
- change mode from '' to '0440'
- change owner from '' to 'root'
- change group from '' to 'root'
- restore selinux security context
[2015-02-08T02:32:03-05:00] WARN: Skipping final node save because override_runlist was given
[2015-02-08T02:32:03-05:00] INFO: Chef Run complete in 12.803214849 seconds
[2015-02-08T02:32:03-05:00] INFO: Skipping removal of unused files from the cache
Running handlers:
[2015-02-08T02:32:03-05:00] INFO: Running report handlers
Running handlers complete
[2015-02-08T02:32:03-05:00] INFO: Report handlers complete
Chef Client finished, 1/3 resources updated in 14.981741152 seconds
stevendanna commented
logrotate_app does not support not_if
or only_if
because it is implemented as a definition rather than an LWRP. As a workaround you can use a regular Ruby conditional:
if node['logrotate']['enable']
logrotate_app 'reactor' do
path "/tmp/log/tomcat/reactor*log"
size '64M'
frequency 'weekly'
rotate 9
options %w(copytruncate compress notifempty missingok)
end
end
We have an issue here:
to track converting this to an LWRP.