• Puppet runs in an agent/master (that is, client/server) configuration.
  • Puppet programs are called “manifests,” and they use the .pp file extension.
  • Puppet execution Flow

puppet1

  • Manifest Example

 

   test.pp

file {'testfile':
path => '/tmp/testfile',
ensure => present,
mode => 0640,
content => "I'm a test file.",
}


  • Compilation – Dry run
$ puppet apply test.pp --noop
Notice: Compiled catalog for <host> in environment production in 0.10 seconds
Notice: /Stage[main]/Main/File[testfile]/ensure: current_value absent, should be present (noop)
Notice: Class[Main]: Would have triggered 'refresh' from 1 events
Notice: Stage[main]: Would have triggered 'refresh' from 1 events
Notice: Finished catalog run in 0.02 seconds

 

  • Catalog application
$ puppet apply test.pp
Notice: Compiled catalog for localhost in environment production in 0.10 seconds
Notice: /Stage[main]/Main/File[testfile]/ensure: created
Notice: Finished catalog run in 0.03 seconds
$

$ ls -lrt /tmp/testfile
-rw-r----- 1 oracle oinstall 16 Mar 22 18:06 /tmp/testfile

$ cat /tmp/testfile

I'm a test file.

 

  • Physical order of resources in a manifest doesnʼt imply a logical order
  • Most useful pattern – package/file/service,
package - makes sure the software is installed, 

File (Config) - file depends on the package resource

Service - subscribes to changes in the config file.


ALL GOOD State -

# puppet apply fmw_jdk/manifests/install_jdk.pp
Warning: Config file /etc/puppet/hiera.yaml not found, using Hiera defaults
Notice: Compiled catalog for localhost in environment production in 0.21 seconds
Notice: Finished catalog run in 0.06 seconds
#

DO THE BAD STUFF - Remove jdk install and do a dry run - You can see puppet tells you that it's missing

# rm -rf  /u01/puppet-test1-jdk/
# puppet apply fmw_jdk/manifests/install_jdk.pp --noop
Warning: Config file /etc/puppet/hiera.yaml not found, using Hiera defaults
Notice: Compiled catalog for localhost in environment production in 0.19 seconds
Notice: /Stage[main]/Fmw_jdk::Internal::Jdk_linux/File[/u01/puppet-test1-jdk]/ensure: current_value absent, should be directory (noop)
Notice: /Stage[main]/Fmw_jdk::Internal::Jdk_linux/Exec[Unpack JDK]/returns: current_value notrun, should be 0 (noop)
Notice: /Stage[main]/Fmw_jdk::Internal::Jdk_linux/File[/u01/puppet-test1-jdk/jdk1.7.0_97]/ensure: current_value absent, should be directory (noop)
Notice: Class[Fmw_jdk::Internal::Jdk_linux]: Would have triggered 'refresh' from 3 events
Notice: Class[Fmw_jdk::Install]: Would have triggered 'refresh' from 1 events
Notice: Stage[main]: Would have triggered 'refresh' from 2 events
Notice: Finished catalog run in 0.06 seconds
#

FIX IT

# puppet apply fmw_jdk/manifests/install_jdk.pp
Warning: Config file /etc/puppet/hiera.yaml not found, using Hiera defaults
Notice: Compiled catalog for localhost in environment production in 0.19 seconds
Notice: /Stage[main]/Fmw_jdk::Install/Fmw_jdk::Internal::Jdk_linux/File[/u01/puppet-test1-jdk]/ensure: created
Notice: /Stage[main]/Fmw_jdk::Install/Fmw_jdk::Internal::Jdk_linux/Exec[Unpack JDK]/returns: executed successfully
Notice: /Stage[main]/Fmw_jdk::Install/Fmw_jdk::Internal::Jdk_linux/File[/u01/puppet-test1-jdk/jdk1.7.0_97]/owner: owner changed 'uucp' to 'root'
Notice: /Stage[main]/Fmw_jdk::Install/Fmw_jdk::Internal::Jdk_linux/File[/u01/puppet-test1-jdk/jdk1.7.0_97]/group: group changed '143' to 'root'
Notice: /Stage[main]/Fmw_jdk::Install/Fmw_jdk::Internal::Jdk_linux/File[/u01/puppet-test1-jdk/jdk1.7.0_97]/mode: mode changed '0755' to '0775'
Notice: Finished catalog run in 4.58 seconds
# ls -lrt /u01/puppet-test1-jdk/
total 4
drwxrwxr-x 8 root root 4096 Feb  2  2016 jdk1.7.0_97
#


  • Puppet resource types – Following will show all resource types that puppet supports
                               $puppet resource --types                               $puppet resource user <username> OR
                               To show all users,                               $puppet resource user