SlideShare a Scribd company logo
Extending Vagrant with
Puppet for Configuration
Management
30-40 minutes
Updated in July 2014 falmeida1988@gmail.com
What Vagrant is and what it isn’t
● Vagrant is a wrapper for Virtual Machine providers (VirtualBox, VMWare,
etc) .
● Vagrant can use provisioners, including shell scripts, puppet, chef and
others.
● Puppet (which we’ll cover here) is but one option of provisioners supported by
Vagrant; there are others like Chef, Ansible, Salt, etc.
● Vagrant is no configuration management tool.
What is Puppet and where does it fit in?
● Puppet can be seen series of system-level asserts. Puppet resources are
meant to be idempotent, i.e. stateless (just like HTTP).
● Puppet is a declarative language. In other words, it does not specify steps,
but states your system must be in.
● Couldn’t I just do everything Puppet does using shell provisioners?
○ Well, yeah but: You would have to write distribution-specific code for each
box (think apt-get vs yum, deb vs rpm, etc).
○ Things will quickly get messy if you need complex provisioning steps that
depend on each other, files to include, third-party modules, etc.
○ Your code would be order-dependent (stateful).
Manifest files - I
● These are the config files for Puppet: This is where you define resources
for your system.
● The main manifest file (entry script) must be pointed to in your
Vagrantfile
● Puppet is a Ruby-inspired DSL.
● Resources are not necessarily applied to the target system in the order
they are written in the manifests. If a resource must be applied before or
after some other resource, you must explicitly say so.
Manifest files - II
Example manifest file - Clone project rails/rails from github:
Exec {
path => [ "/bin/", "/sbin/" , "/usr/bin/", "/usr/sbin/","/usr/local/bin" ]
}
exec { 'sys_update':
command => 'apt-get update --fix-missing',
}
package { 'git-core':
require => Exec['sys_update'],
ensure => 'installed',
}
exec{ 'clone rails project':
command => 'git clone https://github.com/rails/rails.git',
cwd => '/home/foo/',
require => Package['git-core'],
}
define a command
install a package but only after system
update (this is the command you’ve
define above)
set defaults for a
resource (in this case,
default path for Execs)
clone a project using git
but first make sure the
git package is installed
Resources
● Resources are the basic building blocks in Puppet.
● Resources are state definitions. They are not commands that get run, but
assertions that get verified. They should not have side-effects.
● A resource looks like this:
type {'title':
attribute => 'value',
}
● Common resource types are Exec, Package, File and Service.
● Official docs entry for resources.
Resource types: Package I
● This resource type is used to assert that a package is in a given state.
● Attribute provider is used to define what kind of package will be used (it
defaults to your system’s default package manager but others can be
used, including things like pip, gem and npm.
● install a package using default provider (depending on your OS):
package {'apache2':
ensure => 'installed',
}
Resource types: Package II
● Making sure a pip package is updated:
package {'Django':
ensure => 'latest',
provider => 'pip',
}
More info: Puppet Docs for Package Resource
Resource types: Exec
● This resource type defines a shell command to be run in your virtual machine.
● The command must be idempotent or stateless: it should be able to run
multiple times with no errors. Use attributes like onlyif, unless and
creates to control when they run.
● example:
exec {'install chrome browser':
command => 'dpkg -i google-chrome-stable_current_i386.deb',
cwd => "/home/username/Downloads",
creates => "/usr/bin/google-chrome",
}
this command creates a
file, so Puppet knows it
shouldn’t be run if the
file already exists
Resource types: File
● It merely asserts that a file exists. So if it doesn’t exist, it is created; if it already
exists, nothing is done.
● Assert that a file exists and is owned by a given user:
file {'make sure my-file exists':
path => '/path/to/my-file',
ensure => 'present',
owner => 'johndoe',
}
Resource types: File II
● Make sure a directory exists and has given mode
file {'settings-directory',
ensure => 'directory',
path => '/path/to/settings-directory',
mode => 755,
recurse => true,
}
all child files will
have given
mode as well
Classes
● Just a simple way to group resources together, introducing modularization
and reuse:
class python {
package{'python-dev':
ensure => 'installed',
}
package{'python-pip':
ensure =>'installed',
require => Package['python-dev'],
}
}
include python
enforce ordering
between resources
don’t forget to
include what you
have defined
Heads-up
● In order to be able to launch 64-bit boxes, make sure you have
‘Virtualization Support’ enabled in your computer BIOS.
● You need to include all classes you want to be able to use, even though
they are not your ‘entry point’.
Links and References
● Latest Docs (version 3.6)
● Visual Index for all Syntax Elements in the Puppet DSL
● Resource types full reference.
● Wikipedia Article comparing Configuration Management engines

More Related Content

What's hot (19)

PDF
Puppet Camp Chicago 2014: Docker and Puppet: 1+1=3 (Intermediate)
Puppet
 
PDF
Configuration Surgery with Augeas
Puppet
 
PDF
Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...
Puppet
 
PDF
How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...
Puppet
 
PDF
Light my-fuse
Workhorse Computing
 
PPT
Subversion @ JUG Milano 11 dic 2009
Andrea Francia
 
PDF
Infrastructure Deployment with Docker & Ansible
Robert Reiz
 
PDF
Putting some "logic" in LVM.
Workhorse Computing
 
PDF
Node.js essentials
Bedis ElAchèche
 
PDF
SVN essentials
Bedis ElAchèche
 
PDF
Steam Learn: Composer
inovia
 
PDF
JavaCro'15 - Conquer the Internet of Things with Java and Docker - Johan Jans...
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
PDF
Docker / Ansible
Stephane Manciot
 
PDF
Vagrant are you still develop in a non-virtual environment-
Anatoly Bubenkov
 
PDF
Vagrant - Version control your dev environment
bocribbz
 
PDF
Dockerizing Symfony Applications - Symfony Live Berlin 2014
D
 
PDF
Puppet Camp Düsseldorf 2014: Continuously Deliver Your Puppet Code with Jenki...
Puppet
 
PDF
Docker deploy
Eric Ahn
 
PDF
Build and deployment
WO Community
 
Puppet Camp Chicago 2014: Docker and Puppet: 1+1=3 (Intermediate)
Puppet
 
Configuration Surgery with Augeas
Puppet
 
Building and Testing from Scratch a Puppet Environment with Docker - PuppetCo...
Puppet
 
How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...
Puppet
 
Light my-fuse
Workhorse Computing
 
Subversion @ JUG Milano 11 dic 2009
Andrea Francia
 
Infrastructure Deployment with Docker & Ansible
Robert Reiz
 
Putting some "logic" in LVM.
Workhorse Computing
 
Node.js essentials
Bedis ElAchèche
 
SVN essentials
Bedis ElAchèche
 
Steam Learn: Composer
inovia
 
JavaCro'15 - Conquer the Internet of Things with Java and Docker - Johan Jans...
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
Docker / Ansible
Stephane Manciot
 
Vagrant are you still develop in a non-virtual environment-
Anatoly Bubenkov
 
Vagrant - Version control your dev environment
bocribbz
 
Dockerizing Symfony Applications - Symfony Live Berlin 2014
D
 
Puppet Camp Düsseldorf 2014: Continuously Deliver Your Puppet Code with Jenki...
Puppet
 
Docker deploy
Eric Ahn
 
Build and deployment
WO Community
 

Similar to DevOps Series: Extending vagrant with Puppet for configuration management (20)

PPT
Dance for the puppet master: G6 Tech Talk
Michael Peacock
 
PDF
Our Puppet Story – Patterns and Learnings (sage@guug, March 2014)
DECK36
 
PDF
Security Testing Using Infrastructure-As-Code
Vision Concepts Infrastructure Services Solution
 
PDF
Intro to-puppet
F.L. Jonathan Araña Cruz
 
PPTX
Puppet
John Coggeshall
 
PDF
Puppet fundamentals
Murali Boyapati
 
PPTX
Puppet for Developers
sagarhere4u
 
KEY
Puppet for Java developers - JavaZone NO 2012
Carlos Sanchez
 
PPTX
Harmonious Development: Via Vagrant and Puppet
Achieve Internet
 
PDF
Puppet: From 0 to 100 in 30 minutes
Alessandro Franceschi
 
PDF
Our Puppet Story (Linuxtag 2014)
DECK36
 
PDF
20090514 Introducing Puppet To Sasag
garrett honeycutt
 
PDF
Puppet HackDay/BarCamp New Delhi Exercises
Julie Tsai
 
PPT
Puppet
csrocks
 
KEY
From Dev to DevOps - FOSDEM 2012
Carlos Sanchez
 
PDF
Puppet and Vagrant in development
Adam Culp
 
PDF
Using Puppet in Small Infrastructures
Rachel Andrew
 
PDF
Getting started with puppet and vagrant (1)
Puppet
 
ODP
Puppet slides for intelligrape
Sharad Aggarwal
 
PDF
Creating a mature puppet system
rkhatibi
 
Dance for the puppet master: G6 Tech Talk
Michael Peacock
 
Our Puppet Story – Patterns and Learnings (sage@guug, March 2014)
DECK36
 
Security Testing Using Infrastructure-As-Code
Vision Concepts Infrastructure Services Solution
 
Intro to-puppet
F.L. Jonathan Araña Cruz
 
Puppet fundamentals
Murali Boyapati
 
Puppet for Developers
sagarhere4u
 
Puppet for Java developers - JavaZone NO 2012
Carlos Sanchez
 
Harmonious Development: Via Vagrant and Puppet
Achieve Internet
 
Puppet: From 0 to 100 in 30 minutes
Alessandro Franceschi
 
Our Puppet Story (Linuxtag 2014)
DECK36
 
20090514 Introducing Puppet To Sasag
garrett honeycutt
 
Puppet HackDay/BarCamp New Delhi Exercises
Julie Tsai
 
Puppet
csrocks
 
From Dev to DevOps - FOSDEM 2012
Carlos Sanchez
 
Puppet and Vagrant in development
Adam Culp
 
Using Puppet in Small Infrastructures
Rachel Andrew
 
Getting started with puppet and vagrant (1)
Puppet
 
Puppet slides for intelligrape
Sharad Aggarwal
 
Creating a mature puppet system
rkhatibi
 
Ad

More from Felipe (19)

PDF
Aula rotulação automática - Automatic tagging
Felipe
 
PDF
First steps with Keras 2: A tutorial with Examples
Felipe
 
PDF
Word embeddings introdução, motivação e exemplos
Felipe
 
PDF
Cloud Certifications - Overview
Felipe
 
PDF
Elasticsearch for Data Analytics
Felipe
 
PDF
Cloudwatch: Monitoring your Services with Metrics and Alarms
Felipe
 
PDF
Cloudwatch: Monitoring your AWS services with Metrics and Alarms
Felipe
 
PDF
Online Machine Learning: introduction and examples
Felipe
 
PDF
Aws cost optimization: lessons learned, strategies, tips and tools
Felipe
 
PDF
Exemplos de uso de apache spark usando aws elastic map reduce
Felipe
 
PDF
Pré processamento de grandes dados com Apache Spark
Felipe
 
PDF
Hadoop MapReduce and Apache Spark on EMR: comparing performance for distribut...
Felipe
 
PDF
Boas práticas no desenvolvimento de software
Felipe
 
PDF
Rachinations
Felipe
 
PDF
Ausgewählte preußische Tugenden
Felipe
 
PDF
Short intro to scala and the play framework
Felipe
 
PDF
Conceitos e exemplos em versionamento de código
Felipe
 
PDF
DevOps Series: Defining and Sharing Testable Machine Configurations with vagrant
Felipe
 
PDF
D3.js 30-minute intro
Felipe
 
Aula rotulação automática - Automatic tagging
Felipe
 
First steps with Keras 2: A tutorial with Examples
Felipe
 
Word embeddings introdução, motivação e exemplos
Felipe
 
Cloud Certifications - Overview
Felipe
 
Elasticsearch for Data Analytics
Felipe
 
Cloudwatch: Monitoring your Services with Metrics and Alarms
Felipe
 
Cloudwatch: Monitoring your AWS services with Metrics and Alarms
Felipe
 
Online Machine Learning: introduction and examples
Felipe
 
Aws cost optimization: lessons learned, strategies, tips and tools
Felipe
 
Exemplos de uso de apache spark usando aws elastic map reduce
Felipe
 
Pré processamento de grandes dados com Apache Spark
Felipe
 
Hadoop MapReduce and Apache Spark on EMR: comparing performance for distribut...
Felipe
 
Boas práticas no desenvolvimento de software
Felipe
 
Rachinations
Felipe
 
Ausgewählte preußische Tugenden
Felipe
 
Short intro to scala and the play framework
Felipe
 
Conceitos e exemplos em versionamento de código
Felipe
 
DevOps Series: Defining and Sharing Testable Machine Configurations with vagrant
Felipe
 
D3.js 30-minute intro
Felipe
 
Ad

Recently uploaded (20)

PPTX
An Introduction to ZAP by Checkmarx - Official Version
Simon Bennetts
 
PPTX
The Role of a PHP Development Company in Modern Web Development
SEO Company for School in Delhi NCR
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PPTX
A Complete Guide to Salesforce SMS Integrations Build Scalable Messaging With...
360 SMS APP
 
PDF
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PPTX
Platform for Enterprise Solution - Java EE5
abhishekoza1981
 
PDF
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
PPTX
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
PPTX
How Apagen Empowered an EPC Company with Engineering ERP Software
SatishKumar2651
 
PDF
Executive Business Intelligence Dashboards
vandeslie24
 
PDF
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
PPTX
Engineering the Java Web Application (MVC)
abhishekoza1981
 
PPTX
Fundamentals_of_Microservices_Architecture.pptx
MuhammadUzair504018
 
PDF
Capcut Pro Crack For PC Latest Version {Fully Unlocked} 2025
hashhshs786
 
PPTX
Tally software_Introduction_Presentation
AditiBansal54083
 
PDF
Mobile CMMS Solutions Empowering the Frontline Workforce
CryotosCMMSSoftware
 
PDF
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
PPTX
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
PPTX
Revolutionizing Code Modernization with AI
KrzysztofKkol1
 
An Introduction to ZAP by Checkmarx - Official Version
Simon Bennetts
 
The Role of a PHP Development Company in Modern Web Development
SEO Company for School in Delhi NCR
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
A Complete Guide to Salesforce SMS Integrations Build Scalable Messaging With...
360 SMS APP
 
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
Platform for Enterprise Solution - Java EE5
abhishekoza1981
 
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
How Apagen Empowered an EPC Company with Engineering ERP Software
SatishKumar2651
 
Executive Business Intelligence Dashboards
vandeslie24
 
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
Engineering the Java Web Application (MVC)
abhishekoza1981
 
Fundamentals_of_Microservices_Architecture.pptx
MuhammadUzair504018
 
Capcut Pro Crack For PC Latest Version {Fully Unlocked} 2025
hashhshs786
 
Tally software_Introduction_Presentation
AditiBansal54083
 
Mobile CMMS Solutions Empowering the Frontline Workforce
CryotosCMMSSoftware
 
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
Revolutionizing Code Modernization with AI
KrzysztofKkol1
 

DevOps Series: Extending vagrant with Puppet for configuration management

  • 1. Extending Vagrant with Puppet for Configuration Management 30-40 minutes Updated in July 2014 [email protected]
  • 2. What Vagrant is and what it isn’t ● Vagrant is a wrapper for Virtual Machine providers (VirtualBox, VMWare, etc) . ● Vagrant can use provisioners, including shell scripts, puppet, chef and others. ● Puppet (which we’ll cover here) is but one option of provisioners supported by Vagrant; there are others like Chef, Ansible, Salt, etc. ● Vagrant is no configuration management tool.
  • 3. What is Puppet and where does it fit in? ● Puppet can be seen series of system-level asserts. Puppet resources are meant to be idempotent, i.e. stateless (just like HTTP). ● Puppet is a declarative language. In other words, it does not specify steps, but states your system must be in. ● Couldn’t I just do everything Puppet does using shell provisioners? ○ Well, yeah but: You would have to write distribution-specific code for each box (think apt-get vs yum, deb vs rpm, etc). ○ Things will quickly get messy if you need complex provisioning steps that depend on each other, files to include, third-party modules, etc. ○ Your code would be order-dependent (stateful).
  • 4. Manifest files - I ● These are the config files for Puppet: This is where you define resources for your system. ● The main manifest file (entry script) must be pointed to in your Vagrantfile ● Puppet is a Ruby-inspired DSL. ● Resources are not necessarily applied to the target system in the order they are written in the manifests. If a resource must be applied before or after some other resource, you must explicitly say so.
  • 5. Manifest files - II Example manifest file - Clone project rails/rails from github: Exec { path => [ "/bin/", "/sbin/" , "/usr/bin/", "/usr/sbin/","/usr/local/bin" ] } exec { 'sys_update': command => 'apt-get update --fix-missing', } package { 'git-core': require => Exec['sys_update'], ensure => 'installed', } exec{ 'clone rails project': command => 'git clone https://github.com/rails/rails.git', cwd => '/home/foo/', require => Package['git-core'], } define a command install a package but only after system update (this is the command you’ve define above) set defaults for a resource (in this case, default path for Execs) clone a project using git but first make sure the git package is installed
  • 6. Resources ● Resources are the basic building blocks in Puppet. ● Resources are state definitions. They are not commands that get run, but assertions that get verified. They should not have side-effects. ● A resource looks like this: type {'title': attribute => 'value', } ● Common resource types are Exec, Package, File and Service. ● Official docs entry for resources.
  • 7. Resource types: Package I ● This resource type is used to assert that a package is in a given state. ● Attribute provider is used to define what kind of package will be used (it defaults to your system’s default package manager but others can be used, including things like pip, gem and npm. ● install a package using default provider (depending on your OS): package {'apache2': ensure => 'installed', }
  • 8. Resource types: Package II ● Making sure a pip package is updated: package {'Django': ensure => 'latest', provider => 'pip', } More info: Puppet Docs for Package Resource
  • 9. Resource types: Exec ● This resource type defines a shell command to be run in your virtual machine. ● The command must be idempotent or stateless: it should be able to run multiple times with no errors. Use attributes like onlyif, unless and creates to control when they run. ● example: exec {'install chrome browser': command => 'dpkg -i google-chrome-stable_current_i386.deb', cwd => "/home/username/Downloads", creates => "/usr/bin/google-chrome", } this command creates a file, so Puppet knows it shouldn’t be run if the file already exists
  • 10. Resource types: File ● It merely asserts that a file exists. So if it doesn’t exist, it is created; if it already exists, nothing is done. ● Assert that a file exists and is owned by a given user: file {'make sure my-file exists': path => '/path/to/my-file', ensure => 'present', owner => 'johndoe', }
  • 11. Resource types: File II ● Make sure a directory exists and has given mode file {'settings-directory', ensure => 'directory', path => '/path/to/settings-directory', mode => 755, recurse => true, } all child files will have given mode as well
  • 12. Classes ● Just a simple way to group resources together, introducing modularization and reuse: class python { package{'python-dev': ensure => 'installed', } package{'python-pip': ensure =>'installed', require => Package['python-dev'], } } include python enforce ordering between resources don’t forget to include what you have defined
  • 13. Heads-up ● In order to be able to launch 64-bit boxes, make sure you have ‘Virtualization Support’ enabled in your computer BIOS. ● You need to include all classes you want to be able to use, even though they are not your ‘entry point’.
  • 14. Links and References ● Latest Docs (version 3.6) ● Visual Index for all Syntax Elements in the Puppet DSL ● Resource types full reference. ● Wikipedia Article comparing Configuration Management engines