CentOS 5.5 Tutorials

Installing Puppet Master with Foreman frontend on CentOS 5.5

In this CentOS 5.5 tutorial we will be installing Foreman on a CentOS 5.5 i386 server including Puppet Master and Puppet client. The assumption is that you have a basic to medium understanding of the software required but if you follow this tutorial you should be able to complete the task successfully.

A bit on the software that we’ll be using:

Foreman is aimed to be a Single Address For All Machines Life Cycle Management.

Foreman integrates with Puppet (and acts as web front end to it).

Foreman takes care of bare bone provisioning until the point puppet is running, allowing Puppet to do what it does best.

Foreman shows you Systems Inventory (based on Facter) and provides real time information about hosts status based on Puppet reports.

Foreman creates everything you need when adding a new machine to your network. It’s goal being automatically managing everything you would normally manage manually – that would eventually include DNS, DHCP, TFTP, PuppetCA, CMDB and everything else you might consider useful.

With Foreman You Can Always Rebuild Your Machines From Scratch!

Foreman is designed to work in a large enterprise, where multiple domains, subnets and puppetmasters are required.

Preliminary Note:
I am using a CentOS 5.5 i386 base installation in this tutorial with root access.

* (IP CentOS 5.5 i386 base installation

Lets begin by adding additional CentOS 5.5. repositories and installing the framework required by Foreman.

# yum install yum-priorities
# rpm -Uhv
# rpm -Uvh
cat > /etc/yum.repos.d/foreman.repo << EOF
name=Foreman Repo

Lets begin installing the framework starting with Puppet Master, client and MySQL

# yum install puppet-server puppet
# yum install mysql mysql-server mysql-devel ruby-mysql rubygem-activerecord

Let do a basic Puppet Master and client configuration.

# vi /etc/puppet/puppet.conf
    # 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

    # 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

	# Enable reporting for Foreman
	report = true
    storeconfigs = true
    dbadapter = mysql
    dbuser = puppet
    dbpassword = puppet
    dbserver = localhost
    dbsocket = /var/lib/mysql/mysql.sock
    reports=log, foreman
# vi /etc/sysconfig/puppet
# The puppetmaster server

# If you wish to specify the port to connect to do so here

# Where to log to. Specify syslog to send log messages to the system log.

# You may specify other parameters to the puppet client here
# mkdir /etc/puppet/manifests/classes/
# vi /etc/puppet/manifests/site.pp
import "classes/*"

node default {
    include sudo
# vi /etc/puppet/manifests/classes/sudo.pp
class sudo {
    file { "/etc/sudoers":
        owner => "root",
        group => "root",
        mode  => 440,

Start MySQL and add it to startup

# service mysqld start
# chkconfig mysqld on

Add the Puppet Database

# mysql
mysql> create database puppet;
mysql> grant all privileges on puppet.* to puppet@localhost identified by 'puppet';
mysql> exit

Install Foreman and configure the Database and enable reporting.

# yum install foreman

Foreman uses a database, by default, SQLite is used, if you want to use other database (e.g. MySQL) please modify the configuration file under config/database.yml.

# mv  /etc/foreman/database.yml /etc/foreman/database.yml.old
# vi /etc/foreman/database.yml
  adapter: mysql
  database: puppet
  username: puppet
  password: puppet
  host: localhost
  socket: "/var/lib/mysql/mysql.sock"

To enable reporting in Foreman you'll be required to copy foreman-report.rb to your report directory, edit the $foreman_url=, and then add it to your master puppet.conf under the main section add:

# cp /usr/share/foreman/extras/puppet/foreman/files/foreman-report.rb /usr/lib/ruby/site_ruby/1.8/puppet/reports/foreman.rb 
# vi /usr/lib/ruby/site_ruby/1.8/puppet/reports/foreman.rb
# copy this file to your report dir - e.g. /usr/lib/ruby/1.8/puppet/reports/
# add this report in your puppetmaster reports - e.g, in your puppet.conf add:
# reports=log, foreman # (or any other reports you want)

# URL of your Foreman installation

require 'puppet'
require 'net/http'
require 'uri'

Puppet::Reports.register_report(:foreman) do
    desc "Sends reports directly to Foreman"

    def process
        uri = URI.parse($foreman_url)
        http =, uri.port)
        if uri.scheme == 'https' then
          http.use_ssl = true
          http.verify_mode = OpenSSL::SSL::VERIFY_NONE
        req ="/reports/create?format=yml")
        req.set_form_data({'report' => to_yaml})
        response = http.request(req)
      rescue Exception => e
        raise Puppet::Error, "Could not send report to Foreman at #{$foreman_url}/reports/create?format=yml: #{e}"

Finally to initialize the database schema type:

# cd /usr/share/foreman/
# RAILS_ENV=production rake db:migrate

Let start, and add to startup, the various componants and browse to your newly installed Puppet Master and client with Foreman frontend.

# service puppetmaster start
# service puppet start
# service foreman start
# chkconfig puppetmaster on
# chkconfig puppet on 
# chkconfig foreman on

Point your bowser to

By George

Technical Samurai specializing in open source IT Automation and Cloud Infrastructure.