discourse/chef/cookbooks/omnibus_updater/recipes/script.rb
Elliot Murphy f3bcbd8bc3 Use chef-solo to install phantomjs into Vagrant VM.
This introduces two configuration management runs into the
Vagrant provisioning phase. The first chef-solo run ensures that
a current version of chef is installed using the omnibus updater.
The second chef-solo run installs vim and phantomjs.

Much more is possible, this is a proof of concept.
Cookbooks are stored in the chef directory, and managed by
librarian-chef, which is like a bundler for cookbooks.

Chef is run when VM is first downloaded and booted, but not on
subsequent halt/up cycles. To force chef to run again, use
`vagrant provision`.
2013-02-07 14:09:57 -05:00

39 lines
1.5 KiB
Ruby

include_recipe 'omnibus_updater::set_remote_path'
remote_file "chef omnibus_script[#{File.basename(node[:omnibus_updater][:full_uri])}]" do
path File.join(node[:omnibus_updater][:cache_dir], File.basename(node[:omnibus_updater][:full_uri]))
source node[:omnibus_updater][:full_uri]
backup false
not_if do
File.exists?(
File.join(node[:omnibus_updater][:cache_dir], File.basename(node[:omnibus_updater][:full_uri]))
) || (
Chef::VERSION.to_s.scan(/\d+\.\d+\.\d+/) == node[:omnibus_updater][:full_version].scan(/\d+\.\d+\.\d+/) && OmnibusChecker.is_omnibus?
)
end
end
# NOTE: We do not use notifications to trigger the install
# since they are broken with remote_file in 0.10.10
execute "chef omnibus_install[#{node[:omnibus_updater][:full_version]}]" do
command "bash #{File.join(node[:omnibus_updater][:cache_dir], File.basename(node[:omnibus_updater][:full_uri]))}"
only_if do
(File.exists?(
File.join(node[:omnibus_updater][:cache_dir], File.basename(node[:omnibus_updater][:full_uri]))
) &&
Chef::VERSION.to_s.scan(/\d+\.\d+\.\d+/) != node[:omnibus_updater][:full_version].scan(/\d+\.\d+\.\d+/)) ||
!OmnibusChecker.is_omnibus?
end
end
ruby_block "omnibus_updater[remove old install scripts]" do
block do
Dir.glob(File.join(node[:omnibus_updater][:cache_dir], 'chef*.sh')).each do |file|
unless(file.include?(node[:omnibus_updater][:version]))
Chef::Log.info "Deleting stale omnibus script: #{file}"
File.delete(file)
end
end
end
end