Apache2 install with Chef

Ive been working on getting an install of Apache2 up and running using Chef. Everything has worked so far until I run: chef-solo -c solo.rb -j web.json

The error im running into is:

Starting Chef Client, version 11.6.0

Compiling Cookbooks…
[2013-09-17T14:31:57-04:00] WARN: Cloning resource attributes for service[apache2] from prior resource (CHEF-3694)
[2013-09-17T14:31:57-04:00] WARN: Previous service[apache2]: /home/seth/chef-repo/cookbooks/apache2/recipes/default.rb:24:in `from_file’
[2013-09-17T14:31:57-04:00] WARN: Current service[apache2]: /home/seth/chef-repo/cookbooks/apache2/recipes/default.rb:221:in `from_file’
Converging 74 resources
Recipe: apache2::default
* package[apache2] action install
Error executing action `install` on resource ‘package[apache2]’

returned 1, expected 0

Resource Declaration:
# In /home/seth/chef-repo/cookbooks/apache2/recipes/default.rb

20: package “apache2” do
21: package_name node[‘apache’][‘package’]
22: end


Compiled Resource:
# Declared in /home/seth/chef-repo/cookbooks/apache2/recipes/default.rb:20:in `from_file’

package(“apache2”) do
action :install
retries 0
retry_delay 2
package_name “httpd”
version “2.2.15-29.el6.centos”
cookbook_name :apache2
recipe_name “default”


[2013-09-17T14:32:07-04:00] ERROR: Running exception handlers
[2013-09-17T14:32:07-04:00] ERROR: Exception handlers complete
[2013-09-17T14:32:07-04:00] FATAL: Stacktrace dumped to /home/seth/chef-repo/chef-solo/chef-stacktrace.out
Chef Client failed. 0 resources updated
[2013-09-17T14:32:07-04:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

Im not exactly sure whats going on here but im suspecting based on similar issues that there is a problem with me being on Centos and not using Apt. Still digging into this though since I know this should work even if its on Centos.

2 thoughts on “Apache2 install with Chef”

  1. Chef will automatically use the correct package manager for most operating systems. In this case it will see this is a CentOS machine and run something like ‘yum install httpd’. But that command is returning an exit status of 1 (error) so Chef correctly responds to the error by not proceeding.

    In a situation like this you may want to see debug output by appending ‘-l debug’ to the chef-solo command.

    If you run ‘yum install httpd’ from the command line of the CentOS machine do you get an error?

  2. Not sure what happened here. I didnt change anything chef wise but i finally got fed up with messing around with this and decided to try it from scratch again. I removed the whole Apache2 cookbook and then re-downloaded it. The exact same cookbook as before. Ran the exact same command as i had been before and didnt change anything in the default.rb file inside recipes…and it worked on the first run. Weird.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s