[chef] Re: Re: Re: Nginx cookbook usage help


Chronological Thread 
  • From: Sascha Bates < >
  • To:
  • Cc: Morgan Blackthorne < >
  • Subject: [chef] Re: Re: Re: Nginx cookbook usage help
  • Date: Thu, 02 Aug 2012 08:42:04 -0500

When I did some work on Puppet, I found the concept of the file server hella confusing as I had come from Chef. I also found the documentation on where to put template files and file-files confusing. (You should put templates in X dir but Puppet will look for them in Y dir first, WAT?)

In Chef, when you have a file or template associated with a cookbook, you can simply drop them in <cookbook>/templates/default and <cookbook>/files/default. There are more complex use cases as well, however, 99% of the time the default directory is good enough for what you want.


When referencing the files in recipes, you use the "source" attribute and chef will figure out where the file is starting by looking in those default cookbook directories.

cookbook_file "/etc/blah/blah.config" do
  source "blah.config"
end

This is all in the resource reference page, but I figured it was worth talking about in more detail if you are used to Puppet and a file server.  Chef and Puppet seem to come at this from odd directions if you are used to one over the other.  I actually started a Puppet for Chef users series on my blog and was going to talk about files and templates, but figuring it out for Puppet kind of gave me some ragefaces. And by the time I was over it, I was working on something else. I may revisit.
Sascha

On 8/2/12 7:29 AM, Morgan Blackthorne wrote:
" type="cite">Thanks, but I'm a bit more used to Puppet. Where can I put the actual file in Chef to push it to the node? I'd like to autoconfigure the node completely with Chef. Does that go in a databag, or a template, or?

Still trying to get bootstrapped myself :) Too bad there's know "knife-person bootstrap"...

--
~*~ StormeRider ~*~

"Every world needs its heroes [...] They inspire us to be better than we are. And they protect from the darkness that's just around the corner."

(from Smallville Season 6x1: "Zod")



On Thu, Aug 2, 2012 at 5:19 AM, Dan Crosta < " target="_blank"> > wrote:
On Aug 2, 2012, at 7:28 AM, Morgan Blackthorne wrote:
I've got the nginx cookbook in place now, but I'm a little fuzzy on how to proceed next. I bootstrapped a node and it configured nginx with all the defaults. I wrote my own config block which I would like to either:
  • place in /etc/nginx/sites-available
  • create a symlink to it in /etc/nginx/sites-enabled
  • disable the /etc/nginx/sites-enabled/default symlink
You can drop a file in /etc/nginx/sites-available, and then use

    nginx_site "name-of-your-file-in-sites-available" do
      enable true
    end

to have Chef enable the site for you (reloading nginx's configuration as appropriate)


Or, to just replace the default config block directly and save the hassle of mucking around with multiple files.

What's the best way to go about this?

Recent versions of the nginx cookbook have an attribute node["nginx"]["default_site_enabled"] which you can set to false to disable the default site. You can then use the above recommendation to institute your own default site. You can set this from a recipe, role, environment, etc.


- Dan





Archive powered by MHonArc 2.6.16.

§