# Examples for newbies

**URL:** <https://discourse.chef.io/t/examples-for-newbies/1880>\
**Category:** Chef Infra (archive)\
**Created:** [June 22, 2011, 1:24pm UTC](https://discourse.chef.io/t/examples-for-newbies/1880 "2011-06-22T13:24:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ItsMikeE](https://avatars.discourse-cdn.com/v4/letter/i/d6d6ee/32.png) [@ItsMikeE](https://discourse.chef.io/u/ItsMikeE)\
**Post date:** [June 22, 2011, 1:24pm UTC](https://discourse.chef.io/t/examples-for-newbies/1880/1 "2011-06-22T13:24:10Z")

</div>

I am finding it difficult to get to grips with chef.  
There are just too many different ideas to get my head around at one time.

Is there some kind of Idiot’s Guide to Getting Started with Chef?

I do not want to use the hosted chef. The servers I manage are not internet  
facing.  
I suppose I could create a hosted chef account and not have any nodes if that  
will give me access to useful examples.

I have built a chef server and a couple of clients and I am now looking at my  
first recipe / cookbook.

For my first noddy example, I want to set up two different versions of a config  
file.  
I have created two different versions of the file and stored them in  
cookbooks/NAME/templates/default

Should I use ROLEs to decide which server gets which config file?  
Do I do a test on variables or attributes? and how would I set these up (via  
WebUI? or coding in the cookbook?)?

I can see the potential in chef, but feel that the various wiki examples and  
the getting started guide are not pitched at a complete newbie like myself.

I am an experienced Sys Admin, but have no chef or ruby experience.

Thanks in advance

---

<div class="post-metadata">

**Author:** ![John\_E\_Vincent\_lusis](https://avatars.discourse-cdn.com/v4/letter/j/c89c15/32.png) [@John\_E\_Vincent\_lusis](https://discourse.chef.io/u/John_E_Vincent_lusis)\
**Post date:** [June 22, 2011, 1:35pm UTC](https://discourse.chef.io/t/examples-for-newbies/1880/2 "2011-06-22T13:35:00Z")

</div>

Response inline

On Wed, Jun 22, 2011 at 9:24 AM, ItsMikeE [chef@ernstoff.net](mailto:chef@ernstoff.net) wrote:

> I am finding it difficult to get to grips with chef.  
> There are just too many different ideas to get my head around at one time.
> 
> Is there some kind of Idiot's Guide to Getting Started with Chef?
> 
> I do not want to use the hosted chef. The servers I manage are not internet  
> facing.  
> I suppose I could create a hosted chef account and not have any nodes if that  
> will give me access to useful examples.

The hosted platform won't give you an examples of how to use Chef.

> I have built a chef server and a couple of clients and I am now looking at my  
> first recipe / cookbook.
> 
> For my first noddy example, I want to set up two different versions of a config  
> file.  
> I have created two different versions of the file and stored them in  
> cookbooks/NAME/templates/default
> 
> Should I use ROLEs to decide which server gets which config file?  
> Do I do a test on variables or attributes? and how would I set these up (via  
> WebUI? or coding in the cookbook?)?

You have a couple of ways you can handle the different files but it's  
worth stepping back and seeing why you need two versions of the same  
file. Remember that you can inject the content based on any criteria  
in the recipe. The shift to data-driven design is a bit of a jump  
sometimes. You would more than likely have have the template populated  
with sane defaults and override at the node level or in a data bag. If  
that model doesn't work, you can create two distinct recipes (say  
fooapp::prod and fooapp::dev) and assign those to a given role. Roles  
can have override attributes as well.

The biggest thing to grok is that you can override the contents of  
templates or even paths that recipes take based on data from data  
bags, attributes or search results. A REALLY good (but complicated to  
the first timer) example of this is the application cookbook. One set  
of recipes can deploy multiple apps on different hosts because the  
data that it uses is described in a data bag.

> I can see the potential in chef, but feel that the various wiki examples and  
> the getting started guide are not pitched at a complete newbie like myself.
> 
> I am an experienced Sys Admin, but have no chef or ruby experience.
> 
> Thanks in advance

Can you provide a bit more tangible example of what you're trying to  
accomplish? I totally understand not being able to post any specific  
code if it's got sensitive information but even a sanitized outline is  
better than hypothetical roundabouting.
