Facebook Twitter Gplus RSS
 
 
Home » CentOS 5.5 Tutorials » Installing Puppet Master with Foreman frontend on CentOS 5.5
formats

Installing Puppet Master with Foreman frontend on CentOS 5.5

Published on August 27th, 2010

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
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.

http://theforeman.org/

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

* foreman.how2centos.com (IP 10.0.0.100): 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 http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
# rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm

cat > /etc/yum.repos.d/foreman.repo << EOF
[foreman]
name=Foreman Repo
baseurl=http://yum.theforeman.org/stable
gpgcheck=0
enabled=1
EOF

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
[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
 
[puppetd]
    # 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
 
[puppetmasterd]
    storeconfigs = true
    dbadapter = mysql
    dbuser = puppet
    dbpassword = puppet
    dbserver = localhost
    dbsocket = /var/lib/mysql/mysql.sock
    rrddir=/var/lib/puppet/rrd
    rrdinterval=$runinterval
    rrdgraph=true
    reports=log, foreman

# vi /etc/sysconfig/puppet

1
2
3
4
5
6
7
8
9
10
11
# The puppetmaster server
PUPPET_SERVER=foreman.how2centos.com
 
# If you wish to specify the port to connect to do so here
#PUPPET_PORT=8140
 
# Where to log to. Specify syslog to send log messages to the system log.
PUPPET_LOG=/var/log/puppet/puppet.log
 
# You may specify other parameters to the puppet client here
#PUPPET_EXTRA_OPTS=--waitforcert=500

# mkdir /etc/puppet/manifests/classes/
# vi /etc/puppet/manifests/site.pp

1
2
3
4
5
import "classes/*"
 
node default {
    include sudo
 }

# vi /etc/puppet/manifests/classes/sudo.pp

1
2
3
4
5
6
7
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
Bye

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

1
2
3
4
5
6
7
production:
  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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# 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
$foreman_url="http://foreman.how2centos.com:3000"
 
require 'puppet'
require 'net/http'
require 'uri'
 
Puppet::Reports.register_report(:foreman) do
    Puppet.settings.use(:reporting)
    desc "Sends reports directly to Foreman"
 
    def process
      begin
        uri = URI.parse($foreman_url)
        http = Net::HTTP.new(uri.host, uri.port)
        if uri.scheme == 'https' then
          http.use_ssl = true
          http.verify_mode = OpenSSL::SSL::VERIFY_NONE
        end
        req = Net::HTTP::Post.new("/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}"
      end
    end
end

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 http://foreman.how2centos.com:3000

 
  • Ohadlevy

    There is also a puppet module for managing Foreman which does most of the heavy lifting for you.
    you don’t need to have a running puppet master to use it, as it uses the puppet executable.
    see http://github.com/ohadlevy/puppet-foreman

    it would also install passenger on CentOS 5.5 if you enable it in the manifest.
    Ohad

  • Anonymous

    Thanks Ohad!

    For those of you that grock Puppet please follow the link Ohad posted this will definitely do most of the heavy lifting.

  • Scoday

    For anyone that may have checked foreman out of git and is chasing their tails my foreman.rb was actually named foreman-report.rb, puppet will not accept reports unless you either rename the file to foreman.rb or in the reports line of puppet put reports = log,foreman-report… etc..

  • Austin

    I am receiving an error following your guide. When I try to RAILS_ENV=production rake db:migrate , I receive : rake aborted!
    can’t convert Fixnum into String

    has anyone else seen this problem?

  • Anonymous

    So far nobody else has had the same problem.

    The only suggestion I can make is to double check that you’re in the /usr/share/foreman/ folder before running the command?

  • Ohad

    try running it with –trace, this should give you more information,
    maybe worth creating a new bug at http://theforeman.org

  • MBP

    Try typing

    gem install rack -v=1.0.1

    This worked for me. If you use –trace you’ll see the version it’s complaining about. In my case I had 1.1.0 and it wanted 1.0.1

  • Ohadlevy

    Note that the repo used here is very old, check latest installation instructions first at theforeman.org/projects/foreman/wiki/Installation_instructions

  • Anonymous

    Thanks Ohadlevy – I have updated the repo and will run through an installation tonight to confirm it all works.

  • http://twitter.com/aricg aricg

    for /usr/lib/ruby/site_ruby/1.8/puppet/reports/foreman.rb
    add require ‘net/https’  if you want ssl to work.

  • http://twitter.com/aricg aricg

    actually /usr/lib/ruby/site_ruby/1.8/puppet/reports/foreman.rb is out of date, broken in ipv6, modify the one distributed with foreman.

© [How2CentOS]
credit