How to install Puppet 3 on CentOS / RHEL 6 with Unicorn & Nginx for maximum efficiency. You can read more about why Unicorn is great because it’s Unix, in short it’s a much better option than Webrick (very slow) and no more work to setup than Mongrel (in my opinion). In this tutorial I couple Unicorn with Nginx for optimial puppet master performance per dollar spent.
Installing Puppet Labs RPM for CentOS 6
I use the Puppet Labs repo, you might want to use the EPEL Repo however this will install an older version of puppet and I am rolling out Puppet 3 for my servers.
Dependencies Resolved====================================================================================================================================================== Package Arch Version Repository Size======================================================================================================================================================Installing:
puppet-server noarch 3.0.1-1.el6 puppetlabs-products 22 k
Installing for dependencies:
augeas-libs x86_64 0.9.0-4.el6 base 317 k
compat-readline5 x86_64 5.2-17.1.el6 base 130 k
dmidecode x86_64 1:2.11-2.el6 base 71 k
facter x86_64 1:1.6.14-1.el6 puppetlabs-products 58 k
hiera noarch 1.1.1-1.el6 puppetlabs-products 19 k
libselinux-ruby x86_64 2.0.94-5.3.el6 base 99 k
pciutils x86_64 3.1.4-11.el6 base 83 k
puppet noarch 3.0.1-1.el6 puppetlabs-products 890 k
ruby x86_64 1.8.7.352-7.el6_2 base 532 k
ruby-augeas x86_64 0.4.1-1.el6 puppetlabs-deps 21 k
ruby-irb x86_64 1.8.7.352-7.el6_2 base 311 k
ruby-libs x86_64 1.8.7.352-7.el6_2 base 1.6 M
ruby-rdoc x86_64 1.8.7.352-7.el6_2 base 375 k
ruby-shadow x86_64 1.4.1-13.el6 puppetlabs-deps 11 k
rubygem-json x86_64 1.4.6-1.el6 puppetlabs-deps 457 k
rubygems noarch 1.3.7-1.el6 base 206 k
Transaction Summary======================================================================================================================================================Install 17 Package(s)Total download size: 5.2 M
Installed size: 16 M
Is this ok [y/N]:
Install the key when prompted:
1234567
warning: rpmts_HdrFromFdno: Header V4 RSA/SHA1 Signature, key ID 4bd6ec30: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-puppetlabs
Importing GPG key 0x4BD6EC30:
Userid : Puppet Labs Release Key (Puppet Labs Release Key) <[email protected]>
Package: puppetlabs-release-6-6.noarch (installed) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-puppetlabs
Is this ok [y/N]:
At this point open up /etc/puppet/puppet.conf (if it’s not there copy it from: /usr/share/puppet/ext/redhat/puppet.conf ) and add your server name, note this needs to be a FQDN or /etc/hosts hack like I have done in this lab.
Here is an example of my puppet.conf
puppet.conf
123456789101112131415161718192021222324252627
[main]# The Puppet log directory.# The default value is '$vardir/log'.logdir= /var/log/puppet
# Where Puppet PID files are kept.# The default value is '$vardir/run'.rundir= /var/run/puppet
# Where SSL certificates are kept.# The default value is '$confdir/ssl'.ssldir=$vardir/ssl
server= puppet.cloud.local
[agent]# The file in which puppetd stores a list of the classes# associated with the retrieved configuratiion. Can be loaded in# the separate ``puppet`` executable using the ``--loadclasses``# option.# The default value is '$confdir/classes.txt'.classfile=$vardir/classes.txt
# Where puppetd caches the local configuration. An# extension indicating the cache format is added automatically.# The default value is '$confdir/localconfig'.localconfig=$vardir/localconfig
Install Unicorn for the Pupper Master
unicorn is a HTTP server for Rack apps that utilizes features in Unix / Linux Kernels and in short is far more efficient than Mongrel / WEBrick, you can probably get away with using the Puppet default for now but why do half a job and implement something that is not going to scale?
In order for gem to build Unicorn, Rack & it’s deps you need to install some build tools using YUM:
You can now stop, start, restart the puppet master’s unicorn service with:
1
/etc/init.d/puppets-unicorn start
Confirm unicorn is running:
1
ps aux | grep unicorn
Install Nginx for Puppetmaster Unicorn
If you don’t have it installed follow my CentOS Nginx install instructions, then drop the following config file in /etc/nginx/conf.d/ and call it puppets-unicorn:
You will need to change the cert file names to match your FQDN.
Make sure the puppet unicorn service is running and start nginx:
1
/etc/init.d/nginx start
Install Puppet client (Agent)
Next on a client (puppet Agent) machine install the Puppet Labs YUM repo and enter the following command to install the puppet client:
1
yum install puppet
Configure the puppets to talk to the server
Make sure you can ping the puppetmaster & vice verse (if it’s not working the most likely cause is iptables), open up /etc/puppet/puppet.conf and add server = puppet.your.com to the [agent] section.
Here is an example of my puppet.conf:
puppet.conf
1234567891011121314151617181920212223242526
[main]# The Puppet log directory.# The default value is '$vardir/log'.logdir= /var/log/puppet
# Where Puppet PID files are kept.# The default value is '$vardir/run'.rundir= /var/run/puppet
# Where SSL certificates are kept.# The default value is '$confdir/ssl'.ssldir=$vardir/ssl
[agent]# The file in which puppetd stores a list of the classes# associated with the retrieved configuratiion. Can be loaded in# the separate ``puppet`` executable using the ``--loadclasses``# option.# The default value is '$confdir/classes.txt'.classfile=$vardir/classes.txt
# Where puppetd caches the local configuration. An# extension indicating the cache format is added automatically.# The default value is '$confdir/localconfig'.localconfig=$vardir/localconfig
server= puppet.cloud.local
Sign the Puppet Agents Certificate
From the Agent (the client not the server) run:
Start / Restart puppet agent:
1
/etc/init.d/puppet restart
Say Hello to the puppet master (this sends the agent cert to the puppet master):
Signed certificate request for agent.cloud.local
Removing file Puppet::SSL::CertificateRequest agent.cloud.local at '/var/lib/puppet/ssl/ca/requests/agent.cloud.local.pem'
Test the Puppet Agent is working with the Puppet Master
To test the Puppet Agent can pull down the Puppet Masters catalog enter:
1
puppet agent --test
This should give you an output similar to:
12345678
[root@agent puppet]# puppet agent --test Info: Caching certificate for agent.cloud.local
Info: Caching certificate_revocation_list for ca
Info: Retrieving plugin
Info: Caching catalog for agent.cloud.local
Info: Applying configuration version '1354510955'Info: Creating state file /var/lib/puppet/state/state.yaml
Finished catalog run in 0.05 seconds
To test this futher create some manifests and confirm they deploy to your puppet agents correctly.
Enjoy your highly efficient Puppet 3 server running Unicorn & Nginx!