[chef] Question Item re: not_if condition


Chronological Thread 
  • From: < >
  • To:
  • Subject: [chef] Question Item re: not_if condition
  • Date: Fri, 13 Jan 2012 10:38:40 -0800 (PST)

Hi folks -

I'm seeing what I think is a bug, but fully willing to acknowledge its 
actually
my lack of understanding.

I'm trying to setup a cronjob if a node attribute is equal to "0", and delete
it if its non-zero.  I've referred to these resource help docs:

http://wiki.opscode.com/display/chef/Resources#Resources-Cron
http://wiki.opscode.com/display/chef/Resources#Resources-ConditionalExecution

I'm running Ruby 1.8.7, and chef-client 10.4...and my recipe looks like this:

....
cron "logstoragecleanup" do
        user "applogshipper"
        hour "#{node['applogshipper']['logstorageserver']['hour_to_run']}"
        minute "#{node['applogshipper']['logstorageserver']['minute_to_run']}"
        command "/home/applogshipper/cleanup.sh"
        only_if {
node[:applogshipper][:logstorageserver][:enable_cleanup_cronjob].to_i == 0 }
end

#remove existing cron jobs
cron "logstoragecleanup" do
        user "applogshipper"
        action :delete
        not_if {
node[:applogshipper][:logstorageserver][:enable_cleanup_cronjob].to_i == 0 }
end
...

When I set "enable_cleanup_cronjob" to non-zero, the cron delete action 
doesn't
appear to get triggered.

Any suggestions on why this doesn't work...or maybe a better approach for the
same solution?

Thanks.
Bryan



Archive powered by MHonArc 2.6.16.

§