SlideShare a Scribd company logo
1 of 44
Download to read offline
Continuous Integration of Puppet
Code
@d2si
Who am I ?
2
Jack of all trades, I love challenges of any kind from motor sports to IT.
@fgouteroux
@d2si
Outline
Puppet Dev and Tests
State of the art
What's missing ?
Enters beaker
Principles and common use cases
Examples
Real use case testing with beaker
Simulate a true puppet deployment
Details and Setup
Integration in the dev workflow
@d2si
Tests
Why ?
Syntax error è Manifest does not compile
Duplicate resource è Dependency cycle
Forgetting to include a module or set a variable è puppet run fails
Result
The host fails to enforce the expected state
@d2si
State of the art
Writing tests is a good way to verify that your modules are
•  functional
•  reusable
Ensure the module does what you want it to do
@d2si
State of the art
Automated testing is one of the key ways to ensure that:
•  your libraries
•  your manifests
are meeting your expectations !
@d2si
State of the art
There are differents ways to test puppet manifests
Puppet-lint
•  Quick way to ensure that everybody is following a common set of conventions
•  Analyze your manifests and look for deviations from the Puppet style guide
@d2si
Puppet-lint
@d2si
State of the art
Puppet-rspec
•  Manifests and modules compile
•  Manifests contain the expected values
•  Specific types, classes or definitions are in the compiled catalog
•  Parameters match the expectations
@d2si
Puppet-Rspec
@d2si
State of the art
Puppet apply
•  Applies a standalone Puppet manifest to the local system
•  « Simulates » a catalog compilation with modulepath option
$ puppet apply -l /tmp/manifest.log manifest.pp
$ puppet apply --modulepath=/root/dev/modules -e "include ntpd::server"
$ puppet apply --catalog catalog.json
@d2si
It’s cool but, beakerful
You want to be sure that running Puppet on a host will:
•  build the host the way you want
•  have the behavior you expect
That means, verify services like:
•  SSH
•  Postgres
•  Nginx
are running and serving resources !
@d2si
What's missing ?
Testing entire systems:
1. Create virtual machines
2. Configure virtual machines
3. Deploy applications
4. Execute tests
5. Report on tests
6. Destroy virtual machines
6 5
4
3
1
2
@d2si
Enters Beaker
•  Open source acceptance testing tool
•  Built by Alice Nodelman (Puppet Labs)
•  Build test environments by vm provisionning
•  Multi-Cloud Providers (AWS, Google, Openstack)
•  Multi Virtualisation support (Docker, vSphere, Vagrant, Virtualbox)
•  Lifecycle management
•  First step for Continuous Integration
@d2si
Principles and common use cases
•  Tests are just Ruby files
•  Tests passed if no errors/exceptions
•  Tests use asserts to explicitly enforce a state
@d2si
Principles and common use cases
Let’s look at tests !
@d2si
Principles and common use cases
More examples !
@d2si
Simulate a true puppet deployment on AWS
Tasks:
1. Create 5 Virtual machines
2. Configure 4 Virtual machines
3. Deploy applications
4. Execute tests
5. Report tests
6. Destroy 5 Virtual machines
@d2si
TASK 1: Create VMs
How to reproduce this use case with beaker ?
@d2si
TASK 1: Create VMs
Create a file and describes your nodes:
@d2si
Beaker Roles
Each host in a host configuration file has one or more roles
Beaker natively supports the following roles:
•  master
•  agent
•  frictionless
•  dashboard
•  database
These roles indicate what Puppet responsibilities the host will assume.
If puppet is installed as part of the Beaker test execution then the roles will be
honored (ie, the host defined as master will become the puppet master node).
Other than puppet installation, the roles provide shortcuts to access nodes
@d2si
TASK 2: Configure VMs
@d2si
TASK 2: Configure VMs
Step 1: Bootstrap master node
•  Update package list
•  Install puppetmaster, ruby packages
•  Install/Configure Hiera
•  Install/Configure/Deploy r10k
•  Run puppet apply
Step 2: Bootstrap agent nodes
•  Update package list
•  Install curl, augeas packages
•  Push hostname and public IP to Consul KV
•  Install puppet agent
•  Set Default Puppet Environment
•  Run puppet agent
@d2si
r10k is a tool to help manage dynamic environments.
•  Creates new environments from git branches
•  Deploy modules to that environment.
R10K
@d2si
@d2si
beaker_helper.rb
@d2si
TASK 3: Deploy applications
@d2si
Puppet Stack – Roles/Profiles
From Craig Dunn: http://www.craigdunn.org/2012/05/239/
•  Nodes get a single role
•  Roles use several profiles
•  Profiles and Roles are Puppet modules
@d2si
Puppet Stack - Hiera
From Craig Dunn
•  Top down hierarchy for overriding configuration values based on
roles, environments…
•  Puppet modules without hard-coded data are easily shared and
more re-usable
•  Infrastructure configuration can be managed without needing to
edit Puppet code
Pluggable Backends:
•  Source data from multiple locations
•  Data source is abstracted from code
@d2si
Then it’s puppet job !
•  Puppet get the node’s role with the node’s name
•  Puppet apply the manifest according to the role
For front-server role, puppet need backends server infos like:
•  hostname
•  public IP
To get these infos, puppet call hiera consul backend.
TASK 3: Deploy applications
@d2si
front_server.pp
@d2si
apache_server.pp
@d2si
TASK 4: Execute Tests
@d2si
app_server.rb
@d2si
front_server.rb
@d2si
client.rb
@d2si
Task 5: Reporting
@d2si
@d2si
@d2si
Task 6: Destroy VMs
@d2si
Integration in the dev workflow
Developper update
a module
Trigger a hook
Run puppet-lint
Run puppet-rspec
Run integration tests
Merge dev to prod
(pipeline)
Run tests Play configuration
@d2si
Questions ?
@d2si
Go further
https://github.com/fgouteroux/demo-puppet-beaker
http://blog.d2-si.fr/2015/03/18/technique-puppet-beaker/
@d2si
Thank you !

