Keeping your AMI at the latest version with Chef
I created some custom AMIs that I built using a Chef recipe. It took me a while to figure out why they weren't updating to the latest version.
Turns out the opscode-yum recipe had taken over /etc/yum.conf, which is where Amazon specifies that Yum should be looking in the latest version, by setting $releasever=latest
Add this to your Chef recipe, and Yum will go back to looking for the latest releases from Amazon:
ruby_block "reload-internal-yum-cache" do
block { Chef::Provider::Package::Yum::YumCache.instance.reload }
action :nothing
end
execute "yum-clean" do
command "yum clean all"
action :nothing
end
file "/etc/yum/vars/releasever" do
content "latest"
notifies :run, "execute[yum-clean]", :immediately
notifies :create, "ruby_block[reload-internal-yum-cache]", :immediately
end
Written by Alec Hipshear
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#