Robert Harker Technical Wiki
Thoughts and Ideas About Large Sites

[ Prev ] [ Index ] [ Next ]


Puppet Training

TOPIC

List resource:
puppet resource service|user

Inline help?:
puppet describe -s service short listing
puppet describe service long listing

puppet master --configprint modulepath
/etc/puppetlabs/puppet/modules:/opt/puppet/share/puppet/modules

package { 'httpd':
ensure => present,
before => File['/etc/httpd/conf/httpd.conf'],
}
file { '/etc/httpd/conf/httpd.conf':
ensure => file,
mode => 644,
source => '/root/examples/httpd.conf',
}
service { 'httpd':
ensure => running,
enable => true,
subscribe => File['/etc/httpd/conf/httpd.conf'],
}

# using ordering arrows between defs:
package {'httpd':
ensure => installed,
}
-> # ordering arrow
file {'/etc/httpd/conf/httpd.conf':
ensure => file,
source => '/root/examples/answers/httpd.conf',
}
~> # ordering-with-notification arrow
service {'httpd':
ensure => running,
}

notify {"Apache configured!:}

/etc/puppetlabs/puppet/puppet.conf

[main]
vardir = /var/opt/lib/pe-puppet
logdir = /var/log/pe-puppet
rundir = /var/run/pe-puppet
modulepath = /etc/puppetlabs/puppet/modules:/opt/puppet/share/puppet/modules
user = pe-puppet
group = pe-puppet
archive_files = true
archive_file_server = learn.localdomain

Certain module names are disallowed:
main
settings

List all installed modules:
$ sudo puppet module list

Templates:
Facts, global variables, and local variables from the current scope:
@fqdn, @memoryfree, @operatingsystem

Variables from other scopes:
scope.lookupvar('apache::user')

Non-Printing Tags:
<% document = "" %>
Printing an Expression:
<%= sectionheader %>
environment = <%= gitrevision[0,5] %>
Suppressing Line Breaks and Leading Space:
<%- document += thisline -%>

NTP for virt instances
<% if @is_virtual == "true" -%>
# Keep ntpd from panicking in the event of a large clock skew
# when a VM guest is suspended and resumed.
tinker panic 0
<% end -%>
<% if @is_virtual == "false" -%>
# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available.
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
<% end -%>

Class variables:
Module manifest:
class ntp ($servers = undef) {
...
}

if $servers == undef {
$servers_real = $default_servers
}
else {
$servers_real = $servers
}

puppet/manifest:
include ntp
class {'ntp':
servers => [ "ntp1.example.com dynamic", "ntp2.example.com dynamic", ],
}

Ruby RDoc:
puppet doc --mode rdoc --outputdir ~/moduledocs \
--modulepath /etc/puppetlabs/puppet/modules

# Make sure compilation will fail if 'myclass' doesn't get declared:
Class['myclass'] -> Apache::Vhost["$title"]

Puppet’s graphing support:
created by and on the agent nodes
graph=true
graphdir
graphviz pkg
dot -Tpng /var/puppet/state/graphs/resources.dot -o /tmp/configuration.png


Backlinks: index Start
Created with Zim desktop wiki