More Related Content

What's hot

Continuous Delivery in Enterprise Environments using Docker, Ansible and Jenkins
Continuous Delivery in Enterprise Environments using Docker, Ansible and JenkinsContinuous Delivery in Enterprise Environments using Docker, Ansible and Jenkins
Continuous Delivery in Enterprise Environments using Docker, Ansible and Jenkins
Marcel Birkner
 

What's hot (20)

RunDeck
RunDeckRunDeck
RunDeck
 
DrupalCon Los Angeles - Continuous Integration Toolbox
DrupalCon Los Angeles - Continuous Integration ToolboxDrupalCon Los Angeles - Continuous Integration Toolbox
DrupalCon Los Angeles - Continuous Integration Toolbox
 
Володимир Дубенко "Node.js for desktop development (based on Electron library)"
Володимир Дубенко "Node.js for desktop development (based on Electron library)"Володимир Дубенко "Node.js for desktop development (based on Electron library)"
Володимир Дубенко "Node.js for desktop development (based on Electron library)"
 
Puppet Camp Sydney 2015: Puppet and AWS is easy right.....?
Puppet Camp Sydney 2015: Puppet and AWS is easy right.....? Puppet Camp Sydney 2015: Puppet and AWS is easy right.....?
Puppet Camp Sydney 2015: Puppet and AWS is easy right.....?
 
Minikube Workshop Handout
Minikube Workshop HandoutMinikube Workshop Handout
Minikube Workshop Handout
 
"Wix Serverless from inside", Mykola Borozdin
"Wix Serverless from inside", Mykola Borozdin"Wix Serverless from inside", Mykola Borozdin
"Wix Serverless from inside", Mykola Borozdin
 
Vagrant to-aws-flow
Vagrant to-aws-flowVagrant to-aws-flow
Vagrant to-aws-flow
 
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
 
MoldCamp - multidimentional testing workflow. CIBox.
MoldCamp  - multidimentional testing workflow. CIBox.MoldCamp  - multidimentional testing workflow. CIBox.
MoldCamp - multidimentional testing workflow. CIBox.
 
