Online Book Reader

Home Category

Pulling Strings With Puppet - James Turnbull [29]

By Root 370 0
filebucket (called the clientbucket) on the local client and automatically backs up all files there. The filebucket resource is used to create a server-based version of this backup facility.

Defining a filebucket is easy as you can see on the following line:

The filebucket is created on the Puppet master server you specify with the server attribute.

Tip - You can also create local filebuckets on clients by using the path attribute instead of the server attribute.

You can then refer to the created filebucket in resource types that support file backups, usually using the backup attribute. For example, you could specify a resource default that uses this filebucket to ensure all file resources use the filebucket to back up files:

You can see we've specified the capitalized file resource type to indicate this is a default and then the backup attribute. The backup attribute takes the name of a filebucket as a value. From now on, when a file is changed on a client, a backup will be saved to the main filebucket located on the Puppet master server.

Managing Host Files

The host resource manages the contents of host files on your nodes, usually /etc/hosts, but the type also supports adding host entries on OS X using Netlnfo. You can see the host type in Listing 3-23.

The type has a number of attributes, and we've shown some of them in Listing 3-23. The ensure attribute specifies whether the host entry should be added or deleted. The setting of present has Puppet add the host entry. A setting of absent would remove the entry. You can then specify the IP address using the ip attribute; you can specify either IPv4 or IPv6 addresses here. Last, we have the alias attribute, which allows you to list all the potential host aliases for the entry. Multiple entries must be specified with an array as shown in Listing 3-23. So this host resource would create a line in your hosts file like so:

Managing SSH Host Keys

The sshkey resource type manages SSH host keys. The current resource type can be used to install keys in the known hosts file for your SSH server, /etc/ssh/ssh_known_ hosts. You can see an sshkey resource type in Listing 3-24.

In Listing 3-24, we've used the sshkey resource together with two facts. We specified the title of the resource as the $hostname fact and the value of the key as the $sshdsakey fact. So what will Listing 3-23's resource do? For every node it is implemented on, it will place that node's DSA host key in the /etc/ssh/ssh_known_hosts file. We could also pass in a list of known host keys (using either DSA or RSA keys) or use the ensure attribute to indicate whether the key should be present or absent.

Tidy Unwanted Files

The tidy resource type is used to remove unwanted files based on certain criteria. You can specify criteria like the size or age of a file. In Listing 3-25, you can see a tidy resource.

Listing 3-25 shows a tidy resource that will tidy (delete) the file /tmp/dboutput. sql if it is older than 15 minutes. We've given the resource the symbolic name of outputs and specified the precise file to be deleted using the path attribute. This is tidy's equivalent of using the name attribute.

The age is specified using the age attribute that can measure age in terms of seconds, minutes, hours, days, and weeks. The age is specified with a number and the first letter of the time period, for example, is for one second and 2d for two days. By default, the tidy resource uses atime, access time, to determine the age of a file, but you can override this to use ctime or mtime by specifying the type attribute like so:

In Listing 3-25, we have also used a new metaparameter, before. The before metaparameter is the opposite of the require metaparameter. The require metaparameter enforces dependency-another resource must be actioned prior to the current resource being actioned. The before metaparameter ensures that the current resource is actioned before the specified resource. In Listing 3-25, the outputs resource would have to be actioned before the Service[mysql] resource.

With the tidy

Return Main Page Previous Page Next Page

®Online Book Reader