Tuesday, November 9, 2010

PUPPET Dashboard on CentOS/Ubuntu

I've been testing PUPPET Dashboard engine on CentOS 5.0, this may also work on Ubuntu or Debian also.

The Puppet Dashboard allows you to display the results of your Puppet runs on your hosts and provides a node classification tool to configure your hosts.

Adding Yum or Apt repositories
First, we need to add either the Puppet Labs Yum or Apt repositories. For Yum, we need to create a Yum repo entry for Puppet Labs:

$ vi /etc/yum.repos.d/puppetlabs.repo
Add the following to the entry:
[puppetlabs]
name=Puppet Labs Packages
baseurl=http://yum.puppetlabs.com/base/
enabled=1
gpgcheck=1
gpgkey=http://yum.puppetlabs.com/RPM-GPG-KEY-puppetlabs


Then install via Yum.
$ sudo yum install puppet-dashboard

You will be prompted to install the Puppet Labs release key as part of the installation process.
For Apt, we need to add entries to the /etc/apt/sources.list file:
deb http://apt.puppetlabs.com/ubuntulucid main
deb-src http://apt.puppetlabs.com/ubuntulucid main


And then add the Puppet Labs GPG key to Apt.
$ gpg --recv-key 4BD6EC30
$ gpg -a --export 4BD6EC30 | sudo apt-key add -


Next, we run an update:

$ sudo apt-get update

And then install the package:
$ sudo apt-get install puppet-dashboard

On both Red Hat and Ubuntu hosts, the Puppet Dashboard will be installed into the /usr/share/puppet-dashboard directory.



Configuring the Rails application
Next, we need to configure the Rails application, starting with a database. Currently the Dashboard only supports MySQL databases, so create one:
$ mysql --u root p
mysql> CREATE DATABASE dashboard CHARACTER SET utf8;
mysql> CREATE USER 'dashboard'@'localhost' IDENTIFIED BY 'password';

mysql> GRANT ALL PRIVILEGES ON dashboard.* TO 'dashboard'@'localhost';

Here we’ve created a database called dashboard, added a user called dashboard and granted that user appropriate privileges to the database. You should replace “password” with an appropriate password.
Next, we need to tell Dashboard about the database. To do this, we configure a database.yml file in the /usr/share/puppet-dashboard/config directory.
The package contains an example file called database.yml.example that we can copy and edit:
$ cp database.yml.example database.yml
$ vi database.yml
Update the production stanza in the file like so (replacing password with the password you chose above):
production:
adapter: mysql
database: dashboard
username: dashboard
password: password
encoding: utf8
This stanza needs to be valid YAML, so ensure you keep the existing indentation.
Lastly, we need to populate our new database with tables and base data. To do this we use a Rake task.  From the /usr/share/puppet-dashboard directory, run:
$ rake RAILS_ENV=production db:migrate

Now Dashboard is fully configured and we can run the Rails application. There are a lot of ways to run Rails applications. One way is to use the internal Webrick server (this isn’t really great for production, as it doesn’t scale very well).
From the /usr/share/puppet-dashboard directory, run:
$ sudo ./script/server -e production

This will run the Dashboard on port 3000 and you can access it via a Web browser:
http://your.host.name:3000
Getting Puppet reports to the Puppet Dashboard
Now the Dashboard is running and we need to ensure it gets our Puppet reports. There are a few ways we can do this, starting with importing old reports using a Rake task. From the /usr/share/puppet-dashboard directory, run:
$ rake RAILS_ENV=production reports:import

This assumes your Puppet master is on the local host and will import any report files located in the Puppet vardir (usually /var/lib/puppet/reports, but you can specify an alternative with the REPORT_DIR option). You can run this multiple times or schedule it with a cron job -- it recognizes reports it has previously imported and will only add new reports.
You can also configure Puppet to automatically report to the Dashboard using two methods, the first for Puppet versions 0.25.x and earlier, and the second for Puppet versions 2.6.x and later. For Puppet 0.25.x and earlier, ensure you have reports enabled on your clients by adding report = true to the [puppetd] stanza of your puppet.conf configuration file on every client you wish to have reporting. Then on the Puppet master, add /usr/share/puppet-dashboard/lib/puppet to Puppet’s libdir in the puppet.conf file like so:
[main]
libdir = /usr/share//puppet-dashboard/lib/puppet:/var/puppet/lib

And enable the Puppet Dashboard report:
[puppetmasterd]
reports = puppet_dashboard, any-other-reports
This report assumes your Puppet Dashboard is running on the local host at port 3000. You can adjust this location by editing the file /usr/share/puppet-dashboard/lib/puppet/puppet_dashboard.rb file and updating the HOST and PORT options at the top of the file.
On Puppet 2.6.x and later, you need to enable reports on your clients:
[agent]
report = true
And then specify the http report type and use the new reporturl option to specify the target host and URL like so:
[master]
reporturl=http://localhost:80/reports
reports=http


Update the host and port to match your environment (you should leave the reports suffix on the URL).
Now the Puppet Dashboard should be receiving your Puppet reports and you’re done! When you navigate to the page, you should see the Puppet Dashboard’s home screen.


Updates on doing my PUPPET configuration, certificates can be revoked once issued.

Revoking the key on puppet master server:
command : puppetca --revoke <hostname | serial >
Certificates can be removed also on puppet master server
command : puppetca --clean <hostname>

I've been looking on apache automation, Here's I've found out upon searching just want it to document here.


class apache {
    # CentOS v.5 only
    case  $operatingsystem {
     "CentOS":  {
        $wantedpackages = [ "httpd","php","php-mysql","php-mcrypt","php-mhash","php-mbstring" ]
        package { $wantedpackages:
                  ensure => installed
        }
        service { "httpd":
                ensure => running,
                hasstatus => true,
                hasrestart => true,
                require => Package["httpd"],
                restart => true;
        }
      }
 
    "Debian": {
        # assume Debian base..
        $wantedpackages = [ "apache2" ]
        package { $wantedpackages:
                  ensure => installed
        }
 
        service { "apache2":
                hasstatus => true,
                hasrestart => true,
                ensure => running,
                require => Package["apache2"]
        }
    }
  } # end case
}
http://www.capsunlock.net/2008/11/configure-ubuntu-and-centos-webserver-using-puppet.html

No comments:

Post a Comment

If you have any suggestion or clarification you send it via on this form.