Sunday 26 February 2017

puppet cheat sheet

Puppet cheat sheet

Agent

actioncommand
Client bootstrappuppet agent --server puppetmaster --waitforcert 60 --test
Validate manifest syntaxpuppet parser validate init.pp
Puppet dry runpuppet agent --noop --verbose
Disable/Enable Agentpuppet agent --disable / --enable
Execute specific classpuppet agent --tags Some::Class

Cert managment

puppet cert list
puppet cert list --all
puppet cert sign <name>
puppet cert clean <name>
puppet node clean <name>   # removes node + cert

Module managment

puppet module list
puppet module install <name>
puppet module uninstall <name>
puppet module upgrade <name>
puppet module search <name>

Inspecting Resources/Types

puppet describe -l
puppet resource <type name>

# Querying Examples
puppet resource user john.smith
puppet resource service apache
puppet resource mount /data
puppet resource file /etc/motd
puppet resource package wget

# Trigger puppet run from master
puppet kick <name>
puppet kick -p 5 <names>      # 5 parallel

Hiera Queries

On Puppet master

hiera <key>     # to query common.yaml only
hiera <key> -m <FQDN>   # to query config of a given node (using mcollective)
hiera <key> -i <FQDN>   # to query config of a given node (using Puppet inventory)
hiera <key> environment=production fqdn=myhost1   # to pass values for hiera.yaml

# To dump complex data
hiera -a <array key>
hiera -h <hash key>

Hiera Debuging

puppet apply -e "notice(hiera_array('some key'))"


$ cat /etc/puppet/manifests/site.pp
notice("hostname: ${::hostname}")
notice("fqdn: ${::fqdn}")
notice("certname: ${::certname}")

$ puppet master \
  --hiera_config /etc/puppet/hiera.yaml \
  --manifest /etc/puppet/manifests/site.pp \
  --modulepath /etc/puppet/modules \
  --compile test01

Facter

commanddescription
facterAll system facts
facter -pAll system facts and puppet facts
facter -yFacts in YAML format
facter -jFacts in JSON format
facter [-p]A specific fact

Links

No comments:

Post a Comment