I'm new to Chef and the documentation (even the home page of their website) makes my head spin. I'm not even sure if I'm using it for the correct purpose.
My intent is to setup a Vagrantfile
that tells Chef Solo to install some software automatically when I spin up a new box. That is one of Chef Solo's intended uses, am I correct?
I'm not really sure if that qualifies as one of "the hardest infrastructure challenges on the planet", but whatever.
My first goal is to get Chef Solo to install nginx
for me. In my project, I've cloned the cookbook for nginx
:
$ git clone https://github.com/opscode-cookbooks/nginx.git cookbooks/nginx
I edited my Vagrantfile
to look like this:
Vagrant.configure("2") do |config|
config.vm.box = "opscode-ubuntu-1204"
config.vm.provision :chef_solo do |chef|
chef.add_recipe "nginx"
end
end
When I ran vagrant up
, I got some errors that some cookbooks weren't found (build-essential
, apt
, etc), so I cloned them from their appropriate repos. Now, when I vagrant up
, I'm getting this output:
[2013-10-01T20:31:03+00:00] INFO: Processing package[nginx] action install (nginx::package line 38)
Error executing action `install` on resource 'package[nginx]'
Chef::Exceptions::Exec
----------------------
apt-get -q -y install nginx=1.1.19-1ubuntu0.1 returned 100, expected 0
Resource Declaration:
---------------------
# In /tmp/vagrant-chef-1/chef-solo-1/cookbooks/nginx/recipes/package.rb
38: package node['nginx']['package_name'] do
39: notifies :reload, 'ohai[reload_nginx]', :immediately
40: end
41:
Compiled Resource:
------------------
# Declared in /tmp/vagrant-chef-1/chef-solo-1/cookbooks/nginx/recipes/package.rb:38:in `from_file'
package("nginx") do
action :install
retries 0
retry_delay 2
package_name "nginx"
version "1.1.19-1ubuntu0.1"
cookbook_name :nginx
recipe_name "package"
end
[2013-10-01T20:31:08+00:00] INFO: Running queued delayed notifications before re-raising exception
[2013-10-01T20:31:08+00:00] ERROR: Running exception handlers
[2013-10-01T20:31:08+00:00] ERROR: Exception handlers complete
[2013-10-01T20:31:08+00:00] FATAL: Stacktrace dumped to /tmp/vagrant-chef-1/chef-stacktrace.out
[2013-10-01T20:31:08+00:00] FATAL: Chef::Exceptions::Exec: package[nginx] (nginx::package line 38) had an error: Chef::Exceptions::Exec: apt-get -q -y install nginx=1.1.19-1ubuntu0.1 returned 100, expected 0
Chef never successfully completed! Any errors should be visible in the output above. Please fix your recipes so that they properly complete.
How can I fix my recipes so that they properly complete?