19.06.2015 Views

ADMIN

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Management<br />

Chef<br />

at the same time and get in each<br />

other’s way.<br />

Role-Out<br />

To group multiple cookbooks in a<br />

role, create a new file below Roles in<br />

the repository, say, beispiel.rb, with<br />

the following content:<br />

name "beispiel"<br />

description "Example of a role"<br />

run_list("recipe[emacs]", U<br />

"recipe[zsh]", "recipe[git]")<br />

This groups the emacs, zsh and git<br />

recipes under the beispiel role name.<br />

Then send the role to the server like<br />

this:<br />

Figure 2: The web front end login page: the default password specified on the right is incorrect.<br />

Changing the slightly cryptic default<br />

after logging in the first time is a good<br />

idea.<br />

Now go to the Nodes menu. When<br />

you get there, click the client name,<br />

change to the Edit tab, and finally<br />

drag the recipe you want to use from<br />

Available Recipes and drop it into<br />

the Run List (the recipe will slot into<br />

the top position in the list). In the<br />

example, you would now see emacs<br />

at the top [Figure 3]. To store this assignment,<br />

press the Save Node button<br />

bottom left on the page.<br />

Client-side now, manually launch the<br />

chef-client tool:<br />

sudo chef‐client<br />

This command line immediately<br />

opens a server connection, picks<br />

up the recipes assigned to the client<br />

(only emacs for the time being) and<br />

executes the recipes [Figure 5]. To allow<br />

this to happen on a regular basis,<br />

you should run the client at regular<br />

intervals as a daemon:<br />

chef‐client ‐i 3600 ‐s 600<br />

In this example, the client contacts<br />

the server every 3,600 seconds. The<br />

-s parameter lets you vary the period<br />

slightly. If you don’t set this, all of<br />

your clients might query the server<br />

rake roles<br />

In the web front end, you can assign<br />

roles to a node just like cookbooks<br />

using drag and drop.<br />

Freshly Stirred<br />

Ready-made recipes and cookbooks<br />

off the Internet will only cover standard<br />

application cases. For special<br />

cases, or individual configurations,<br />

you will typically need to create your<br />

own cookbook.<br />

The following, extremely simple<br />

example, creates a text file on the client<br />

called /​tmp/​thoughts.txt that is<br />

based on the quick_start cookbook<br />

[6], and it adds a sentence that is<br />

G Figure 4: The Status tab lists all the nodes with their last contact attempts<br />

and recipe assignments (following Run List).<br />

F Figure 3: Using drag and drop to assign recipes to a node. In this example, the<br />

client runs the beispiel recipe first, followed by emacs.<br />

72 Admin 01 www.admin-magazine.com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!