Puppet is a configuration management tool written in Ruby. It works across multiple Unix systems and Linux distributions.
Puppet can be found here. A small summary of features is listed here.
Puppet is a declarative language for expressing system configuration, a client and server for distributing it, and a library for realizing the configuration. Rather than approaching server management by automating current techniques, Puppet reframes the problem by providing a language to express the relationships between servers, the services they provide, and the primitive objects that compose those services. Rather than handling the detail of how to achieve a certain configuration or provide a given service, Puppet users can simply express their desired configuration using the abstractions they're used to handling, like service and node, and Puppet is responsible for either achieving the configuration or providing the user enough information to fix any encountered problems.
While it is easiest to test Puppet by running both client and server on the same host, in the more general case, we will be running it on multiple hosts, with a central server and multiple clients. The rest of the documentation assumes that you have two systems (even if one is in a virtual machine) available to test and try out puppet.
To start with, we will look at deploying a hosts file on our client node.import "classes/*"Create a basic configuration for the client.
# This class is a standard entry in all hosts.
class host-standard {
host { "local":
name => "localhost",
alias => "localhost.localdomain",
ip => "127.0.0.1",
ensure => present,
}
}
Create a default manifest for your client in site.pp
node puppet-client {
include host-standard
}
Start the puppetmasterd process on puppetmaster:You will have to use a valid DNS name or IP addresses instead of puppetmaster.
Puppet uses SSL for bidirectional authentication and authorization.Ensure that the clocks on both systems are synchronised and correct. On the client, you should see a message about not receiving a certificate.notice: Starting Puppet client version 0.22.2 info: Facts have changed; recompiling info: Caching configuration at /var/lib/puppet/localconfig.yaml info: /Host[local]: Adding aliases "localhost.localdomain" notice: Starting configuration run notice: Finished configuration run in 0.02 secondsThis completes a basic Puppet installation. Now, we will add puppet-client specific hosts entries to the /etc/hosts file. Edit hosts.pp on puppetmaster and add:
class puppet-client-host {
host { "puppet-client":
name => "puppet-client",
alias => "puppet-client.internal.example.com",
ip => "192.0.20.1",
ensure => present,
}
host { "postfix":
name => "postfix",
alias => "postfix.example.com",
ip => "203.199.107.58",
ensure => present,
}
host { "postfix-us":
name => "postfix-us",
alias => "postfix-us.example.com",
ip => "67.15.238.68",
ensure => present,
}
host { "postfix-us2":
name => "postfix-us2",
alias => "postfix-us2.example.com",
ip => "67.15.253.249",
ensure => present,
}
}
Edit site.pp on puppetmaster
node puppet-client {
include host-standard
include puppet-client-host
}
Run puppetd on puppet-client
puppetd --verbose --server puppetmaster
class apache-2 {
package { "httpd":
ensure => "latest",
}
}
It is possible to put each class in it's own file, or group them all into one file. A mixture of the two is also feasible.
In site.pp
host puppet-client {
include apache-2
}
[etc]
path /etc/puppet/manifests/files
allow 192.168.0.0/24
Puppet's fileserver.conf is modelled after the rsync configuration file. The label etc is how the puppetmasterd identifies the location of the actual file on disk.
Puppet accesses remote files via the puppet:// scheme.
class standard-syslog {
file { "/etc/syslog.conf":
source => "puppet://puppetmaster/etc/syslog.conf",
owner => "root",
group => "root",
mode => "644",
}
}
In site.pp
host puppet-client {
include standard-syslog
}
When puppetd runs on the client, the syslog.conf file will be transferred.
class localusers {
user { "f3ew":
ensure => "present",
comment => "test user",
}
user { "dvb":
ensure => "present",
comment => "test user",
home => "/home/dvb",
}
}
See here for options on parameters to the users class.
In site.pp:
host puppet-client {
include localusers
}
#puppetd --test --noop notice: Ignoring --listen on onetime run notice: Ignoring cache info: Caching configuration at /var/lib/puppet/localconfig.yaml info: /Host[local]: Adding aliases "localhost.localdomain" info: /Host[puppet-client]: Adding aliases "puppet-client.internal.example.com" info: /Host[postfix]: Adding aliases "postfix.example.com" info: /Host[postfix-us]: Adding aliases "postfix-us.example.com" info: /Host[postfix-us2]: Adding aliases "postfix-us2.example.com" notice: Starting configuration run notice: //puppet-client/localusers/User[f3ew]/ensure: is absent, should be present (noop) notice: //puppet-client/apache-2/Package[httpd]/ensure: is 2.0.52-28.ent.centos4, should be 2.0.52-32.3.ent.centos (noop) notice: Finished configuration run in 11.65 secondsinm