Closed haidangwa closed 3 years ago
also seeing this
Seeing this after updating the chef-client cookbook today as well.
Put the following override in my base role as a workaround:
{
"chef_client": {
"cron": {
"log_file": "chef-client.log"
}
}
}
It should just overwrite chef-client.log on every run.
Since this cron command contains -c /etc/chef/client.rb
and the log_location
that is generated (by default) in client.rb is already set to /var/log/chef/client.log
, I would say that the attempted redirect to a log file or /dev/null
is not needed at all.
I am also experiencing this issue on RHEL 7.
I looked at the cookbook and the attribute names and/or their use is inconsistent. There is a log_dir
and a log_file
. That Indicates to me that one (i.e. log_file
) is a filename (without the directory or absolute path) and the other (i.e. log_dir
) is the absolute path where the log file lives. The problem is that the log_file
attribute is set to /dev/null
which is an absolute path and violates the previous stated assumptions.
@tas50 I'm pretty sure this was resolved by https://github.com/chef-cookbooks/chef-client/pull/727
Should be now
This didn't fix the issue above. Running 12.3.4 still has it showing up in cron as:
*/30 * * * * root /bin/sleep 24; /usr/bin/cinc-client -c /etc/cinc/client.rb >> /var/log/cinc/dev/null 2>&1
my cookbook is specified as such:
node.default['chef_client']['init_style'] = 'none'
node.default['chef_client']['cron']['minute'] = '*/30'
node.default['chef_client']['cron']['hour'] = '*'
node.default['chef_client']['cron']['use_cron_d'] = true
node.default['chef_client']['cron']['append_log'] = true
node.default['chef_client']['cron']['environment_variables'] = {
PATH: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games'
}
node.override['chef_client']['bin'] = '/usr/bin/cinc-client'
node.override['chef_client']['conf_dir'] = '/etc/cinc'
node.override['chef_client']['log_dir'] = '/var/log/cinc'
node.override['chef_client']['log_file'] = 'client.log'
node.override['chef_client']['run_path'] = '/var/run/cinc'
node.override['chef_client']['file_backup_path'] = '/var/lib/cinc'
node.override['chef_client']['log_rotation']['postrotate'] = 'systemctl reload cinc-client.service >/dev/null || :'
@SeanSith what version of Chef are you running? If you're using a newer version, then this would be a native resource in chef.
Due to https://github.com/chef-cookbooks/chef-client/blob/75a99f10b19302db2bde16bf624f82f4d6b4ca26/attributes/default.rb#L56 default value and when
node['chef-client']['cron']['use_cron_d'] == true
, the cron command writes to a log file at/var/log/chef/dev/null
instead of/dev/null
.