SlideShare una empresa de Scribd logo
1 de 32
Dance for the puppet
master
An introduction to Puppet
Michael Peacock
So, what is puppet
Provisioning tool
  “Open source configuration management
  tool”
Used to automate server management
  Configuration
  Installs & upgrades
  etc
Internal development team presentation

          Ground Six Limited
Idempotent
Can be ran multiple times without changing the
server (unless the configuration changes)
Instead of doing things, it checks or ensures
things:
 Ensuring a package is installed only installs it if
 it hasn’t been installed. Execs only run if their
 create file isn’t found (and puppet doesn’t
 think they have been ran)
Configuration within
Vagrant

Tell puppet to run
Tell it where the manifests live
Tell it the default manifest
Tell it where modules live
config.vm.provision :puppet do |puppet|
    puppet.manifests_path = "provision/manifests"
    puppet.manifest_file = "default.pp"
    puppet.module_path = "provision/modules"
  end
What can it do?
cron: install and manage cron jobs (scheduled_task on
windows)
exec: runs shall commands
user: create and manage user accounts
group: create and manage groups
file: create and manage files, folders and symlinks
notify: log something
service: manage running services
And more...the items in bold are known as resources within
puppet
Require
Many / all puppet options support a “require”
configuration
Defines other puppet tasks which must have
been successfully checked / executed before
this can be ran
 We only want to install packages once we
 have updated aptitude
 We only want to install MySQL drivers once
 we have the MySQL client/server installed
Require example


require => [ Package['mysql-client'], Package['mysql-server'] ]




   notice when referencing other puppet
   configurations, the resource type is capitalised
exec
command: command (including full path unless path
is also defined) to be executed. The “name” will be
used if omitted
user & group: to run the command as
create: a file that the command creates. If found,
the exec is not run
cwd: directory to run the command from
path: if full path for command isn’t supplied, path
must point to location of the command
exec: a note

 We create lock files in some of our exec
commands to prevent repeated execution,
 e.g. after installing the default database,
download something or run anything which
           can only be ran once.
exec: example
exec{ "create-db":
           command => '/bin/gunzip -c
/vagrant/database/default.sql.gz > db.sql &&
/usr/bin/mysql < db.sql && /bin/rm db.sql &&
/bin/touch /vagrant/mysqlimport.lock',
      require => [ Package['mysql-client'],
Package['mysql-server'] ],
      creates => "/vagrant/mysqlimport.lock",
      timeout => 0
    }
exec: another example
exec{ "compose":
          command => '/bin/rm -rfv /vagrant/vendor/* && /bin/rm
-f /vagrant/composer.lock && /usr/bin/curl -s
http://getcomposer.org/installer | /usr/bin/php -- --install-
dir=/vagrant && cd /vagrant && /usr/bin/php
/vagrant/composer.phar install',
          require => [ Package['curl'], Package['git-core'] ],
          creates => "/vagrant/composer.lock",
     timeout => 0
     }
exec: what we use it for

Installing the default MySQL database content
Install pear projects
Note: we should probably use or write a puppet
module to install pear projects we need, our
approach is a bit of a hack
subscribe & refreshonly
Some commands need to be ran periodically after
other things have ran
  More so the case when puppet manages
  existing infrastructure (using it to manage whats
  already on a machine and installing new things)
subscribe: defines other events which should cause the
task to run (like require, but refreshes the task)
refreshonly: instructs the task to only run when the other
tasks are completed
Installing software


Package “type”
We need to apt-get update first...
We want to ensure some of our installed
software is running
Update aptitude


  exec { 'apt-get   update':
       command =>   '/usr/bin/apt-get update',
       require =>   Exec['preparenetworking'],
       timeout =>   0
       }
Install package
We just need to ensure the package is present


       package { "apache2":
           ensure => present,
           require => Exec['apt-get update']
         }
Run the service


    service { "apache2":
        ensure => running,
        require => Package['apache2']
      }
Files

ensure: type of file - symlink (link), directory
target: for symlinks - set the target file
source:file to be copied (if copying a file)
owner: user who should own the file
group: group associated with the file
mode: file permissions e.g. 777
file: copy apache config
    Set the source: source => ‘/path/to/file’


