Reputation: 1723
Is there anyway I can delay the entire chef recipe running in AWS OpsWorks?
I was trying to execute a sleep command but no success:
Chef::Log.info("Delaying chef execution")
execute 'delay' do
command 'sleep 60'
end
What I want to achieve is to delay all the Ruby code in a recipe based on where I make the delay, could be on top, could be in the middle.
EDIT: Complete Chef recipe:
Chef::Log.info("stopping service rsyslog")
service 'rsyslog' do
action :stop
end
Chef::Log.info("configuring private ip addresses for mesos_master templates")
ruby_block "configuring_mesos_master_templates" do
# Do stuff
end
Chef::Log.info("starting service rsyslog")
service 'rsyslog' do
action :start
end
Chef::Log.info("restarting service zookeeper")
service 'zookeeper' do
action :restart
end
Chef::Log.info("restarting service mesos-master")
service 'mesos-master' do
provider Chef::Provider::Service::Upstart
action :restart
end
Chef::Log.info("starting service marathon")
service 'marathon' do
action :start
end
Upvotes: 0
Views: 6818
Reputation: 532
In the meanwhile Chef (in version 15.5) introduced an own 'chef_sleep resource' for this like described in https://docs.chef.io/resources/chef_sleep/.
Upvotes: 0
Reputation: 54249
Doing that is fine, or you could use a ruby_block
resource and Ruby's sleep()
method. Remember how ordering works though, see https://coderanger.net/two-pass/ for an overview of the compile-vs-converge split.
Upvotes: 1