Reputation: 31736
Totally new to chef ... We used to install elasticsearch from a ppa repo but now I want to build it from scratch (repo isn't being updated any more) each time I change the version number in my attributes/default.rb
Right now I have a bash block that just pulls down the gz file, unzips it and links it to the right place, but I don't know how to make it so that it won't run everytime I run chef-solo.
Any suggestions?
Upvotes: 2
Views: 765
Reputation: 21226
I create a text file with version inside. The logic is simple.
IO.read(filename)
) is different: unzip.By default the resource that creates file has action :nothing
and is notified by unzip. This way not only unzip will not run, if the version is the same, but the version file will be left untouched too.
Pseudo-code to illustrate the logic:
unzip "resource_name" do
not_if { ::File.exists?( filename ) and node[:version]==IO.read( filename ).strip }
notifies :create, "file[#{filename}]"
end
file filename do
action :nothing
content node[:version]
end
Upvotes: 3