Puppeteering with Puppet

So I’ve been a very naughty sysadmin recently, one of the things I intended to do early on in my new employment was setup some form of System Management as we have several Linux hosts. However truth be told I have never had a System Management system for Linux hosts (due to a lack of time to implement one) and due to a number of tight deadlines I’ve had to put this on the back burner and spin up servers for additional roles.

This road however will lead to ruin so I have put a stop to the random spinning up of hosts for anything other than testing until I get something in place to mange all the configurations centrally. The question for me was what to use, I’ve heard of both Puppet and Chef, but I have no experience of them. So after doing a bit of reading I figured I’d go with Puppet as it seems to have most of the bases I am interested in covered.

Installing puppet 


Install puppet master (RHEL):
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh http://yum.puppetlabs.com/el/6/products/i386/puppetlabs-release-6-6.noarch.rpm
yum -y update
yum -y install puppet puppet-server facter

Install puppet agent: (RHEL)
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh http://yum.puppetlabs.com/el/6/products/i386/puppetlabs-release-6-6.noarch.rpm
yum -y update
yum -y install puppet facter

Install puppet agent: (Debian)
apt-get update
apt-get install ruby libshadow-ruby1.8 puppet factor

Install puppet agent: (SLES 11 SP2) (puppet 2.6.12 already installed)
zypper ar http://download.opensuse.org/repositories/systemsmanagement:/puppet/SLE_11_SP2/systemsmanagement:puppet.repo
zypper --non-interactive --gpg-auto-import-keys up
zypper --non-interactive install facter-1.6.17-1.4.x86_64

A template GOTCHA

So far I am reasonably impressed with it (I’ve yet to dig into the reporting, but I can worry about that after I have some good basic configs). One issue I did have was when I was creating a template for resolv.conf, the following code caused a resolv.conf to be generated with a single space at the start of “nameserver” line IF there were multiple nameservers (I.E. we entered the loop), this broke name resolution.

# Generated on Puppet Server
<% if search != '' -%>
search <%= search %>
<% end -%>
<% if dnsservers.is_a? Array -%>
 <% dnsservers.each do |dnsserver| -%>
nameserver <%= "#{dnsserver}" %>
 <% end -%>
<% elsif dnsservers != '' -%>
nameserver <%= "#{dnsservers}" %>
<% end -%>

The fix that was suggested by a helpful person on the #puppet IRC channel was to add “trim left” (<%-) to lines 6 and 8, so the template became:

# Generated on Puppet Server
<% if search != '' -%>
search <%= search %>
<% end -%>
<% if dnsservers.is_a? Array -%>
 <%- dnsservers.each do |dnsserver| -%>
nameserver <%= "#{dnsserver}" %>
 <%- end -%>
<% elsif dnsservers != '' -%>
nameserver <%= "#{dnsservers}" %>
<% end -%>

That’s it for now but this will tie back to the video network series as well ;) and as I come across more “gotchas” in puppet I’ll post them and the resolutions

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This blog is kept spam free by WP-SpamFree.