file { '/etc/apache2/sites-available/default':
          source =>
'/vagrant/provision/modules/apache/files/default',
          owner => 'root',
          group => 'root'
     }
file: create a symlink
ensure => ‘link’


        file { '/var/www/vendor':
                ensure => 'link',
                target => '/vagrant/vendor',
                require => Package['apache2']
        }
file: create a folder

 ensure => ‘directory’

       file{ "/var/www/uploads":
               ensure => "directory",
               owner => "www-data",
               group => "www-data",
               mode   => 777,
       }
file: create several
  folders

$cache_directories = [ "/var/www/cache/", "/var/www/cache/pages",
                  "/var/www/cache/routes",
"/var/www/cache/templates",
                ]
    file { $cache_directories:
        ensure => "directory",
        owner => "www-data",
        group => "www-data",
        mode   => 777,
    }
Add a cron

command: the command to run
user: user to run the cron as
hour, minute, month, monthday, weekday
 can be defined as hour => 1 or
 hour => [1,2,3,5] or
 hour => [1-10]
Create a user

     user { "developer":
               ensure => "present",
               gid => "wheel",
               shell => "/bin/bash",
               home =>
     "/home/developer",
               managehome => true,
               password =>
     "passwordtest",
               require =>
     Group["wheel"]
          }
Create a group


      group { "wheel":
               ensure =>
      "present",
           }
Make the group a
sudoer
   We probably want to stop this being ran
   multiple times!


exec { "/bin/echo "%wheel ALL=(ALL) ALL" >> /etc/sudoers":
         require => Group["wheel"]
     }
Stages
Running things in a specific order can often be
important
Require often makes this easy for us, however
Exec’s don’t seem to use this reliably
We can define “stages” with a specific order.
We can then put puppet modules into stages
Default stage is Stage[main]
Stages example


   stage { 'first': before => Stage[main] }
   class {'apache': stage => first}
Importing modules
Import the module (assuming it is in the right
folder)
Include the module to be executed


                 import "apache"
                 include apache
Image Credits



http://www.flickr.com/photos/stephen_wong/5
60079730/

Más contenido relacionado

La actualidad más candente

Flask - Backend com Python - Semcomp 18
Flask - Backend com Python - Semcomp 18Flask - Backend com Python - Semcomp 18
Flask - Backend com Python - Semcomp 18Lar21
 
Extending the WordPress REST API - Josh Pollock
Extending the WordPress REST API - Josh PollockExtending the WordPress REST API - Josh Pollock
Extending the WordPress REST API - Josh PollockCaldera Labs
 
Filling the flask
Filling the flaskFilling the flask
Filling the flaskJason Myers
 
Getting to The Loop - London Wordpress Meetup July 28th
Getting to The Loop - London Wordpress Meetup  July 28thGetting to The Loop - London Wordpress Meetup  July 28th
Getting to The Loop - London Wordpress Meetup July 28thChris Adams
 
Dealing with Continuous Data Processing, ConFoo 2012
Dealing with Continuous Data Processing, ConFoo 2012Dealing with Continuous Data Processing, ConFoo 2012
Dealing with Continuous Data Processing, ConFoo 2012Michael Peacock
 
Real time server
Real time serverReal time server
Real time serverthepian
 
Introducing Assetic: Asset Management for PHP 5.3
Introducing Assetic: Asset Management for PHP 5.3Introducing Assetic: Asset Management for PHP 5.3
Introducing Assetic: Asset Management for PHP 5.3Kris Wallsmith
 
PyCon US 2012 - State of WSGI 2
PyCon US 2012 - State of WSGI 2PyCon US 2012 - State of WSGI 2
PyCon US 2012 - State of WSGI 2Graham Dumpleton
 