Drupal contrib module maintaining
Drupal contrib module maintainingDrupal contrib module maintaining
Drupal contrib module maintaining
 
Masterless puppet
Masterless puppetMasterless puppet
Masterless puppet
 
Puppetconf 2015 - Puppet Reporting with Elasticsearch Logstash and Kibana
Puppetconf 2015 - Puppet Reporting with Elasticsearch Logstash and KibanaPuppetconf 2015 - Puppet Reporting with Elasticsearch Logstash and Kibana
Puppetconf 2015 - Puppet Reporting with Elasticsearch Logstash and Kibana
 
Continuous Delivery in Enterprise Environments using Docker, Ansible and Jenkins
Continuous Delivery in Enterprise Environments using Docker, Ansible and JenkinsContinuous Delivery in Enterprise Environments using Docker, Ansible and Jenkins
Continuous Delivery in Enterprise Environments using Docker, Ansible and Jenkins
 
OMD and Check_mk
OMD and Check_mkOMD and Check_mk
OMD and Check_mk
 
Running at Scale: Practical Performance Tuning with Puppet - PuppetConf 2013
Running at Scale: Practical Performance Tuning with Puppet - PuppetConf 2013Running at Scale: Practical Performance Tuning with Puppet - PuppetConf 2013
Running at Scale: Practical Performance Tuning with Puppet - PuppetConf 2013
 
Pragmatic Monolith-First, easy to decompose, clean architecture
Pragmatic Monolith-First, easy to decompose, clean architecturePragmatic Monolith-First, easy to decompose, clean architecture
Pragmatic Monolith-First, easy to decompose, clean architecture
 
CIbox - OpenSource solution for making your #devops better
CIbox - OpenSource solution for making your #devops betterCIbox - OpenSource solution for making your #devops better
CIbox - OpenSource solution for making your #devops better
 
為 Node.js 專案打造專屬管家進行開發流程整合及健康檢測
為 Node.js 專案打造專屬管家進行開發流程整合及健康檢測為 Node.js 專案打造專屬管家進行開發流程整合及健康檢測
為 Node.js 專案打造專屬管家進行開發流程整合及健康檢測
 
Puppet Camp Chicago 2014: Running Multiple Puppet Masters (Beginner)
Puppet Camp Chicago 2014: Running Multiple Puppet Masters (Beginner) Puppet Camp Chicago 2014: Running Multiple Puppet Masters (Beginner)
Puppet Camp Chicago 2014: Running Multiple Puppet Masters (Beginner)
 
Queick: A Simple Job Queue System for Python
Queick: A Simple Job Queue System for PythonQueick: A Simple Job Queue System for Python
Queick: A Simple Job Queue System for Python
 

Similar to Puppet Camp Paris 2015: Continuous Integration of Puppet Code (Intermediate)

Similar to Puppet Camp Paris 2015: Continuous Integration of Puppet Code (Intermediate) (20)

Nagios Conference 2014 - Mike Merideth - The Art and Zen of Managing Nagios w...
Nagios Conference 2014 - Mike Merideth - The Art and Zen of Managing Nagios w...Nagios Conference 2014 - Mike Merideth - The Art and Zen of Managing Nagios w...
Nagios Conference 2014 - Mike Merideth - The Art and Zen of Managing Nagios w...
 
Puppet overview
Puppet overviewPuppet overview
Puppet overview
 
Puppet Camp New York 2014: Streamlining Puppet Development Workflow
Puppet Camp New York 2014: Streamlining Puppet Development Workflow Puppet Camp New York 2014: Streamlining Puppet Development Workflow
Puppet Camp New York 2014: Streamlining Puppet Development Workflow
 
Steamlining your puppet development workflow
Steamlining your puppet development workflowSteamlining your puppet development workflow
Steamlining your puppet development workflow
 
Building XWiki
Building XWikiBuilding XWiki
Building XWiki
 
DockerCon 15 Keynote - Day 2
DockerCon 15 Keynote - Day 2DockerCon 15 Keynote - Day 2
DockerCon 15 Keynote - Day 2
 
