Chef-client cookbook cron job


#1

Hello,

I need to setup a cookbook to be run daily at 1 am. I am trying to use chef-client cookbook, but no matter what setting I set, it runs about every 30 minutes.

I don;t want to set cron job manually as there are many nodes. I have separate role which is I am using as runlist. I did normal and override attributes from this role to set it up.

I tried to set hour/minute attributes along with use_cron_d to true/false. I tried to use init_style but it still runs every 30 minutes (± splay)

What I may be doing wrong…

Thanks

M


#2

I think I figures this…

I can’t use chef-client default recipe in my run_list, I have to use chef-client::cron instead.

Thanks

M


#3

Hello,

Is there a way to specify timezone in chef-client cron?

I set a cron job to be run at midnight (verified it) and all my servers on UTC, but I see half severs (at least in chef server reports), ran at 5 am and other half at midnight…
Not sure what might cause this.

Thanks

M


#4

Was your recipe set to restart crond? And did the timezones on ther server get set to UTC, after crond started, the first time?

I often find it useful to reboot a server when changing the timezone, just to make sure I don’t have to pick and choose which daemons need to be restarted.


#5

Hi

knife ssl fetch fails if I use the hostname in the knife.rb file.

I am able to ping telnet to port 443 and wget with the hostname .

[root@chefserver .chef]# knife ssl check
Connecting to host chefserver.lbs.com:443
ERROR: Service temporarily unavailable
/opt/chefdk/embedded/lib/ruby/2.4.0/net/http/response.rb:333:in
stream_check': undefined methodclosed?’ for nil:NilClass (NoMethodError)
from /opt/chefdk/embedded/lib/ruby/2.4.0/net/http/response.rb:202:in
read_body' from /opt/chefdk/embedded/lib/ruby/2.4.0/net/http/response.rb:229:inbody’
from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/knife.rb:541:in
rescue in format_rest_error' from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/knife.rb:538:informat_rest_error’
from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/knife.rb:510:in
humanize_http_exception' from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/knife.rb:456:inhumanize_exception’
from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/knife.rb:447:in
rescue in run_with_pretty_exceptions' from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/knife.rb:436:inrun_with_pretty_exceptions’
from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/knife.rb:220:in
run' from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/ lib/chef/application/knife.rb:160:inrun’
from /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/bin/knife:25:in
<top (required)>' from /opt/chefdk/bin/knife:250:inload’
from /opt/chefdk/bin/knife:250:in `’
[root@chefserver .chef]#

[root@chefserver ~]# hostname
chefserver
[root@chefserver ~]# hostname -f
chefserver.lbs.com
[root@chefserver ~]# cat /etc/hosts
#127.0.0.1 localhost localhost.localdomain localhost4
localhost4.localdomain4
::1 localhost localhost.localdomain localhost6
localhost6.localdomain6
9.126.144.73 chefserver.lbs.com chefdk chefserver
9.126.144.76 chef-compliance chef-compliance.lbs.com

[root@chefserver ~]# ping chefserver.lbs.com
PING chefserver.lbs.com (9.126.144.73) 56(84) bytes of data.
64 bytes from chefserver.lbs.com (9.126.144.73): icmp_seq=1 ttl=64
time=0.033 ms
64 bytes from chefserver.lbs.com (9.126.144.73): icmp_seq=2 ttl=64
time=0.070 ms

Thanks
Prerna


#6

Thanks,

I added environment_variable CRON_TZ=UTC but that didn’t help.

I am not sure when crond started. May be I will add that as first step in chef-client cookbook…

Thanks

M