Showing posts with label puppet. Show all posts
Showing posts with label puppet. Show all posts

Monday, June 3, 2013

[how to]:: Install puppet

Ok so my first puppet post was a little advanced, so I thought maybe I should start with the basics of puppet. Puppet starts getting pretty awesome as soon as you need to manage more than 5 servers and over 60 virtual hosts, spread across various servers. But before we proceed, lets install puppet and run our first puppet script!


Installation:

Assuming you have CentOS, you'll need to add the correct puppetlabs yum repositories. This can be done by using the following command,


# rpm -ivh http://yum.puppetlabs.com/el/6/products/i386/puppetlabs-release-6-7.noarch.rpm

Once installed, you need to use yum to install puppet and puppet server.



# yum install puppet puppet-server

Confirm that puppet is installed by running,
# puppet --version
3.2.1


Lets start with create a basic puppet script to create a file called test.pp and add the following text to it,

## test.pp
file {"/tmp/test":
 ensure => file,
 owner => root,
 group => root,
 content => "hello im a file",
 mode => 644,
}

To apply this script you will need to run puppet with the following command,


# puppet apply test.pp 
Notice: /Stage[main]//File[/tmp/test]/ensure: defined content as '{md5}e32d2cadd86f222aa80e3fd11d22d0cd'
Notice: Finished catalog run in 0.08 seconds

Great, from the Notice you can see that a file was created under /tmp/test. You can cat the file to confirm the content "hello im a file".


Next post we will be moving this test.pp to the puppet master, add a server to puppet master and then create the /tmp/test file on the client server.




Cheers,

Dan

Production Class Puppet Master Server

Background:

Running puppetmaster with the built in webserver from Ruby is not exactly scalable and puppet will suffer from performance issues. After researching, I've come across the following solution,
  • nginx, with ruby passenger.
More robust and can scale easily to a couple of hundred hosts. I have not personally run this on a environment of more that 40 servers. So lets start with the setup.

Assumptions:

  1. Using latest Centos 6.4
  2. Puppet repo added to yum (# rpm -ivh http://yum.puppetlabs.com/el/6/products/i386/puppetlabs-release-6-7.noarch.rpm)
  3. Remove any nginx installations (# yum remove nginx)
Once your server virtual machine is updated, lets get ready for the installation.

Installation:

  1. # yum install -y ruby rubygems ruby-devel.x86_64 puppet puppet-server gcc make pcre-devel zlib-devel openssl-devel pam-devel curl-devel gcc-c++
  2. # gem install rack passenger
  3. # /usr/lib/ruby/gems/1.8/gems/passenger-4.0.5/bin/passenger-install-nginx-module 
    • Follow the onscreen instructions. This script will install the passenger module, as well as getting the latest nginx and compiling it under /opt/nginx.
    • This will take a while :)
  4. A couple of links are required
    • # ln -s /opt/nginx/conf /etc/nginx
    • # ln -s /opt/nginx/logs /var/log/nginx
  5. Lets install the start up script and sysconfig,
    • # curl -L https://raw.github.com/anythinglinux/misc_scripts/master/nginx/initd_nginx.sh -o /etc/init.d/nginx; chmod +x /etc/init.d/nginx
    • # curl -L https://raw.github.com/anythinglinux/misc_scripts/master/nginx/sysconfig_nginx -o /etc/sysconfig/nginx
  6. nginx configuration setup
    • # mkdir -p /etc/nginx/conf.d
    • We will be placing the puppet master virtual host under the conf.d directory. This keeps things neat and tidy!
    • # curl -L https://raw.github.com/anythinglinux/misc_scripts/master/nginx/nginx.conf -o /etc/nginx/nginx.conf
    • # curl -L https://raw.github.com/anythinglinux/misc_scripts/master/nginx/puppet.conf-o /etc/nginx/conf.d/puppet.conf
    • Edit the puppet.conf file and replace puppet01.test.net with your FQDN servername!
  7. Now we run puppet in master mode to create all the certificates required.
    • # puppet master --no-daemonize --verbose
    • Once all certs are created press CTRL+c to quit.
    • View that the certs where created, # ls -l /var/lib/puppet/ssl/*/*
      • MAKE SURE THE SERVER NAMES MATCH UP!
  8. Next we setup the Rack.
    • # mkdir -p /etc/puppet/rack/public
    • # curl -L https://raw.github.com/anythinglinux/misc_scripts/master/nginx/puppet_rack/config.ru -o /etc/puppet/rack/config.ru
    • # chown -R puppet:puppet /etc/puppet/rack
  9. Add nginx to startup,
    • # chkconfig --add nginx; chkconfig nginx on; chkconfig puppetmaster off
If everything went to plan you should be running puppet master thru nginx and passenger on port 8140 (ssl).

Please ensure that all the setting are correct on the files.

Feel free to comment :)

Enjoy,
D