- From: Tomasz Chmielewski <
>
- To:
- Subject: [chef] best way to run something only once?
- Date: Thu, 19 Jun 2014 00:34:57 +0200
- Domainkey-signature: a=rsa-sha1; c=nofws; d=wpkg.org; h=date:from:to :subject:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=eEljvzqWAiiLC5hU qagq4yzshbNixmla/YI2cfTnEz2wGbHrfUpwYMVKmLJjmMza1dX9XvVbaSd0kXMu O1esmuDQmBPnrohSJgI4RvbzI2pGzoiFJOUQnxDuX1hRMWehI5fHMchPCcM8JxM9 /V9UUjeNoXxzCyiXD1Z8ADeQuaY=
Does chef have some built-in way to run some recipes (or parts of it)
once only?
Say, I have the following (here, bash snippet, but could be anything):
bash 'adjust-supervisor' do
code <<-EOF
...some_code...
EOF
end
How would you approach to make sure it only runs once?
I figured I could use something like this in the recipe:
not_if { ::File.exists?("/etc/chef/stamps/some-description.stamp") }
followed by:
file "/etc/chef/stamps/some-description.stamp" do
owner "root"
group "root"
mode "0644"
action :create
end
It allows me to easily re-run by removing the stamp file, if needed.
But not sure it's the optimal way to make sure we run a given thing
once.
How do you approach this?
--
Tomasz Chmielewski
http://www.sslrack.com
- [chef] best way to run something only once?, Tomasz Chmielewski, 06/18/2014
Archive powered by MHonArc 2.6.16.