Brunei Geek Meet: 9th Sept 2015
Catalog
Document that describes the desired system state of a system
list resources to be managed
specifies dependencies between resources
Stored on the Master
Facts
Represents individual pieces of information of the node (e.g. operating system, ip address)
facter # see all facts
facter ipaddress # retrieve ip address of system
facter hostname # retrieve hostname of system
Manifests are files containing Puppet code
.pp extension
Manually execute a manifest
Puppet starts with the main/site manifest
$confdir/manifests/site.pp
Manifests will have
resources declared in them
logic to process nodes according to their facts
puppet apply file.pp
puppet config print
Basic building blocks of manifests
Resource Abstraction Layer (RAL) allows for single naming of types
User, File, Package, Service
Providers
actual implementation of the resource
(operating) system dependent
E.g. Package type => providers: apt, yum, gem
puppet resource user # inspect all user resources
puppet resource user test # inspect a single user
Type.Title must be unique
Creating / Editing / Querying
# defining a resource
user { 'gary':
ensure => present,
uid => '1002',
gid => '01',
}
# directly executing puppet code
puppet apply -e "user { 'gary': ensure => present, \
uid => '1002', gid => '01', }"
# modifying an existing resource, shows all attributes
puppet resource -e user gary
Grouping of resources related to a specific function
Named blocks of Puppet code
Named so that can be used in nodes easily
https://docs.puppetlabs.com/puppet/latest/reference/lang_classes.html
# defining the class
class apache ($version = 'latest') {
package {'httpd':
ensure => $version, # Using the class parameter from above
before => File['/etc/httpd.conf'],
}
file {'/etc/httpd.conf':
ensure => file,
owner => 'httpd',
content => template('apache/httpd.conf.erb'), # Template from a module
}
service {'httpd':
ensure => running,
enable => true,
subscribe => File['/etc/httpd.conf'],
}
}
Classes can be used after definition / declaration
# using the class
# simple usage
include 'apache'
# for specifying parameter values
class {apache:
version => "2.6",
}
docs.puppetlabs.com/puppet/latest/reference/modules_fundamentals.html
Self contained bundle of manifests and files
Automatically loaded and can be used similar to classes
Puppet Forge: online repository of modules
Location
$confdir/modules
Searching / Installing Modules
puppet module search module_name
puppet module install module_name
package { 'openssh-server':
ensure => present,
before => File['/etc/ssh/sshd_config'],
}
file { '/etc/ssh/sshd_config':
ensure => file,
mode => '0600',
source => 'puppet:///modules/sshd/sshd_config',
require => Package['openssh-server'],
}
file { '/etc/ssh/sshd_config':
ensure => file,
mode => '0600',
source => 'puppet:///modules/sshd/sshd_config',
notify => Service['sshd'],
}
service { 'sshd':
ensure => running,
enable => true,
subscribe => File['/etc/ssh/sshd_config'],
}
Use the Learning VM
Self-Paced Training
Personally found this slow and couldn't find code that was used as prerequisites to the exercises!
Chef
Collaborations with Microsoft (presumingly better Windows support)
Salt
Ansible