Online Book Reader

Home Category

Pulling Strings With Puppet - James Turnbull [28]

By Root 373 0
variable that is prefixed with FACTER is a fact that can be used by Puppet. So to set up one of these facts, we would simply configure an environmental variable as you can see in Listing 3-21.

Listing 3-21. Setting an Environmental Variable Fact

In a Puppet manifest, we could then refer to the value of this environmental value using a variable just like any other Facter fact. In this case, the $statevar variable would contain a value of primary.

So what happens when the value of a fact changes'? Puppet doesn't ignore this. As we described in Chapter 2, by default the client wakes up every 30 minutes and checks the currency of its configuration. When this check occurs, it does two things:

• Checks that no facts have changed on the node

• Checks that the modification time on the server-side configuration is earlier than the compilation time

If facts have changed, or the configuration on the master has been edited after the last compilation time, the client requests that the server recompile and redeliver the configuration. The client then reimplements and applies the updated configuration locally.

This check for fact changes does not apply to all facts though. Some facts are dynamic, such as memory and swap sizes, and the fact change check ignores these rather than initiating a recompile. By default, the following facts are ignored by the Puppet client:

• memorysize

• memoryfree

• swapsize

• swapfree

The list of facts to be ignored is controlled from the Puppet configuration file in the [puppetd] namespace and through the dynamicfacts configuration option.

You can add further facts to be ignored by separating each fact with a comma.

Tip In Chapter 7, you'll see how to enhance Facter by adding your own facts for Puppet to use.

Resource Types

In this chapter, we've seen a few examples of the various resource types that can be used to manage resources on our nodes. We saw the file type resource that can manage files and directories, the service type that manages services and daemons, the group type that manages groups, and the package type that provides package management for our nodes. But these are not the only resource types available to us. There is a rich collection of resource types that we can make use of to configure resources on our nodes. It is also a collection that is growing rapidly as the developers and members of the community contribute new types. You can see the full list of resource types, their attributes, and examples of their functionality at http://reductivelabs.com/trac/puppet/wiki/ TypeReference.

Note -* In Chapter 7, I'll also discuss how you can use Ruby to create your own resource types and further enhance Puppet.

In Table 3-2, you can see a full list of the current resource types available at the time of writing.

(Continued)

Let's look at a selection of the resource types in Table 3-2 and how to make use of them.

Managing Cron Jobs

The first item in the table is the cron resource type that manages cron jobs on your nodes. You can see a cron resource in Listing 3-22.

The cron resource type is very simple. The command attribute specifies the function, command, or binary that the cron job will execute. The user attribute specifies the user to run the cron job as, and the resource also supports the standard minutes, hours, days, months attributes that cron jobs use for scheduling.

Using a Filebucket

The filebucket type provides a repository for file backups. At this stage, the filebucket type allows you to specify a local or network repository to hold file backups for other resource types, principally the file resource type.

Files are backed up to the filebucket when they are changed on a client. Each change is assigned an MD5 checksum. This checksum can be used to later retrieve and restore files. At the moment, this is a manual restore process, but future plans are to automate this process so that the filebucket can aid in the transaction rollback process. Most sites define a single filebucket as their default backup location.

Note - Puppet creates a local

Return Main Page Previous Page Next Page

®Online Book Reader