Exploring Puppet

Reference: http://reductivelabs.com/trac/puppet/

Prerequisites:

  • The only prerequisite not included with Ruby installation is facter.
  • Other prerequisites are Ruby libraries that come with most Ruby installations. Use the Ruby that comes with your system.

Installing on SuSE:

Articles about Puppet:

http://www.computerworld.com.au/index.php/id;224515074;pp;2 http://www.socallinuxexpo.org/scale6x/presentations/Luke_Kanies.pdf

Puppet server runs on port 8140. Communication with the client is secured with a self-signed certificate.

EXPLORING PUPPET for our VMs: I installed Ruby, Facter, Puppet and Puppetmaster on my laptop and installed Ruby, Facter, and Puppet on a VM. I am using the laptop as Puppet master server and the vm will be the client.

The Puppet web site has a lot of good documentation on the installation and use of Puppet. There is a language tutorial which is full of examples to get started writing manifests. I am currently trying out some of the functions and observing their effects on the client VM and on the server (and the client on the server machine).

Rough Notes on Puppet exploration:

I have been able to use the language tutorial to accomplish some simple tasks. I will not duplicate the code for the recipes here, but in essence I have so far been able to:

  • Use conditionals based on host name to create a user and a group and assign the user to the group.
  • Make a function work. The simplest of these is notice, which prints a message to the server console.
  • Create a new file in a designated location with designated content.
  • Create a new folder and new files in the folder, each with designated permissions.
  • Install a package and its dependencies using yum.

A recipe I tried in the Puppet Recipes section is still not working completely for me. It is the one for MySQLServer Install and Set Password. As of now, I can use the recipe to install MySQL, but it does not set the root password. The root MySQL user can log into MySQL with no password. This may be a difference in how SuSE handles a new MySQL installation, but I am going to try to find out how to set that password using Puppet so that we don't have to do it manually on each VM.

Meanwhile, here is what I have so far for my config for installing software using Puppet:

  • According to the SuSE pages in the Puppet Wiki, the only package providers for SuSE are rpm, yum and rug. As of version 0.22.4 rug is default provider for SuSE.
  • I used yum, installing it like this:
yast -i yum
  • The yumrepo information is in my site.pp, displayed below.
  • I am now able to use Puppet to install software using yum. This is what my site.pp looks like, assuming I want to always install ant-antlr.noarch and koffice-database on node caGrid (I chose these packages because they will show that yum also installs the dependencies). I had been getting an error about yum not being able to find dependencies, but it was a problem with my respositories. I corrected those and now can install dependencies automatically with yum.
# /etc/puppet/manifests/site.pp
import "classes/*"
case $operatingsystem {
  suse: {Package{ provider => yum }}
}
Yumrepo {gpgcheck=>1, enabled=>1}

yumrepo {

  "SL-10.3":
     descr=>"openSuSE Linux 10.3",
     baseurl=>"http://download.opensuse.org/distribution/10.3/repo/oss/suse/";
   "SL-10.3-update":
     descr=>"openSuSE Linux 10.3 updates",
     baseurl=>"http://download.opensuse.org/update/10.3/";
        }

node "caGrid" {
  include ourtestapps
}

In the 'classes' subdirectory of manifests, the ourtestapps.pp class looks like this:

# /etc/puppet/manifests/classes/ourtestapps.pp

class ourtestapps {
  package { "ant-antlr-1.7.0-37.noarch":
                       ensure   => present,
                       provider => yum
          }

  package { "koffice-database":
                       ensure   => present,
                       provider => yum
          }

}

At this point all I had to do was

puppetd --test

on the client, and it created the packages and installed (including ant and koffice, which were prerequisites) on the caGrid node.

Package providers for Puppet

Here are links and comments comparing Yum and Yast.

http://www.osnews.com/comments/12264[[BR]]

Article discussing yum on SuSE

Later article re yum, yast, zypper, rug on SuSE

This is a good article with many details about each of yast, rug, zypper, yum. I will not reproduce the whole article, but here are some important, but maybe easily overlooked facts I copied straight from the article:

  • Interesting in this case is that zmd (rug) and Yast are kept synchronised: if you add a repository in Yast it will appear in zmd and vice versa. That is not the case with all methods introduced here!
  • zypper is yet another easy to use command line application to manage software - it can also be synchronised with zmd (and therefore with Yast) - but it does not require it. So if you don't like zmd you can savely use zypper. zypper will warn us that it will not synchronise with Yast or zmd, but you can check in rug or Yast that it indeed has been synchronized. I’m not sure what this warning is about…
  • Important to know is in this case that yum is not synchronized at all - if you use and configure yum nothing of this configuration appears in Yast or zmd or zypper or anywhere else.

How to push a new config to Puppet client: Puppet client connects to the server every 30 minutes by default to look for a new config and pull it down. Puppetrun can be run on the server to force this to happen. I am trying to get this to work right now but it is giving me an error (Timeout::Error) message. This bug describes what happens to me whether or not I use the '--foreground' option. I am looking for configuration settings that are necessary before puppetrun can work. I am starting puppetd with --listen and have placed a namespaceauth.conf file in place although I will be checking the contents and location of this file against Puppet recommendations. I downloaded the latest puppetrun file and am still getting the timeout, so I must have something

Ralsh reference - Usage

ralsh [-h|--help] [-d|--debug] [-v|--verbose] [-e|--edit] [-H|--host <host>]
    [-p|--param <param>] [-t|--types] type <name>

Description This command provides simple facilities for converting current system state into Puppet code, along with some ability to use Puppet to affect the current state.

By default, you must at least provide a type to list, which case ralsh will tell you everything it knows about all instances of that type. You can optionally specify an instance name, and ralsh will only describe that single instance.

You can also add --edit as an argument, and ralsh will write its output to a file, open that file in an editor, and then apply the file as a Puppet transaction. You can easily use this to use Puppet to make simple changes to a system.