puppet tips

syntax, test mode, ...

# check syntax of your manifests:
find -name '*.pp' | xargs -n 1 -t puppet --parseonly
 
# since version 2.7 the syntax for the syntax check changed:
puppet parser validate *.pp
ppcheck
#!/bin/bash
 
if [ -z $1 ]; then
    PENV=production
else
    PENV=$1
fi
 
find -name '*.pp' | xargs -n 1 -t puppet --parseonly --environment $PENV
# ERB files are easy to syntax check. For a file mytemplate.erb, run:
erb -x -T '-' -P mytemplate.erb | ruby -c
# test what should be done:
puppet agent --no-daemonize --verbose --onetime --noop
 
# newer agents have --test which combines several options:
puppet agent --test --environment=dev --noop
 
# use the default environment from /etc/puppet.conf:
puppet agent --test --noop
# avoid caching and force the puppetmaster to recompile the catalog:
touch manifests/site.pp

run puppet agent via cron

puppet-cron.sh
#!/bin/bash
#
# the sleep command causes a random delay between zero and five minutes
#
set -e
set -u
sleep $((RANDOM % 300))
exec puppet agent --no-daemonizie --onetime

ralsh

puppet resource User "xyz"
 
user { 'xyz':
   home => '/home/xyz',
   shell => '/bin/bash',
   uid => '1000',
   comment => 'xyz,,,',
   gid => '1000',
   groups => ['adm','dialout','cdrom','sudo','plugdev','lpadmin','admin','sambashare','libvirtd'],
   ensure => 'present'
}

show config settings

Very useful if you wonder why somethings breaks:

puppet --configprint all 
async_storeconfigs = false
authconfig = /etc/puppet/namespaceauth.conf
autoflush = false
autosign = /etc/puppet/autosign.conf
[...]

stored configs

To clean up everything a puppetmaster knows about a node (including stored configs), run:

puppet node clean host.example.com

notice: Revoked certificate with serial 12
notice: Removing file Puppet::SSL::Certificate host.example.com at '/var/lib/puppet/ssl/ca/signed/host.example.com.pem'
notice: Removing file Puppet::SSL::Certificate host.example.com at '/var/lib/puppet/ssl/certs/host.example.com.pem'
notice: host.example.com storeconfigs removed
["host.example.com"]
networking/puppet/tips.txt · Last modified: 2015-05 by tb
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0 ipv6 ready