It’s that time again! I’m pleased to announce the release candidates of Chef 0.7.12 and Ohai 0.3.4.
I hope you’ll take the time to test both releases on a development snapshot of any production infrastructure, and report bugs towards the 0.7.12 and 0.3.4 projects on JIRA. I’ve tentatively scheduled the release of 0.7.12 and 0.3.4 final for later this week.
The MVP for this release is Diego Algorta; he has supplied us with the ability for Ohai to detect (CHEF-293) the correct locale for every Linux system, and use this information while parsing system commands used internally in Chef. This fix restores the ability for Chef and Ohai to be used on systems where a non-English installation was selected.
We’ve had a staggering number of contributions this cycle and considerably increased our speed and stability. New features worth noting are the completion of Lightweight Resources and Providers, and the Deploy and SCM resources.
Lightweight Resources and Providers allow the seasoned cookbook author to build standard Chef resources and providers via a lightweight cookbook based DSL. Cookbooks gain two new optional directories for this feature, ‘resources/’ and ‘providers/’. We’re expecting the emergence of lightweight resources and providers to almost entirely replace the usage of definitions, which are used currently throughout cookbooks as global macros.
Cookbook Layout
cookbooks/lwrp/providers/default.rb cookbooks/lwrp/recipes/default.rb cookbooks/lwrp/resources/default.rb
This will build the following resources and providers:
Chef::Resource::Lwrp Chef::Provider::Lwrp
Without reproducing too much from the existing documentation, a few examples:
cookbooks/lwrp/resources/default.rb
actions :print_message, :touch_file attribute :message, :kind_of => String attribute :filename, :kind_of => String
cookbooks/lwrp/providers/default.rb
action :print_message do puts new_resource.message end action :touch_file do file "#{node[:tmpdir]}/#{new_resource.filename}" do action :create end end
cookbooks/lwrp/recipes/default.rb
lwrp "foo" do message "Default everything" action :print_message provider Chef::Provider::Lwrp end lwrp "bar" do filename "/tmp/foo" action :touch_file provider Chef::Provider::Lwrp end
The chef-deploy project written originally by Ezra Zygmuntowicz to bring Capistrano-strategy deployment to Chef has been ported to Chef proper. The SCM functionality has additionally been extracted into Git and Subversion resources. I’m increasingly excited with the prospects opened by having deployment and SCM functionality available as first class citizens in Chef, and hope we can continue to offer more enhancements such as alternate (cough Heroku) deploy strategies.
I believe a few examples will speak for themselves:
CouchDB from SCM?
subversion "CouchDB Edge" do repository "http://svn.apache.org/repos/asf/couchdb/trunk" revision "HEAD" destination "/opt/mysources/couch" action :sync end
Prefer git?
git "/opt/mysources/couch" do repository "git://git.apache.org/couchdb.git" reference "HEAD" action :sync end
Fancy deploying a rails app with a custom application layout and in-line Chef resource deployment hooks? No problem!
deploy "#{node[:tmpdir]}/deploy" do repo "#{node[:tmpdir]}/gitrepo/typo/" environment "RAILS_ENV" => "production" revision "HEAD" action :deploy migration_command "rake db:migrate --trace" migrate true symlinks "system" => "public/system", "pids" => "tmp/pids", "log" => "log" # Callbacks before_migrate do current_release = release_path directory "#{current_release}/deploy" do mode "0755" end # creates a callback for before_symlink template "#{current_release}/deploy/before_symlink_callback.rb" do source "embedded_recipe_before_symlink.rb.erb" mode "0644" end end # This file can contain Chef recipe code, plain ruby also works before_symlink "deploy/before_symlink_callback.rb" restart do current_release = release_path file "#{release_path}/tmp/restart.txt" do mode "0644" end end end
Release Notes – Chef – Version 0.7.12rc0
Release Notes – Ohai – Version 0.3.4rc0