Introduction to Puppet Paul Waring (paul@xk7.net, @pwaring) June - - PowerPoint PPT Presentation

introduction to puppet
SMART_READER_LITE
LIVE PREVIEW

Introduction to Puppet Paul Waring (paul@xk7.net, @pwaring) June - - PowerPoint PPT Presentation

Introduction to Puppet Paul Waring (paul@xk7.net, @pwaring) June 21, 2014 Configuration management and provisioning Define how a machine should be setup Configuration, software installed, users etc. Manage large numbers of machines -


slide-1
SLIDE 1

Introduction to Puppet

Paul Waring (paul@xk7.net, @pwaring) June 21, 2014

slide-2
SLIDE 2

Configuration management and provisioning

◮ Define how a machine should be setup ◮ Configuration, software installed, users etc. ◮ Manage large numbers of machines - especially identical ones ◮ Quick redeployment of server ◮ Development matches production ◮ Ensure a consistent state, even if local edits made

slide-3
SLIDE 3

What is Puppet?

◮ Configuration management and provisioning ◮ Apache 2.0 licence since v2.7 ◮ Declarative vs imperative ◮ Describe desired state of server, Puppet makes it so

slide-4
SLIDE 4

Puppet Labs

◮ Commercial company behind the software ◮ Enterprise platform available ◮ Support, training, conferences etc.

slide-5
SLIDE 5

Support

◮ Community: mailing lists, IRC etc. ◮ Commercial: Puppet Labs, contractors etc.

slide-6
SLIDE 6

Alternatives

◮ Ansible ◮ Chef ◮ cfengine

slide-7
SLIDE 7

Why Puppet?

◮ Large ecosystem and community ◮ Lots of documentation (wikis, books etc.)

slide-8
SLIDE 8

Why not Puppet?

◮ Requires an agent on all machines ◮ Extra firewall rules ◮ Bootstrapping problem ◮ You hate Ruby

slide-9
SLIDE 9

Manifests

◮ Describe how a system should be configured ◮ Plain text files, Ruby syntax ◮ Write manifests once, run anywhere (mostly)

slide-10
SLIDE 10

Vagrant Provisioning

◮ Start up a VM and configure it automatically ◮ Will be used in all examples

slide-11
SLIDE 11

Resources

◮ Basic building blocks of manifests ◮ Standard types: package, exec, service etc. ◮ Define your own resource types ◮ Third party resource types: mysql, apache etc.

Generic example

resource_type { "identifier": attribute1 = value, attribute2 = value, }

slide-12
SLIDE 12

Package resource

Controls packages installed on the system.

Attributes

◮ name: Name (from package management system), defaults to

identifier

◮ ensure: What state the package should be in

Examples

package { "nethack-common": ensure = present, } package { "php5": ensure = absent, }

slide-13
SLIDE 13

Exec resource

Execute specific commands which are not represented by resources (e.g. there is no ‘compressed’ resource type).

Examples

exec { "unpack_moodle_db": unless = "/usr/bin/test -f /home/vagrant/moodle.sql", command = "/bin/gunzip /home/vagrant/moodle.sql.gz", } exec { "unpack_moodle_code": cwd = "/home/vagrant/www/moodle2/htdocs", command = "/bin/tar --strip-components=1 \

  • xzf /home/vagrant/moodle-2.2.11.tgz",

}

slide-14
SLIDE 14

Service resource

Ensure services are running (or not). service { 'apache2': ensure = running, enable = true, }

slide-15
SLIDE 15

MySQL resource

Optional resource made available by Puppet Labs. puppet module install puppetlabs-mysql mysql_user { 'puppet@localhost': ensure = present, } mysql_database { 'puppet': ensure = present, } mysql_grant { 'puppet@localhost/puppet.*': ensure = present,

  • ptions = ['GRANT'],

privileges = ['ALL'], table = 'puppet.*', user = 'puppet@localhost', }

slide-16
SLIDE 16

Resource ordering

Occasionally resources need to be processed in a particular order which Puppet cannot determine.

Examples

file { "/home/vagrant/moodle-latest-26.tgz": ensure = present, source = "/vagrant_data/moodle-latest-26.tgz", before = Exec["unpack_moodle_code"], } exec { "unpack_moodle_code": cwd = "/home/vagrant/www/moodle2/htdocs", command = "/bin/tar --strip-components=1 \

  • xzf /home/vagrant/moodle-latest-26.tgz",

}

slide-17
SLIDE 17

Questions

◮ Slides and scripts on GitHub under BSD Licence ◮ https://github.com/pwaring/puppet-talk