Puppet manifest examples

In this artcile we will describe different type of manifests for different platforms. and  dont  forget to follow the  links  bellow to see how to install the Puppet Master and the Agent.

there is many examples to find on the net. lets show you some of starters things that can make your tests easy  and successful

 

 

Set owner and permission for /etc/passwd file:
file { “/etc/passwd”:
owner => “root”,
group => “wheel”,
mode => 664,
}

Install latest version of Samba:
package { “samba”:
ensure => latest
}

Add new yum repositories for all servers where used yum:
[root@pupmaster ~]# cat /etc/puppet/manifests/nodes/yums.pp
class repos {
        yumrepo { “webtatic”:
                        descr          => “webtatic”,
                        baseurl        => “https://mirror.webtatic.com/yum/el7/webtatic-release.rpm”,
                        failovermethod => “priority”,
                        gpgcheck       => “0”,
                        enabled        => “1”;
        }
        yumrepo { “epel”:
                        descr          => “epel-release”,
                        baseurl        => “http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm”,
                        failovermethod => “priority”,
                        gpgcheck       => “0”,
                        enabled        => “1”;
        }
        yumrepo { “remi”:
                        descr   => “remi-release”,
                        baseurl => “http://rpms.famillecollet.com/enterprise/remi-release-7.rpm”,
                        failovermethod => “priority”,
                        gpgcheck       => “0”,
                        enabled        => “1”;
        }
}
include repos

Condition for install packages to all CentOS(package: httpd):
[root@pupmaster nodes]# cat /etc/puppet/manifests/nodes/centosgroup.pp
class httpd {
        if $::operatingsystem == ‘CentOS’ {
                package { “httpd”:
                        ensure => latest
                }
        }
}
node ‘pupnode1.unixmen.com’ {
        include httpd
}
node ‘pupnode2.unixmen.com’ {
        include httpd
}
node ‘pupnode3.unixmen.com’ {
        include httpd
}
node ‘pupnode4.unixmen.com’ {
        include httpd
}

Condition for install or remove packages to all FreeBSD servers (package: apache24):
[root@pupmaster nodes]# cat /etc/puppet/manifests/nodes/fbgroup.pp
class apache24 {
        if $::operatingsystem == ‘FreeBSD’ {
                package {
                        “apache24”:
                        provider => pkgng,
                        ensure => present;
# For remove use following line:
#                       ensure => “absent”
                }
        }
}
node ‘pupnode7.unixmen.com’ {
        include apache24
}
node ‘pupnode8.unixmen.com’ {
        include apache24
}
node ‘pupnode9.unixmen.com’ {
        include apache24
}

Condition for install packages to all Ubuntu (package:  apache2):
[root@pupmaster nodes]# cat /etc/puppet/manifests/nodes/ubuntugroup.pp
class apache {
        if $::operatingsystem == ‘Ubuntu’ {
                package { “apache2”:
                        ensure => latest
                }
        }
}
node ‘pupnode5.unixmen.com’ {
        include apache
}
node ‘pupnode6.unixmen.com’ {
        include apache
}

Our purpose is synchronize one selected folder from our Puppet Master server to our client node.

For that we must add the following lines in the master server /etc/puppet/fileserver.conf file (With this we told, our file server folder is /etc/qovluq):
[files]
  path /etc/qovluq
  allow *

After in the master server create /etc/puppet/manifests/nodes/foldsync.pp file and add the following lines to content of this file(With this lines we told, synchronize all from the path which named is files in our master server to the /etc/qovluq folder for all nodes):
file {‘/etc/qovluq’:
  ensure  => directory,
  recurse => true,
  purge   => true,
  force   => true,
  source  => ‘puppet:///files’,
}

 

Install  Puppet  master

http://unixmen.com/puppet-installation-and-configuration-to-centos-7-x64/

Install  Puppet  Agent

http://unixmen.com/puppet-agent-install-and-configure-to-all-linuxunix/