ContainerCon - Test Driven Infrastructure
ContainerCon - Test Driven InfrastructureContainerCon - Test Driven Infrastructure
ContainerCon - Test Driven Infrastructure
 
Keeping your Kubernetes Cluster Secure
Keeping your Kubernetes Cluster SecureKeeping your Kubernetes Cluster Secure
Keeping your Kubernetes Cluster Secure
 
Using Docker for Testing - Mukta
Using Docker for Testing - MuktaUsing Docker for Testing - Mukta
Using Docker for Testing - Mukta
 
Using Docker for Testing
Using Docker for TestingUsing Docker for Testing
Using Docker for Testing
 
Improving WordPress Development and Deployments with Docker
Improving WordPress Development and Deployments with DockerImproving WordPress Development and Deployments with Docker
Improving WordPress Development and Deployments with Docker
 
PuppetConf 2017: Puppet Development Kit: A Seamless Workflow for Module Devel...
PuppetConf 2017: Puppet Development Kit: A Seamless Workflow for Module Devel...PuppetConf 2017: Puppet Development Kit: A Seamless Workflow for Module Devel...
PuppetConf 2017: Puppet Development Kit: A Seamless Workflow for Module Devel...
 
Django and Docker
Django and DockerDjango and Docker
Django and Docker
 
Docker at Djangocon 2013 | Talk by Ken Cochrane
Docker at Djangocon 2013 | Talk by Ken CochraneDocker at Djangocon 2013 | Talk by Ken Cochrane
Docker at Djangocon 2013 | Talk by Ken Cochrane
 
Puppet and docker
Puppet and dockerPuppet and docker
Puppet and docker
 
Using the puppet debugger for lightweight exploration
Using the puppet debugger for lightweight explorationUsing the puppet debugger for lightweight exploration
Using the puppet debugger for lightweight exploration
 
CI/CD with Azure DevOps and Azure Databricks
CI/CD with Azure DevOps and Azure DatabricksCI/CD with Azure DevOps and Azure Databricks
CI/CD with Azure DevOps and Azure Databricks
 
Shipping NodeJS with Docker and CoreOS
Shipping NodeJS with Docker and CoreOSShipping NodeJS with Docker and CoreOS
Shipping NodeJS with Docker and CoreOS
 
DCEU 18: Building Your Development Pipeline
DCEU 18: Building Your Development PipelineDCEU 18: Building Your Development Pipeline
DCEU 18: Building Your Development Pipeline
 
Getting Started with Docker
Getting Started with DockerGetting Started with Docker
Getting Started with Docker
 

More from Puppet

Puppet camp2021 testing modules and controlrepo
Puppet camp2021 testing modules and controlrepoPuppet camp2021 testing modules and controlrepo
Puppet camp2021 testing modules and controlrepo
Puppet
 
2021 04-15 operational verification (with notes)
2021 04-15 operational verification (with notes)2021 04-15 operational verification (with notes)
2021 04-15 operational verification (with notes)
Puppet
 
Enforce compliance policy with model-driven automation
Enforce compliance policy with model-driven automationEnforce compliance policy with model-driven automation
Enforce compliance policy with model-driven automation
Puppet
 

More from Puppet (20)

Puppet camp2021 testing modules and controlrepo
Puppet camp2021 testing modules and controlrepoPuppet camp2021 testing modules and controlrepo
Puppet camp2021 testing modules and controlrepo
 
Puppetcamp r10kyaml
Puppetcamp r10kyamlPuppetcamp r10kyaml
Puppetcamp r10kyaml
 
2021 04-15 operational verification (with notes)
2021 04-15 operational verification (with notes)2021 04-15 operational verification (with notes)
2021 04-15 operational verification (with notes)
 
Puppet camp vscode
Puppet camp vscodePuppet camp vscode
Puppet camp vscode
 
Modules of the twenties
Modules of the twentiesModules of the twenties
Modules of the twenties
 
Applying Roles and Profiles method to compliance code
Applying Roles and Profiles method to compliance codeApplying Roles and Profiles method to compliance code
Applying Roles and Profiles method to compliance code
 
