Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have been recently experimenting with Chef. I thought I would attempt to rebuild my personal web server using chef-solo. It's an AWS instance running the Amazon 64bit Linux AMI.

My first objective is to install nginx. I have cloned the Opscode cookbook repository, and am using their nginx cookbook.

My problem appears to be that chef-solo cannot find a template after it has started the process.

The command I'm using is

 chef-solo -j /etc/chef/dna.json

dna.json

{
  "nginx": {
    "user": "ec2-user"
  },
  "recipes": [ "nginx" ]
}

solo.rb

file_cache_path "/var/chef-solo"
cookbook_path "/var/chef-solo/cookbooks"

...the output

[root@ip-10-202-221-135 chef-solo]# chef-solo -j /etc/chef/dna.json
/usr/lib64/ruby/gems/1.9.1/gems/systemu-2.2.0/lib/systemu.rb:29: Use RbConfig instead of obsolete and deprecated Config.
[Fri, 27 Jan 2012 19:41:36 +0000] INFO: *** Chef 0.10.8 ***
[Fri, 27 Jan 2012 19:41:37 +0000] INFO: Setting the run_list to ["nginx"] from JSON
[Fri, 27 Jan 2012 19:41:37 +0000] INFO: Run List is [recipe[nginx]]
[Fri, 27 Jan 2012 19:41:37 +0000] INFO: Run List expands to [nginx]
[Fri, 27 Jan 2012 19:41:37 +0000] INFO: Starting Chef Run for ip-10-202-221-135.ec2.internal
[Fri, 27 Jan 2012 19:41:37 +0000] INFO: Running start handlers
[Fri, 27 Jan 2012 19:41:37 +0000] INFO: Start handlers complete.
[Fri, 27 Jan 2012 19:41:37 +0000] INFO: Missing gem 'mysql'
[Fri, 27 Jan 2012 19:41:38 +0000] INFO: Processing package[nginx] action install (nginx::default line 21)
[Fri, 27 Jan 2012 19:41:39 +0000] INFO: Processing directory[/var/log/nginx] action create (nginx::default line 23)
[Fri, 27 Jan 2012 19:41:39 +0000] INFO: Processing template[/usr/sbin/nxensite] action create (nginx::default line 30)
[Fri, 27 Jan 2012 19:41:39 +0000] INFO: Processing template[/usr/sbin/nxdissite] action create (nginx::default line 30)
[Fri, 27 Jan 2012 19:41:39 +0000] INFO: Processing template[nginx.conf] action create (nginx::default line 38)
[Fri, 27 Jan 2012 19:41:39 +0000] INFO: Processing template[/etc/nginx/sites-available/default] action create (nginx::default line 46)
[Fri, 27 Jan 2012 19:41:39 +0000] INFO: template[/etc/nginx/sites-available/default] mode changed to 644
[Fri, 27 Jan 2012 19:41:39 +0000] ERROR: template[/etc/nginx/sites-available/default] (nginx::default line 46) has had an error
[Fri, 27 Jan 2012 19:41:39 +0000] ERROR: template[/etc/nginx/sites-available/default] (/var/chef-solo/cookbooks/nginx/recipes/default.rb:46:in `from_file') had an error:
template[/etc/nginx/sites-available/default] (nginx::default line 46) had an error: Errno::ENOENT: No such file or directory - (/tmp/chef-rendered-template20120127-29441-1yp55vz, /etc/nginx/sites-available/default)
/usr/lib64/ruby/1.9.1/fileutils.rb:519:in `rename'
/usr/lib64/ruby/1.9.1/fileutils.rb:519:in `block in mv'
/usr/lib64/ruby/1.9.1/fileutils.rb:1515:in `block in fu_each_src_dest'
/usr/lib64/ruby/1.9.1/fileutils.rb:1531:in `fu_each_src_dest0'
/usr/lib64/ruby/1.9.1/fileutils.rb:1513:in `fu_each_src_dest'
/usr/lib64/ruby/1.9.1/fileutils.rb:508:in `mv'
/usr/lib64/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/provider/template.rb:47:in `block in action_create'
/usr/lib64/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/mixin/template.rb:48:in `block in render_template'
/usr/lib64/ruby/1.9.1/tempfile.rb:316:in `open'
/usr/lib64/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/mixin/template.rb:45:in `render_template'
/usr/lib64/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/provider/template.rb:99:in `render_with_context'
/usr/lib64/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/provider/template.rb:39:in `action_create'
/usr/lib64/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/resource.rb:440:in `run_action'
/usr/lib64/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/runner.rb:45:in `run_action'
/usr/lib64/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/runner.rb:81:in `block (2 levels) in converge'
/usr/lib64/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/runner.rb:81:in `each'
/usr/lib64/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/runner.rb:81:in `block in converge'
/usr/lib64/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/resource_collection.rb:94:in `block in execute_each_resource'
/usr/lib64/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/resource_collection/stepable_iterator.rb:116:in `call'
/usr/lib64/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/resource_collection/stepable_iterator.rb:116:in `call_iterator_block'
/usr/lib64/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
/usr/lib64/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/resource_collection/stepable_iterator.rb:104:in `iterate'
/usr/lib64/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
/usr/lib64/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/resource_collection.rb:92:in `execute_each_resource'
/usr/lib64/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/runner.rb:76:in `converge'
/usr/lib64/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/client.rb:312:in `converge'
/usr/lib64/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/client.rb:160:in `run'
/usr/lib64/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/application/solo.rb:192:in `block in run_application'
/usr/lib64/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/application/solo.rb:183:in `loop'
/usr/lib64/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/application/solo.rb:183:in `run_application'
/usr/lib64/ruby/gems/1.9.1/gems/chef-0.10.8/lib/chef/application.rb:67:in `run'
/usr/lib64/ruby/gems/1.9.1/gems/chef-0.10.8/bin/chef-solo:25:in `<top (required)>'
/usr/bin/chef-solo:19:in `load'
/usr/bin/chef-solo:19:in `<main>'
[Fri, 27 Jan 2012 19:41:39 +0000] ERROR: Running exception handlers
[Fri, 27 Jan 2012 19:41:39 +0000] ERROR: Exception handlers complete
[Fri, 27 Jan 2012 19:41:39 +0000] FATAL: Stacktrace dumped to /var/chef-solo/chef-stacktrace.out
[Fri, 27 Jan 2012 19:41:39 +0000] FATAL: Errno::ENOENT: template[/etc/nginx/sites-available/default] (nginx::default line 46) had an error: Errno::ENOENT: No such file or directory - (/tmp/chef-rendered-template20120127-29441-1yp55vz, /etc/nginx/sites-available/default)

What am I doing incorrectly?

share|improve this question
add comment

2 Answers

It looks like a directory in the tree /etc/nginx/sites-available doesn't exist and ought to be created.

If you want to add to the opscode recipe, here's how you can have chef create the directory for you:

http://wiki.opscode.com/display/chef/Resources#Resources-Directory

share|improve this answer
add comment

To fix you should probably add this to the beginning of your nginx default recipe:

directory "/etc/nginx/sites-available" do
    owner "root"
    group "root"
    mode "0755"
end

For what it's worth, I've been doing the same thing with Chef (Hosted), EC2 and Amazon Linux. It took me a while, but I figured out that it was almost always easier to just roll my own recipes. I now have a dozen that I now use, and I've removed all the Opscode shared ones I initially tried.

In fact, my default recipe for nginx has just one line:

`package "nginx"`

So one way to go is to install that on your server first with yum install nginx and then grab the default config file it created. Bring that back to your cookbook as a template, and put in ERB lines to customize any values for your needs.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.