Sunday, 29 December 2013

Puppet - Bit Advanced setup and configuration

In continuation to Basic puppet setup explained in my earlier post . Here is the advanced setup.

Advanced puppet configuration:


Agenda: What exactly I am trying to replicate here.I will be trying to keep 'mod_jk.conf' file which I had placed inside '/etc/puppet/files' folder of master server to keep in sync. Whenever I make any changes to mod_jk.conf file on puppet master,the daemon running on puppet agent will pick up the changes on master and bring agent in sync with puppet master. It will also restart Apache webserver where puppet agent is installed.

----------------------------------Master side configuration changes-----------------------------------

Create  a file inside '/etc/puppet/manifests'. Touch site.pp.

site.pp
import 'classes/*.pp'
class toolbox {
        file { '/tmp/gautam.txt':
        owner => root, group => root, mode => 0755,
        content => "Hi gautam....how are you",
        }
        }
        node 'beta01.hs18.lan' {
        include toolbox
        include apache
        include mysite
        }

Create a folder 'classes' inside '/etc/puppet/manifests'. Now create two files inside classes folder.
apache.pp
mysite.pp

apache.pp
class apache {
        package { 'mod_ssl-2.2.15-29.el6.centos.x86_64':
        ensure => installed
        }

        service { 'httpd':
                        ensure => running,
                        hasstatus => true,
                        hasrestart => true,
                }
}

mysite.pp
class mysite {
                file { '/etc/httpd/conf.d/mod_jk.conf':
        owner => root, group => root, mode => 0644,
        source => "puppet:///files/mod_jk.conf",
        }

}

fileserver.conf [Please modify the content as per your requirement]
# This file consists of arbitrarily named sections/modules
# defining where files are served from and to whom

# Define a section 'files'
# Adapt the allow/deny settings to your needs. Order
# for allow/deny does not matter, allow always takes precedence
# over deny
[files]
path /etc/puppet/files/
allow *
#  allow *.hs18.lan
#  deny *.evil.example.com
#  allow 192.168.0.0/24
#
[mount_point]
        path /etc/puppet/files/
    allow *

make a folder 'files' inside '/etc/puppet' and place our file [mod_jk.conf in my case]

Now start puppet agent as explained in my previous blog ( http://kulshresht-gautam.blogspot.in/2013/12/getting-started-with-puppet-basic-setup.html ) and play around with it.

Please watch the below video for better understanding.
http://www.youtube.com/watch?v=Hiu_ui2nZa0

1 comment: