Show what puppet would have done without changing anything:
sudo puppet apply –noop /examples/file_hello.pp
See what change puppet would actually make to a file:
sudo puppet apply –noop –show_diff /examples/file_hello.pp
See what version of a package puppet thinks you have installed:
puppet resource package openssl
See different attributes of different resources:
puppet describe [file, package, service]
See list of all avaiable resource types:
puppet describe –list
Using the each function
$tasks = [‘task1’, ‘task2’, ‘task3’]
$tasks.each | $task | {
file { “/usr/local/bin/${task}”:
content => “echo I am ${task}\n”,
mode => ‘0755’,
}
}
Iterating over hashes
$nics = $facts[‘networking’][‘interfaces’]
$nics.each | String $interface, Hash $attributes | {
notice(“Interface ${interface} has IP ${attributes[‘ip’]}”)
}
Accessing hashes of facts
$facts[‘os’][‘architecture’]
$facts[‘os’][‘distro’][‘codename’]
$facts[‘os’][‘release’][‘major’]
Using memory facts
$facts[‘memory’][‘system’][‘total_bytes’]
Discovering networking facts
notice(“My hostname is ${facts[‘hostname’]}”)
notice(“My FQDN is ${facts[‘fqdn’]}”)
notice(“My IP is ${facts[‘networking’][‘ip’]}”)