Skip to content

Puppet 4 :: Language Essentials

Sandesh Kota edited this page Apr 30, 2018 · 20 revisions

Intro:

  • Puppet script should be Idempotent : Same result every time the script is ran
  • Ex: Create User 'kota' with id 101
    • No matter how many times the above script is ran it should result in User 'kota' with Id '101' existence. not necessarily create it.
  • Puppet Docs

Display Data:

  • puppet agent --version
  • puppet config print
  • puppet config print confdir
  • puppet config print certname
  • puppet config print { confdir rundir ssldir runinterval }

Puppet script Validation

  • puppet parser validate hello.pp

Puppet Agent - Runs on Clients and send facts (about the machine) to the server
Puppet Server - Collects facts from agents and compiles a catalog for the agents to apply
Puppet Apply - A combination of puppet agent and puppet server allowing client to run in a standalone mode

Controlling the Agent - We currently do want to use the Puppet Agent. This can run as a daemon service so we should check that it us both stopped and disabled

service { 'puppet':
  ensure => 'stopped',
  enable => false,
}

To show all puppet modules that are installed
puppet module list
To Install a module
puppet module install <module_name>
To install from a manifest
puppet apply -e "include <module_name>"
include <module_name>

Puppet Resources - The Big Three

  • Package
    • ensure => 'installed', 'absent', 'purged', 'latest', '4.1'
  • File
    • ensure =>
    • content =>
  • Service
    • ensure => 'running', 'stopped'
    • enable => true, false
type { 'title':
  attribute => value,
}
#List of all resources
puppet describe --list
#Attributes of a particular resource
puppet describe <resource_name>
puppet describe notify
puppet describe user
puppet describe user --short

Puppet Standard Library

Users and Groups

Hosts

SSH_Authorized_Keys

Resource Defaults

Clone this wiki locally