I’ve recently run into a strange issue which I fail to explain.
I’ve a recipe that configures a cron resource:
cron 'keystone-manage-token-flush' do
minute node['openstack']['identity']['token_flush_cron']['minute']
hour node['openstack']['identity']['token_flush_cron']['hour']
day node['openstack']['identity']['token_flush_cron']['day']
weekday node['openstack']['identity']['token_flush_cron']['weekday']
command "keystone-manage token_flush > #{log_file} 2>&1; "\
"echo keystone-manage token_flush ran at $(/bin/date) with exit code $? >> #{log_file}"
end
there is a file in the attributes directory that sets default values for node[‘openstack’][‘identity’][‘token_flush_cron’][‘minute’] and other attributes.
I want to modify the crontab dynamically based on results of chef search. I created a recipe, let’s call it recipe2, that sets the node attributes like so:
node.default['openstack']['identity']['token_flush_cron']['minute'] = '55'
and added it to the runlist before the recipe that has the cron resource.
It seems to be working fine, when checking the crontab, the minute, hour, day, etc. parameters have the values as set in recipe2. However, after every chef-client run, a new crontab is added with the same minute, hour, command, etc so after a couple of chef-client runs, my crontab looks like this:
# Chef Name: keystone-manage-token-flush
23 04 * * Mon,Thu keystone-manage token_flush > /var/log/keystone/token-flush.log 2>&1; echo keystone-manage token_flush ran at $(/bin/date) with exit code $? >> /var/log/keystone/token-flush.log
23 04 * * Mon,Thu keystone-manage token_flush > /var/log/keystone/token-flush.log 2>&1; echo keystone-manage token_flush ran at $(/bin/date) with exit code $? >> /var/log/keystone/token-flush.log
23 04 * * Mon,Thu keystone-manage token_flush > /var/log/keystone/token-flush.log 2>&1; echo keystone-manage token_flush ran at $(/bin/date) with exit code $? >> /var/log/keystone/token-flush.log
What am I missing? Why insn’t the cron resource recognizing that a correct crontab exists already and is creating a new crontab entry on every run?
I’m using chef-client version 12.21.26