KGI compliance as-code approach
KGI compliance as-code approachKGI compliance as-code approach
KGI compliance as-code approach
 
Enforce compliance policy with model-driven automation
Enforce compliance policy with model-driven automationEnforce compliance policy with model-driven automation
Enforce compliance policy with model-driven automation
 
Keynote: Puppet camp compliance
Keynote: Puppet camp complianceKeynote: Puppet camp compliance
Keynote: Puppet camp compliance
 
Automating it management with Puppet + ServiceNow
Automating it management with Puppet + ServiceNowAutomating it management with Puppet + ServiceNow
Automating it management with Puppet + ServiceNow
 
Puppet: The best way to harden Windows
Puppet: The best way to harden WindowsPuppet: The best way to harden Windows
Puppet: The best way to harden Windows
 
Simplified Patch Management with Puppet - Oct. 2020
Simplified Patch Management with Puppet - Oct. 2020Simplified Patch Management with Puppet - Oct. 2020
Simplified Patch Management with Puppet - Oct. 2020
 
Accelerating azure adoption with puppet
Accelerating azure adoption with puppetAccelerating azure adoption with puppet
Accelerating azure adoption with puppet
 
Puppet catalog Diff; Raphael Pinson
Puppet catalog Diff; Raphael PinsonPuppet catalog Diff; Raphael Pinson
Puppet catalog Diff; Raphael Pinson
 
ServiceNow and Puppet- better together, Kevin Reeuwijk
ServiceNow and Puppet- better together, Kevin ReeuwijkServiceNow and Puppet- better together, Kevin Reeuwijk
ServiceNow and Puppet- better together, Kevin Reeuwijk
 
Take control of your dev ops dumping ground
Take control of your  dev ops dumping groundTake control of your  dev ops dumping ground
Take control of your dev ops dumping ground
 
100% Puppet Cloud Deployment of Legacy Software
100% Puppet Cloud Deployment of Legacy Software100% Puppet Cloud Deployment of Legacy Software
100% Puppet Cloud Deployment of Legacy Software
 
Puppet User Group
Puppet User GroupPuppet User Group
Puppet User Group
 
Continuous Compliance and DevSecOps
Continuous Compliance and DevSecOpsContinuous Compliance and DevSecOps
Continuous Compliance and DevSecOps
 
The Dynamic Duo of Puppet and Vault tame SSL Certificates, Nick Maludy
The Dynamic Duo of Puppet and Vault tame SSL Certificates, Nick MaludyThe Dynamic Duo of Puppet and Vault tame SSL Certificates, Nick Maludy
The Dynamic Duo of Puppet and Vault tame SSL Certificates, Nick Maludy
 

