Pro Puppet (40 page)

Read Pro Puppet Online

Authors: Jeffrey McCune James Turnbull

BOOK: Pro Puppet
4.88Mb size Format: txt, pdf, ePub

Tip
You can see more detail on this process in
Chapter 5
.

Logging, Database Backup and Performance

With the Dashboard there are also a few simple management and maintenance tasks you need to know about.

First, like all Rails applications, Puppet Dashboard logs information and errors produced to logs contained in the
/usr/share/puppet-dashboard/logs
directory. These logs are useful to find diagnostic and informational data about the running of the Dashboard. Each Rails environment, production, development, etc., produces a separate log file named for the environment being logged. For example, check the
production.log
file for log data for your Rails production instance, or check
development.log
for development instance data.

These log files can accumulate and grow in size, and you should be sure sure to regularly prune them. The Dashboard comes with a Rake task to do this for you that you can manually schedule (or better yet, configure Puppet to run it as a cron job for you). To use the Rake task, change into the root of the Rails application, usually
/usr/share/puppet-dashboard
, and run:

$ sudo rake log:clear

Tip
You can also use
logrotate,
or a similar tool, to prune log files as part of your regular log management.

Second, like most database-driven applications, performance of the Puppet Dashboard can sometimes be improved by running optimization techniques over its MySQL database. Again, the Dashboard contains a Rake task that can perform this optimization for you. From the root of the application, run:

$ sudo rake RAILS_ENV=production db:raw:optimize

Third, you should back up your Dashboard's database. The best way to do this is to use the appropriate database backup tool used in your environment. If you don't have a tool, then you can use another in-built Rake task to create a dump of the database, which you can then back up:

$ sudo rake RAILS_ENV=production db:raw:dump

This will create a SQL dump of the Dashboard database in a file called
production.sql
in the current directory. You can override this file name an location using the following command line:

$ sudo rake RAILS_ENV=production FILE=/path/to/backup/file.sql db:raw:dump

Conveniently, there is also a Rake task to restore the database:

$ sudo rake RAILS_ENV=production FILE=production.sql db:raw:restore

Note
Lots of Rake tasks? You can see a full list of the available tasks by running
rake –T
in the root directory of the Dashboard application.

Lastly, you can purge older reports from your Dashboard database using another Rake task, reports:prune. For example, to prune reports 3 months old or older, you would use:

  $ sudo rake RAILS_ENV=production reports:prune upto=3 unit=mon

You can run the
rake reports:prune
task without any options to get a full list of the task's options.

Note
The Dashboard is a relatively new product – it's growing and changing all the time. Keep an eye on new releases for new features and capabilities.

The Foreman

The other entry in the Puppet GUI ecosystem is The Foreman, or simply Foreman (
http://theforeman.org/
). Foreman is an integrated data center lifecycle management tool that provides provisioning, configuration management and reporting. Like Puppet Dashboard, Foreman is a Ruby on Rails application.

Foreman, unlike the Dashboard, has much more of a focus on provisioning and managing data center capabilities, for example integration with bootstrapping tools, PXE boot servers, DHCP servers and provisioning tools.

Here, we focus on getting started with Foreman so you learn how to:

  • Install Foreman
  • Configuring Foreman
  • Integrate Foreman with Puppet
Installing Foreman

Installing Foreman requires some prerequisites. First, you need to install Puppet, a version later than 0.24.4. You can see how to do this in
Chapter 1
of the book. You also need to install some additional packages. On Red Hat and related distributions, you need to install the following packages:

$ sudo yum install rubygems rubygem-rake rubygem-rack rubygem-sqlite3-ruby

Alternatively, on Ubuntu and Debian-based hosts, you will need:

$ sudo apt-get install rubygems rake librack-ruby libsqlite3-ruby

Both of these package installations might also prompt you to install additional dependencies, depending on your distribution and its version.

Once you have the required prerequisites, you can install Foreman itself. Levy has packaged Foreman for both RPM- and DEB-based distributions.

Installing Foreman via RPM

The easiest way to install Foreman via RPM is to add the Foreman Yum repository to your environment. To do this, create a Yum repository entry for the Foreman repository, in
/etc/yum.repos.d/foreman.repo
:

[foreman]
name=Foreman Repo
baseurl=http://yum.theforeman.org/stable
gpgcheck=0
enabled=1

Then run:

$ sudo yum install foreman

You will also need to have the EPEL repository enabled, which you can see from the instructions specified in
Chapter 1
or via
http://fedoraproject.org/wiki/EPEL/FAQ#howtouse
. Foreman will load several additional packages from the EPEL repository.

Note
You can also install Foreman from source if you wish, though we recommend for manageability that you stick with packages. You can find the Foreman source at git://github.com/ohadlevy/foreman.git, or grab a daily snapshot of the Foreman development code at
http://theforeman.org/foreman-nightly.tar.bz2
.

Installing via DEB

Foreman is also available as an Ubuntu/Debian package. To make use of the current packages, add the following line to your
/etc/apt/sources.list
file:

deb http://deb.theforeman.org/ stable main

You then need to download the Foreman GPG key, add it to APT and update like so:

$ wget http://deb.theforeman.org/foreman.asc
$ sudo apt-key add foreman.asc
$ sudo apt-get update

Now Foreman should be available to install as a package. It is available in three versions:

  • Foreman with Sqlite3 – foreman-sqlite3
  • Foreman with PostgreSQL – foreman-pgsql
  • Foreman with MySQL – foreman-mysql

We're going to install the MySQL version:

$ apt-get install foreman-mysql

Tip
Levy has also made available a Puppet module that can be configured to install Foreman and take care of much of the installation process for you. You can find the module at
http://github.com/ohadlevy/puppet-foreman
.

Configuring Foreman

The primary configuration we have to perform for Foreman is to its database back end. Foreman supports a variety of databases including MySQL, Sqlite3, PostgreSQL and Oracle. It also supports sharing a database with Puppet's stored configuration capability (see
Chapter 6
). We're going to choose a MySQL database, so we need to install the required packages.

Configuring Foreman on Red Hat

On Red Hat-based hosts you first need to install the required packages:

$ sudo yum install -y mysql mysql-devel mysql-server ruby-mysql

Next, you will need to manage MySQL. To do this, start MySQL and configure it to start at boot. Use the
service
command to start the service:

$ sudo service mysqld start

Then use the
chkconfig
command to configure to MySQL to start when the host boots:

$ sudo chkconfig mysqld on
Configuring Foreman on Ubuntu and Debian

On Ubuntu and Debian based hosts, you need to install the required packages:

$ sudo apt-get install -y libmysql-ruby libmysqlclient-dev mysql-server

Other books

The Bungalow Mystery by Annie Haynes
Mister Cassowary by Samantha Wheeler
Atlas by Isaac Hooke
The Unwanted by Kien Nguyen
Retribution by Wards, Lietha
Altered by Gennifer Albin
In Arabian Nights by Tahir Shah
Caravan of Thieves by David Rich
Night of Shadows by Marilyn Haddrill, Doris Holmes
The Golden Desires by Pratley, Ann M