Overview
Very quick start on CentOS 7.x.
Three servers:
- master (puppet master)
- web (puppet client, httpd and php will be installed)
- db (puppet client, mariadb-server will be installed)
These 3 servers should have the same current date,time and similar /etc/hosts:
# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.1 master
192.168.1.2 web
192.168.1.3 db
Install
Add puppetlabs repository on all servers:
rpm -Uvh https://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm
Install puppet server on master:
yum -y install puppetserver
systemctl start puppetserver
Install puppet agent on web and db servers:
yum -y install puppet-agent
# cat /etc/puppetlabs/puppet/puppet.conf
server = master
/opt/puppetlabs/bin/puppet resource service puppet ensure=running enable=true
Sign certificate requests on master server:
/opt/puppetlabs/bin/puppet cert list
"db" (SHA256) FE:90:4D:46:9B:89:77:1C:CF:C2:81:5F:2D:A0:22:51:C7:2A:62:A4:01:F5:42:1D:73:2D:66:81:F9:B5:33:81
"web" (SHA256) 1C:53:D7:B5:9F:89:5F:78:68:0B:BD:AA:A5:C5:38:56:FC:16:17:6E:07:75:26:56:0F:64:79:0B:17:B5:6C:08
/opt/puppetlabs/bin/puppet cert sign db
/opt/puppetlabs/bin/puppet cert sign web
First manifest:
Create default main manifest: /etc/puppetlabs/code/environments/production/manifests/site.pp:
node default {
}
node 'web' {
package { 'httpd':
ensure => installed,
}
package { 'php':
ensure => installed,
}
}
node 'db' {
package { 'mariadb-server':
ensure => installed,
}
}
You can run "puppet apply" command to execute the manifest. If you do not want to wait default 30 minutes.
On web server:
[root@web ~]# /opt/puppetlabs/bin/puppet agent -t
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Caching catalog for web
Info: Applying configuration version '1460114887'
Notice: /Stage[main]/Main/Node[web]/Package[httpd]/ensure: created
Notice: /Stage[main]/Main/Node[web]/Package[php]/ensure: created
Notice: Applied catalog in 7.07 seconds
[root@web ~]# rpm -q php
php-5.4.16-36.el7_1.x86_64
[root@web ~]# rpm -q httpd
httpd-2.4.6-40.el7.centos.x86_64
On db server:
[root@db ~]# /opt/puppetlabs/bin/puppet agent -t
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Caching catalog for db
Info: Applying configuration version '1460114896'
Notice: /Stage[main]/Main/Node[db]/Package[mariadb-server]/ensure: created
Notice: Applied catalog in 16.51 seconds
[root@db ~]# rpm -q mariadb-server
mariadb-server-5.5.47-1.el7_2.x86_64
Reports
Reports location: /opt/puppetlabs/server/data/puppetserver/reports/[your_server_name]/*
Some commands to parse reports below.
List changes for web server:
[root@master ~]# find /opt/puppetlabs/server/data/puppetserver/reports/web/ -type f | xargs -I{} cat {}| grep -e "^time: " -e "^status:" | tr '\n' ' ' | sed 's/status/\nstatus/g' | awk '{print $4,$5,$2}' | sort
2016-04-08 18:41:22.023740905 unchanged
2016-04-08 19:11:22.024349202 unchanged
2016-04-08 19:41:22.314900310 changed
2016-04-08 20:11:22.024831563 unchanged
2016-04-08 20:41:22.025064299 failed
2016-04-08 21:11:22.019494381 failed
Last status from web server:
[root@master ~]# ls -1t /opt/puppetlabs/server/data/puppetserver/reports/web/ | head -n1 | xargs -I{} cat /opt/puppetlabs/server/data/puppetserver/reports/web/{} | grep '^status:'
status: failed