Puppet Camp Paris 2015: Continuous Integration of Puppet Code (Intermediate)

  • 2. @d2si Who am I ? 2 Jack of all trades, I love challenges of any kind from motor sports to IT. @fgouteroux
  • 3. @d2si Outline Puppet Dev and Tests State of the art What's missing ? Enters beaker Principles and common use cases Examples Real use case testing with beaker Simulate a true puppet deployment Details and Setup Integration in the dev workflow
  • 4. @d2si Tests Why ? Syntax error è Manifest does not compile Duplicate resource è Dependency cycle Forgetting to include a module or set a variable è puppet run fails Result The host fails to enforce the expected state
  • 5. @d2si State of the art Writing tests is a good way to verify that your modules are •  functional •  reusable Ensure the module does what you want it to do
  • 6. @d2si State of the art Automated testing is one of the key ways to ensure that: •  your libraries •  your manifests are meeting your expectations !
  • 7. @d2si State of the art There are differents ways to test puppet manifests Puppet-lint •  Quick way to ensure that everybody is following a common set of conventions •  Analyze your manifests and look for deviations from the Puppet style guide
  • 9. @d2si State of the art Puppet-rspec •  Manifests and modules compile •  Manifests contain the expected values •  Specific types, classes or definitions are in the compiled catalog •  Parameters match the expectations
  • 11. @d2si State of the art Puppet apply •  Applies a standalone Puppet manifest to the local system •  « Simulates » a catalog compilation with modulepath option $ puppet apply -l /tmp/manifest.log manifest.pp $ puppet apply --modulepath=/root/dev/modules -e "include ntpd::server" $ puppet apply --catalog catalog.json
  • 12. @d2si It’s cool but, beakerful You want to be sure that running Puppet on a host will: •  build the host the way you want •  have the behavior you expect That means, verify services like: •  SSH •  Postgres •  Nginx are running and serving resources !
  • 13. @d2si What's missing ? Testing entire systems: 1. Create virtual machines 2. Configure virtual machines 3. Deploy applications 4. Execute tests 5. Report on tests 6. Destroy virtual machines 6 5 4 3 1 2
  • 14. @d2si Enters Beaker •  Open source acceptance testing tool •  Built by Alice Nodelman (Puppet Labs) •  Build test environments by vm provisionning •  Multi-Cloud Providers (AWS, Google, Openstack) •  Multi Virtualisation support (Docker, vSphere, Vagrant, Virtualbox) •  Lifecycle management •  First step for Continuous Integration
  • 15. @d2si Principles and common use cases •  Tests are just Ruby files •  Tests passed if no errors/exceptions •  Tests use asserts to explicitly enforce a state
  • 16. @d2si Principles and common use cases Let’s look at tests !
  • 17. @d2si Principles and common use cases More examples !
  • 18. @d2si Simulate a true puppet deployment on AWS Tasks: 1. Create 5 Virtual machines 2. Configure 4 Virtual machines 3. Deploy applications 4. Execute tests 5. Report tests 6. Destroy 5 Virtual machines
  • 19. @d2si TASK 1: Create VMs How to reproduce this use case with beaker ?
  • 20. @d2si TASK 1: Create VMs Create a file and describes your nodes:
  • 21. @d2si Beaker Roles Each host in a host configuration file has one or more roles Beaker natively supports the following roles: •  master •  agent •  frictionless •  dashboard •  database These roles indicate what Puppet responsibilities the host will assume. If puppet is installed as part of the Beaker test execution then the roles will be honored (ie, the host defined as master will become the puppet master node). Other than puppet installation, the roles provide shortcuts to access nodes
  • 23. @d2si TASK 2: Configure VMs Step 1: Bootstrap master node •  Update package list •  Install puppetmaster, ruby packages •  Install/Configure Hiera •  Install/Configure/Deploy r10k •  Run puppet apply Step 2: Bootstrap agent nodes •  Update package list •  Install curl, augeas packages •  Push hostname and public IP to Consul KV •  Install puppet agent •  Set Default Puppet Environment •  Run puppet agent
  • 24. @d2si r10k is a tool to help manage dynamic environments. •  Creates new environments from git branches •  Deploy modules to that environment. R10K
  • 25. @d2si
  • 27. @d2si TASK 3: Deploy applications
  • 28. @d2si Puppet Stack – Roles/Profiles From Craig Dunn: http://www.craigdunn.org/2012/05/239/ •  Nodes get a single role •  Roles use several profiles •  Profiles and Roles are Puppet modules
  • 29. @d2si Puppet Stack - Hiera From Craig Dunn •  Top down hierarchy for overriding configuration values based on roles, environments… •  Puppet modules without hard-coded data are easily shared and more re-usable •  Infrastructure configuration can be managed without needing to edit Puppet code Pluggable Backends: •  Source data from multiple locations •  Data source is abstracted from code
  • 30. @d2si Then it’s puppet job ! •  Puppet get the node’s role with the node’s name •  Puppet apply the manifest according to the role For front-server role, puppet need backends server infos like: •  hostname •  public IP To get these infos, puppet call hiera consul backend. TASK 3: Deploy applications
  • 38. @d2si
  • 39. @d2si
  • 41. @d2si Integration in the dev workflow Developper update a module Trigger a hook Run puppet-lint Run puppet-rspec Run integration tests Merge dev to prod (pipeline) Run tests Play configuration