Running a Scalable And Reliable Symfony2 Application in Cloud (Symfony Sweden...
Running a Scalable And Reliable Symfony2 Application in Cloud (Symfony Sweden...Running a Scalable And Reliable Symfony2 Application in Cloud (Symfony Sweden...
Running a Scalable And Reliable Symfony2 Application in Cloud (Symfony Sweden...Ville Mattila
 
Power shell examples_v4
Power shell examples_v4Power shell examples_v4
Power shell examples_v4JoeDinaso
 
Symfony Guard Authentication: Fun with API Token, Social Login, JWT and more
Symfony Guard Authentication: Fun with API Token, Social Login, JWT and moreSymfony Guard Authentication: Fun with API Token, Social Login, JWT and more
Symfony Guard Authentication: Fun with API Token, Social Login, JWT and moreRyan Weaver
 
Databases and MySQL
Databases and MySQLDatabases and MySQL
Databases and MySQLThings Lab
 
PyCon AU 2010 - Getting Started With Apache/mod_wsgi.
PyCon AU 2010 - Getting Started With Apache/mod_wsgi.PyCon AU 2010 - Getting Started With Apache/mod_wsgi.
PyCon AU 2010 - Getting Started With Apache/mod_wsgi.Graham Dumpleton
 
Javascript Frameworks for Joomla
Javascript Frameworks for JoomlaJavascript Frameworks for Joomla
Javascript Frameworks for JoomlaLuke Summerfield
 
Python RESTful webservices with Python: Flask and Django solutions
Python RESTful webservices with Python: Flask and Django solutionsPython RESTful webservices with Python: Flask and Django solutions
Python RESTful webservices with Python: Flask and Django solutionsSolution4Future
 

La actualidad más candente (20)

Flask - Backend com Python - Semcomp 18
Flask - Backend com Python - Semcomp 18Flask - Backend com Python - Semcomp 18
Flask - Backend com Python - Semcomp 18
 
Extending the WordPress REST API - Josh Pollock
Extending the WordPress REST API - Josh PollockExtending the WordPress REST API - Josh Pollock
Extending the WordPress REST API - Josh Pollock
 
Filling the flask
Filling the flaskFilling the flask
Filling the flask
 
Getting to The Loop - London Wordpress Meetup July 28th
Getting to The Loop - London Wordpress Meetup  July 28thGetting to The Loop - London Wordpress Meetup  July 28th
Getting to The Loop - London Wordpress Meetup July 28th
 
Dealing with Continuous Data Processing, ConFoo 2012
Dealing with Continuous Data Processing, ConFoo 2012Dealing with Continuous Data Processing, ConFoo 2012
Dealing with Continuous Data Processing, ConFoo 2012
 
Real time server
Real time serverReal time server
Real time server
 
Flask – Python
Flask – PythonFlask – Python
Flask – Python
 
Introducing Assetic: Asset Management for PHP 5.3
Introducing Assetic: Asset Management for PHP 5.3Introducing Assetic: Asset Management for PHP 5.3
Introducing Assetic: Asset Management for PHP 5.3
 
Add loop shortcode
Add loop shortcodeAdd loop shortcode
Add loop shortcode
 
PyCon US 2012 - State of WSGI 2
PyCon US 2012 - State of WSGI 2PyCon US 2012 - State of WSGI 2
PyCon US 2012 - State of WSGI 2
 
Running a Scalable And Reliable Symfony2 Application in Cloud (Symfony Sweden...
Running a Scalable And Reliable Symfony2 Application in Cloud (Symfony Sweden...Running a Scalable And Reliable Symfony2 Application in Cloud (Symfony Sweden...
Running a Scalable And Reliable Symfony2 Application in Cloud (Symfony Sweden...
 
Mojo as a_client
Mojo as a_clientMojo as a_client
Mojo as a_client
 
Power shell examples_v4
Power shell examples_v4Power shell examples_v4
Power shell examples_v4
 
Symfony Guard Authentication: Fun with API Token, Social Login, JWT and more
Symfony Guard Authentication: Fun with API Token, Social Login, JWT and moreSymfony Guard Authentication: Fun with API Token, Social Login, JWT and more
Symfony Guard Authentication: Fun with API Token, Social Login, JWT and more
 
Databases and MySQL
Databases and MySQLDatabases and MySQL
Databases and MySQL
 
PyCon AU 2010 - Getting Started With Apache/mod_wsgi.
PyCon AU 2010 - Getting Started With Apache/mod_wsgi.PyCon AU 2010 - Getting Started With Apache/mod_wsgi.
PyCon AU 2010 - Getting Started With Apache/mod_wsgi.
 
Php database connectivity
Php database connectivityPhp database connectivity
Php database connectivity
 
Javascript Frameworks for Joomla
Javascript Frameworks for JoomlaJavascript Frameworks for Joomla
Javascript Frameworks for Joomla
 
Kyiv.py #17 Flask talk
Kyiv.py #17 Flask talkKyiv.py #17 Flask talk
Kyiv.py #17 Flask talk
 
Python RESTful webservices with Python: Flask and Django solutions
Python RESTful webservices with Python: Flask and Django solutionsPython RESTful webservices with Python: Flask and Django solutions
Python RESTful webservices with Python: Flask and Django solutions
 

Similar a Dance for the puppet master: G6 Tech Talk

Puppet: Eclipsecon ALM 2013
Puppet: Eclipsecon ALM 2013Puppet: Eclipsecon ALM 2013
Puppet: Eclipsecon ALM 2013grim_radical
 
From Dev to DevOps - Codemotion ES 2012
From Dev to DevOps - Codemotion ES 2012From Dev to DevOps - Codemotion ES 2012
From Dev to DevOps - Codemotion ES 2012Carlos Sanchez
 
Puppet for Java developers - JavaZone NO 2012
Puppet for Java developers - JavaZone NO 2012Puppet for Java developers - JavaZone NO 2012
Puppet for Java developers - JavaZone NO 2012Carlos Sanchez
 
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013Carlos Sanchez
 
From Dev to DevOps - FOSDEM 2012
From Dev to DevOps - FOSDEM 2012From Dev to DevOps - FOSDEM 2012
From Dev to DevOps - FOSDEM 2012Carlos Sanchez
 
Infrastructure testing with Jenkins, Puppet and Vagrant - Agile Testing Days ...
Infrastructure testing with Jenkins, Puppet and Vagrant - Agile Testing Days ...Infrastructure testing with Jenkins, Puppet and Vagrant - Agile Testing Days ...
Infrastructure testing with Jenkins, Puppet and Vagrant - Agile Testing Days ...Carlos Sanchez
 
From Dev to DevOps
From Dev to DevOpsFrom Dev to DevOps
From Dev to DevOpsAgile Spain
 
From Dev to DevOps - ApacheCON NA 2011
From Dev to DevOps - ApacheCON NA 2011From Dev to DevOps - ApacheCON NA 2011
From Dev to DevOps - ApacheCON NA 2011Carlos Sanchez
 
20090514 Introducing Puppet To Sasag
20090514 Introducing Puppet To Sasag20090514 Introducing Puppet To Sasag
20090514 Introducing Puppet To Sasaggarrett honeycutt
 
Puppet: What _not_ to do
Puppet: What _not_ to doPuppet: What _not_ to do
Puppet: What _not_ to doPuppet
 
PuppetCamp Ghent - What Not to Do with Puppet
PuppetCamp Ghent - What Not to Do with PuppetPuppetCamp Ghent - What Not to Do with Puppet
PuppetCamp Ghent - What Not to Do with PuppetWalter Heck
 
PuppetCamp Ghent - What Not to Do with Puppet
PuppetCamp Ghent - What Not to Do with PuppetPuppetCamp Ghent - What Not to Do with Puppet
PuppetCamp Ghent - What Not to Do with PuppetOlinData
 
Writing and Publishing Puppet Modules - PuppetConf 2014
Writing and Publishing Puppet Modules - PuppetConf 2014Writing and Publishing Puppet Modules - PuppetConf 2014
Writing and Publishing Puppet Modules - PuppetConf 2014Puppet
 
DevOps Series: Extending vagrant with Puppet for configuration management
DevOps Series: Extending vagrant with Puppet for configuration managementDevOps Series: Extending vagrant with Puppet for configuration management
DevOps Series: Extending vagrant with Puppet for configuration managementFelipe
 
Developing IT infrastructures with Puppet
Developing IT infrastructures with PuppetDeveloping IT infrastructures with Puppet
Developing IT infrastructures with PuppetAlessandro Franceschi
 
Serving Moodle Presentation
Serving Moodle PresentationServing Moodle Presentation
Serving Moodle Presentationwebhostingguy
 
Getting Started with Ansible
Getting Started with AnsibleGetting Started with Ansible
Getting Started with Ansibleahamilton55
 
Provisioning with Puppet
Provisioning with PuppetProvisioning with Puppet
Provisioning with PuppetJoe Ray
 
A Presentation about Puppet that I've made at the OSSPAC conference
A Presentation about Puppet that I've made at the OSSPAC conferenceA Presentation about Puppet that I've made at the OSSPAC conference
A Presentation about Puppet that I've made at the OSSPAC conferenceohadlevy
 

Similar a Dance for the puppet master: G6 Tech Talk (20)

Puppet: Eclipsecon ALM 2013
Puppet: Eclipsecon ALM 2013Puppet: Eclipsecon ALM 2013
Puppet: Eclipsecon ALM 2013
 
From Dev to DevOps - Codemotion ES 2012
From Dev to DevOps - Codemotion ES 2012From Dev to DevOps - Codemotion ES 2012
From Dev to DevOps - Codemotion ES 2012
 
Puppet for Java developers - JavaZone NO 2012
Puppet for Java developers - JavaZone NO 2012Puppet for Java developers - JavaZone NO 2012
Puppet for Java developers - JavaZone NO 2012
 
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
 
From Dev to DevOps - FOSDEM 2012
From Dev to DevOps - FOSDEM 2012From Dev to DevOps - FOSDEM 2012
From Dev to DevOps - FOSDEM 2012
 
Infrastructure testing with Jenkins, Puppet and Vagrant - Agile Testing Days ...
Infrastructure testing with Jenkins, Puppet and Vagrant - Agile Testing Days ...Infrastructure testing with Jenkins, Puppet and Vagrant - Agile Testing Days ...
Infrastructure testing with Jenkins, Puppet and Vagrant - Agile Testing Days ...
 
Puppet
PuppetPuppet
Puppet
 
From Dev to DevOps
From Dev to DevOpsFrom Dev to DevOps
From Dev to DevOps
 
From Dev to DevOps - ApacheCON NA 2011
From Dev to DevOps - ApacheCON NA 2011From Dev to DevOps - ApacheCON NA 2011
From Dev to DevOps - ApacheCON NA 2011
 
20090514 Introducing Puppet To Sasag
20090514 Introducing Puppet To Sasag20090514 Introducing Puppet To Sasag
20090514 Introducing Puppet To Sasag
 
Puppet: What _not_ to do
Puppet: What _not_ to doPuppet: What _not_ to do
Puppet: What _not_ to do
 
PuppetCamp Ghent - What Not to Do with Puppet
PuppetCamp Ghent - What Not to Do with PuppetPuppetCamp Ghent - What Not to Do with Puppet
PuppetCamp Ghent - What Not to Do with Puppet
 
PuppetCamp Ghent - What Not to Do with Puppet
PuppetCamp Ghent - What Not to Do with PuppetPuppetCamp Ghent - What Not to Do with Puppet
PuppetCamp Ghent - What Not to Do with Puppet
 
Writing and Publishing Puppet Modules - PuppetConf 2014
Writing and Publishing Puppet Modules - PuppetConf 2014Writing and Publishing Puppet Modules - PuppetConf 2014
Writing and Publishing Puppet Modules - PuppetConf 2014
 
DevOps Series: Extending vagrant with Puppet for configuration management
DevOps Series: Extending vagrant with Puppet for configuration managementDevOps Series: Extending vagrant with Puppet for configuration management
DevOps Series: Extending vagrant with Puppet for configuration management
 
Developing IT infrastructures with Puppet
Developing IT infrastructures with PuppetDeveloping IT infrastructures with Puppet
Developing IT infrastructures with Puppet
 
Serving Moodle Presentation
Serving Moodle PresentationServing Moodle Presentation
Serving Moodle Presentation
 
Getting Started with Ansible
Getting Started with AnsibleGetting Started with Ansible
Getting Started with Ansible
 
Provisioning with Puppet
Provisioning with PuppetProvisioning with Puppet
Provisioning with Puppet
 
A Presentation about Puppet that I've made at the OSSPAC conference
A Presentation about Puppet that I've made at the OSSPAC conferenceA Presentation about Puppet that I've made at the OSSPAC conference
A Presentation about Puppet that I've made at the OSSPAC conference
 

Más de Michael Peacock

Immutable Infrastructure with Packer Ansible and Terraform
Immutable Infrastructure with Packer Ansible and TerraformImmutable Infrastructure with Packer Ansible and Terraform
Immutable Infrastructure with Packer Ansible and TerraformMichael Peacock
 
Test driven APIs with Laravel
Test driven APIs with LaravelTest driven APIs with Laravel
Test driven APIs with LaravelMichael Peacock
 
Symfony Workflow Component - Introductory Lightning Talk
Symfony Workflow Component - Introductory Lightning TalkSymfony Workflow Component - Introductory Lightning Talk
Symfony Workflow Component - Introductory Lightning TalkMichael Peacock
 
Alexa, lets make a skill
Alexa, lets make a skillAlexa, lets make a skill
Alexa, lets make a skillMichael Peacock
 
API Development with Laravel
API Development with LaravelAPI Development with Laravel
API Development with LaravelMichael Peacock
 
Refactoring to symfony components
Refactoring to symfony componentsRefactoring to symfony components
Refactoring to symfony componentsMichael Peacock
 
Introduction to OOP with PHP
Introduction to OOP with PHPIntroduction to OOP with PHP
Introduction to OOP with PHPMichael Peacock
 
Evolution of a big data project
Evolution of a big data projectEvolution of a big data project
Evolution of a big data projectMichael Peacock
 
Real time voice call integration - Confoo 2012
Real time voice call integration - Confoo 2012Real time voice call integration - Confoo 2012
Real time voice call integration - Confoo 2012Michael Peacock
 
Data at Scale - Michael Peacock, Cloud Connect 2012
Data at Scale - Michael Peacock, Cloud Connect 2012Data at Scale - Michael Peacock, Cloud Connect 2012
Data at Scale - Michael Peacock, Cloud Connect 2012Michael Peacock
 
PHP Continuous Data Processing
PHP Continuous Data ProcessingPHP Continuous Data Processing
PHP Continuous Data ProcessingMichael Peacock
 
PHP North East Registry Pattern
PHP North East Registry PatternPHP North East Registry Pattern
PHP North East Registry PatternMichael Peacock
 
PHP North East - Registry Design Pattern
PHP North East - Registry Design PatternPHP North East - Registry Design Pattern
PHP North East - Registry Design PatternMichael Peacock
 
Supermondays: Jenkins CI lightning talk
Supermondays: Jenkins CI lightning talkSupermondays: Jenkins CI lightning talk
Supermondays: Jenkins CI lightning talkMichael Peacock
 
Corporate Structures - September 2010
Corporate Structures - September 2010Corporate Structures - September 2010
Corporate Structures - September 2010Michael Peacock
 
PHP North-East - Automated Deployment
PHP North-East - Automated DeploymentPHP North-East - Automated Deployment
PHP North-East - Automated DeploymentMichael Peacock
 
Abstracting functionality with centralised content
Abstracting functionality with centralised contentAbstracting functionality with centralised content
Abstracting functionality with centralised contentMichael Peacock
 

Más de Michael Peacock (20)

Immutable Infrastructure with Packer Ansible and Terraform
Immutable Infrastructure with Packer Ansible and TerraformImmutable Infrastructure with Packer Ansible and Terraform
Immutable Infrastructure with Packer Ansible and Terraform
 
Test driven APIs with Laravel
Test driven APIs with LaravelTest driven APIs with Laravel
Test driven APIs with Laravel
 
Symfony Workflow Component - Introductory Lightning Talk
Symfony Workflow Component - Introductory Lightning TalkSymfony Workflow Component - Introductory Lightning Talk
Symfony Workflow Component - Introductory Lightning Talk
 
Alexa, lets make a skill
Alexa, lets make a skillAlexa, lets make a skill
Alexa, lets make a skill
 
API Development with Laravel
API Development with LaravelAPI Development with Laravel
API Development with Laravel
 
Refactoring to symfony components
Refactoring to symfony componentsRefactoring to symfony components
Refactoring to symfony components
 
Introduction to OOP with PHP
Introduction to OOP with PHPIntroduction to OOP with PHP
Introduction to OOP with PHP
 
Vagrant
VagrantVagrant
Vagrant
 
Evolution of a big data project
Evolution of a big data projectEvolution of a big data project
Evolution of a big data project
 
Real time voice call integration - Confoo 2012
Real time voice call integration - Confoo 2012Real time voice call integration - Confoo 2012
Real time voice call integration - Confoo 2012
 
Data at Scale - Michael Peacock, Cloud Connect 2012
Data at Scale - Michael Peacock, Cloud Connect 2012Data at Scale - Michael Peacock, Cloud Connect 2012
Data at Scale - Michael Peacock, Cloud Connect 2012
 
Supermondays twilio
Supermondays twilioSupermondays twilio
Supermondays twilio
 
PHP & Twilio
PHP & TwilioPHP & Twilio
PHP & Twilio
 
PHP Continuous Data Processing
PHP Continuous Data ProcessingPHP Continuous Data Processing
PHP Continuous Data Processing
 
PHP North East Registry Pattern
PHP North East Registry PatternPHP North East Registry Pattern
PHP North East Registry Pattern
 
PHP North East - Registry Design Pattern
PHP North East - Registry Design PatternPHP North East - Registry Design Pattern
PHP North East - Registry Design Pattern
 
Supermondays: Jenkins CI lightning talk
Supermondays: Jenkins CI lightning talkSupermondays: Jenkins CI lightning talk
Supermondays: Jenkins CI lightning talk
 
Corporate Structures - September 2010
Corporate Structures - September 2010Corporate Structures - September 2010
Corporate Structures - September 2010
 
PHP North-East - Automated Deployment
PHP North-East - Automated DeploymentPHP North-East - Automated Deployment
PHP North-East - Automated Deployment
 
Abstracting functionality with centralised content
Abstracting functionality with centralised contentAbstracting functionality with centralised content
Abstracting functionality with centralised content
 

Dance for the puppet master: G6 Tech Talk

  • 1. Dance for the puppet master An introduction to Puppet Michael Peacock
  • 2. So, what is puppet Provisioning tool “Open source configuration management tool” Used to automate server management Configuration Installs & upgrades etc
  • 3. Internal development team presentation Ground Six Limited
  • 4. Idempotent Can be ran multiple times without changing the server (unless the configuration changes) Instead of doing things, it checks or ensures things: Ensuring a package is installed only installs it if it hasn’t been installed. Execs only run if their create file isn’t found (and puppet doesn’t think they have been ran)
  • 5. Configuration within Vagrant Tell puppet to run Tell it where the manifests live Tell it the default manifest Tell it where modules live
  • 6. config.vm.provision :puppet do |puppet| puppet.manifests_path = "provision/manifests" puppet.manifest_file = "default.pp" puppet.module_path = "provision/modules" end
  • 7. What can it do? cron: install and manage cron jobs (scheduled_task on windows) exec: runs shall commands user: create and manage user accounts group: create and manage groups file: create and manage files, folders and symlinks notify: log something service: manage running services And more...the items in bold are known as resources within puppet
  • 8. Require Many / all puppet options support a “require” configuration Defines other puppet tasks which must have been successfully checked / executed before this can be ran We only want to install packages once we have updated aptitude We only want to install MySQL drivers once we have the MySQL client/server installed
  • 9. Require example require => [ Package['mysql-client'], Package['mysql-server'] ] notice when referencing other puppet configurations, the resource type is capitalised
  • 10. exec command: command (including full path unless path is also defined) to be executed. The “name” will be used if omitted user & group: to run the command as create: a file that the command creates. If found, the exec is not run cwd: directory to run the command from path: if full path for command isn’t supplied, path must point to location of the command
  • 11. exec: a note We create lock files in some of our exec commands to prevent repeated execution, e.g. after installing the default database, download something or run anything which can only be ran once.
  • 12. exec: example exec{ "create-db": command => '/bin/gunzip -c /vagrant/database/default.sql.gz > db.sql && /usr/bin/mysql < db.sql && /bin/rm db.sql && /bin/touch /vagrant/mysqlimport.lock', require => [ Package['mysql-client'], Package['mysql-server'] ], creates => "/vagrant/mysqlimport.lock", timeout => 0 }
  • 13. exec: another example exec{ "compose": command => '/bin/rm -rfv /vagrant/vendor/* && /bin/rm -f /vagrant/composer.lock && /usr/bin/curl -s http://getcomposer.org/installer | /usr/bin/php -- --install- dir=/vagrant && cd /vagrant && /usr/bin/php /vagrant/composer.phar install', require => [ Package['curl'], Package['git-core'] ], creates => "/vagrant/composer.lock", timeout => 0 }
  • 14. exec: what we use it for Installing the default MySQL database content Install pear projects Note: we should probably use or write a puppet module to install pear projects we need, our approach is a bit of a hack
  • 15. subscribe & refreshonly Some commands need to be ran periodically after other things have ran More so the case when puppet manages existing infrastructure (using it to manage whats already on a machine and installing new things) subscribe: defines other events which should cause the task to run (like require, but refreshes the task) refreshonly: instructs the task to only run when the other tasks are completed
  • 16. Installing software Package “type” We need to apt-get update first... We want to ensure some of our installed software is running
  • 17. Update aptitude exec { 'apt-get update': command => '/usr/bin/apt-get update', require => Exec['preparenetworking'], timeout => 0 }
  • 18. Install package We just need to ensure the package is present package { "apache2": ensure => present, require => Exec['apt-get update'] }
  • 19. Run the service service { "apache2": ensure => running, require => Package['apache2'] }
  • 20. Files ensure: type of file - symlink (link), directory target: for symlinks - set the target file source:file to be copied (if copying a file) owner: user who should own the file group: group associated with the file mode: file permissions e.g. 777
  • 21. file: copy apache config Set the source: source => ‘/path/to/file’ file { '/etc/apache2/sites-available/default': source => '/vagrant/provision/modules/apache/files/default', owner => 'root', group => 'root' }
  • 22. file: create a symlink ensure => ‘link’ file { '/var/www/vendor': ensure => 'link', target => '/vagrant/vendor', require => Package['apache2'] }
  • 23. file: create a folder ensure => ‘directory’ file{ "/var/www/uploads": ensure => "directory", owner => "www-data", group => "www-data", mode => 777, }
  • 24. file: create several folders $cache_directories = [ "/var/www/cache/", "/var/www/cache/pages", "/var/www/cache/routes", "/var/www/cache/templates", ] file { $cache_directories: ensure => "directory", owner => "www-data", group => "www-data", mode => 777, }
  • 25. Add a cron command: the command to run user: user to run the cron as hour, minute, month, monthday, weekday can be defined as hour => 1 or hour => [1,2,3,5] or hour => [1-10]
  • 26. Create a user user { "developer": ensure => "present", gid => "wheel", shell => "/bin/bash", home => "/home/developer", managehome => true, password => "passwordtest", require => Group["wheel"] }
  • 27. Create a group group { "wheel": ensure => "present", }
  • 28. Make the group a sudoer We probably want to stop this being ran multiple times! exec { "/bin/echo "%wheel ALL=(ALL) ALL" >> /etc/sudoers": require => Group["wheel"] }
  • 29. Stages Running things in a specific order can often be important Require often makes this easy for us, however Exec’s don’t seem to use this reliably We can define “stages” with a specific order. We can then put puppet modules into stages Default stage is Stage[main]
  • 30. Stages example stage { 'first': before => Stage[main] } class {'apache': stage => first}
  • 31. Importing modules Import the module (assuming it is in the right folder) Include the module to be executed import "apache" include apache