SlideShare a Scribd company logo
1 of 30
Download to read offline
Puppet Development Workflow
Bio - Jeff Smith
• Manager, Site Reliability Engineering
at Grubhub
• Puppet User for about 2 years
• Yes, we are also hiring.
• Yes, there is free food. Yes, it's totally
awesome to work here.
Email: jsmith@grubhub.com
Twitter: @DarkAndNerdy
Blog: http://www.allthingsdork.com
Agenda
• High level Environment Overview
• Local workstation setup
• How we solve problems
• Branching strategy
• Committing, Automated Testing and Publishing
Puppet Environment
Local Workstation Setup
Editor Setup
• VIM
• tmux
• Nerd Tree
• Powerline
Local Testing Tools
Listing tools can help you can syntax errors before you commit
code!
Local Linting Tools
• jsonlint
• puppet parser validate
• erb syntax checker
VIM Linting Function Example
function LintFile()
let l:currentfile = expand('%:p')
if &ft == 'puppet'
let l:command = "puppet-lint " . l:currentfile
elseif &ft == 'eruby.html'
let l:command = "erb -P -x -T '-' " . l:currentfile . "| ruby -c"
elseif &ft == 'json'
let l:command = 'jsonlint -q ' . l:currentfile
end
silent !clear
execute "!" . l:command . " " . bufname("%")
endfunction
map :call LintFile()
Guard
Guard is a command line tool to easily handle events on file
system modifications.
guard-puppet - A configuration of Guard geared towards
Puppet manifests and syntax.
Find more at https://github.com/johnbintz/guard-puppet
Vagrant Environment
It's easier to make changes locally then to a committed
repository. Use Vagrant for test VMs
• Puppet Master
• 2 Agents (only 1 started by default)
• Shares the puppet repo on the Host machine and uses that
as the module path in the VM
config.vm.define "master" do |master|
master.vm.box = "centos65-base-small"
if not ENV['PUPPETREPO'].nil?
puppet_path = ENV['PUPPETREPO']
else
puppet_path = ENV['HOME']+'/Development/puppet'
end
config.vm.synced_folder puppet_path, "/manifests", type: "nfs"
master.vm.network "private_network", ip: "172.16.1.10"
master.vm.network :forwarded_port, host: 10443, guest: 443
config.vm.hostname = "pe.local.vm"
master.vm.provision :hosts
config.pe_build.version = '3.3.2'
config.pe_build.download_root = 'http://s3.amazonaws.com/specialbuildbucket/'
master.vm.provision :hosts do |provisioner|
provisioner.add_host '172.16.1.11', ['agent.local.vm', 'agent']
provisioner.add_host '172.16.1.12', ['agent-2.local.vm', 'agent-2']
end
master.vm.provision :pe_bootstrap do |provisioner|
provisioner.role = :master
#provisioner.relocate_manifests = true
end
master.vm.provision :shell, inline: "service iptables stop;chkconfig --level 3 iptables off"
master.vm.provision :shell, path: 'bootstrap.sh'
end
How We Approach Development
Guiding Principles
• YAGNI - You Ain't Gonna Need It
• DRY - Don't Repeat Yourself
• Modules, Profiles, Roles
• Have respect for what you're doing
• Write your manifests in Puppet
You Ain't Gonna Need It
It's great to build your module to support CentOS, Ubuntu,
Solaris, AIX. But if your shop only has CentOS, has only ever
used CentOS and has plans to only use CentOS...........code for
CentOS.
• Adds too much time to development
• Complicates a potentially simple solution
• Not being tested in those environments so probably won't
work anyways
Don't Repeat Yourself
When you see the same piece of code showing up over and
over again, there's an opportunity.
• Limit the scope of where changes need to happen
• Compose your modules in a way that makes them reusable
• Hard-Coding is the devil
Modules, Profiles and Roles
Compose your Puppet manifests into 3 separate categories
• Modules - Contains the implementation details of a module.
Responsible for the plumbing.
• Profiles - Leverages modules to implement business logic.
Takes your "Apache" module and turns it into "Payroll_Web"
• Roles - Takes all of the profiles necessary to make a
complete system.
Only assign roles to a node and only 1 role per node
Have Respect for What You're Doing
YOU ARE PROGRAMMING
Write Your Manifests in Puppet
file { '/opt/app/config.ini':
ensure => file,
content => template('config.erb')
}
OR
payroll_config { 'database_connection':
property => 'dbserver',
value => 'dbserver1.example.com:3306'
}
Time to Write Some Code!
Puppet Forge is
Your Friend
• Someone has the same problem as
you
• More eyeballs on the same problem
• More flexible
• Less Work
Branching Strategy
Largely will depend on your environment. We have a single
Puppet repository for everything. (Don't do this)
3 Phases of Development
Local => Preprod => Production
Local Development
• Use Vagrant for test VMs
• Make all changes prior to commit
• Use linting
• Test using your local Puppet Master VM and Agent
• Set FACTS or variables via Custom Facts
Writing Test Cases
Be highly selective about what you test in Puppet.
Puppet Code
file { '/opt/app/config.ini':
ensure => file,
content => template('app/config.erb')
}
RSpec Puppet Test
it { should contain_file('/opt/app/config.ini) }
Puppet
Things To Test
1. File Syntax
2. Conditional Branches
3. Interpreted Values (e.g. RegEx evaluations, Facts)
4. Catalog Compilation
Getting Code to the Puppet
Master
• Work off a branch. Branch name should match your ticket
• Push your branch to the remote origin server
• Push your branch to the Pre-prod Puppet Master Remote
Repo (optional)
• Create a Pull Request from your branch, into the Develop
Branch
Branching Workflow Diagram
Automated Test Execution
CI Server watches master/develop branch. Executes tests on
change
1. Script executes to determine which files have changed
2. Linting is performed on changed files (if applicable)
3. Catalog compilation of changed manifests
4. Execution of manifests specific tests (if applicable)
5. Deployment of code to the Puppet Masters
Auto Deployment
Building Confidence
With enough confidence in the process you should be able to
• Deploy your changes to production after a commit and
successful automated testing
• Regular Puppet runs on production systems
• Iterate on changes faster
Move slowly. Go piece by piece. Every small step you take
adds value immediately. Bite off small bits.
Questions?

More Related Content

What's hot

Testing Ansible Infrastructure With Serverspec
Testing Ansible Infrastructure With ServerspecTesting Ansible Infrastructure With Serverspec
Testing Ansible Infrastructure With Serverspec
Benji Visser
 
Automate your Development Environment with Vagrant & Chef
Automate your Development Environment with Vagrant & ChefAutomate your Development Environment with Vagrant & Chef
Automate your Development Environment with Vagrant & Chef
Michael Lihs
 

What's hot (20)

Ansible and AWS
Ansible and AWSAnsible and AWS
Ansible and AWS
 
Vagrant and Chef on FOSSASIA 2014
Vagrant and Chef on FOSSASIA 2014Vagrant and Chef on FOSSASIA 2014
Vagrant and Chef on FOSSASIA 2014
 
infra-as-code
infra-as-codeinfra-as-code
infra-as-code
 
Go Faster with Ansible (PHP meetup)
Go Faster with Ansible (PHP meetup)Go Faster with Ansible (PHP meetup)
Go Faster with Ansible (PHP meetup)
 
Continuous Testing with Molecule, Ansible, and GitHub Actions
Continuous Testing with Molecule, Ansible, and GitHub ActionsContinuous Testing with Molecule, Ansible, and GitHub Actions
Continuous Testing with Molecule, Ansible, and GitHub Actions
 
Portland PUG April 2014: Beaker 101: Acceptance Test Everything
Portland PUG April 2014: Beaker 101: Acceptance Test EverythingPortland PUG April 2014: Beaker 101: Acceptance Test Everything
Portland PUG April 2014: Beaker 101: Acceptance Test Everything
 
Testing Ansible with Jenkins and Docker
Testing Ansible with Jenkins and DockerTesting Ansible with Jenkins and Docker
Testing Ansible with Jenkins and Docker
 
Testing Ansible Infrastructure With Serverspec
Testing Ansible Infrastructure With ServerspecTesting Ansible Infrastructure With Serverspec
Testing Ansible Infrastructure With Serverspec
 
Experiences from Running Masterless Puppet - PuppetConf 2014
Experiences from Running Masterless Puppet - PuppetConf 2014Experiences from Running Masterless Puppet - PuppetConf 2014
Experiences from Running Masterless Puppet - PuppetConf 2014
 
Ansible Best Practices - July 30
Ansible Best Practices - July 30Ansible Best Practices - July 30
Ansible Best Practices - July 30
 
Automate your Development Environment with Vagrant & Chef
Automate your Development Environment with Vagrant & ChefAutomate your Development Environment with Vagrant & Chef
Automate your Development Environment with Vagrant & Chef
 
Deploying PHP Applications with Ansible
Deploying PHP Applications with AnsibleDeploying PHP Applications with Ansible
Deploying PHP Applications with Ansible
 
Ansible module development 101
Ansible module development 101Ansible module development 101
Ansible module development 101
 
Docker
DockerDocker
Docker
 
Cyansible
CyansibleCyansible
Cyansible
 
Ansible: How to Get More Sleep and Require Less Coffee
Ansible: How to Get More Sleep and Require Less CoffeeAnsible: How to Get More Sleep and Require Less Coffee
Ansible: How to Get More Sleep and Require Less Coffee
 
Automated Deployment and Configuration Engines. Ansible
Automated Deployment and Configuration Engines. AnsibleAutomated Deployment and Configuration Engines. Ansible
Automated Deployment and Configuration Engines. Ansible
 
Take control of your Jenkins jobs via job DSL.
Take control of your Jenkins jobs via job DSL.Take control of your Jenkins jobs via job DSL.
Take control of your Jenkins jobs via job DSL.
 
Ansible Case Studies
Ansible Case StudiesAnsible Case Studies
Ansible Case Studies
 
Getting Started with Ansible
Getting Started with AnsibleGetting Started with Ansible
Getting Started with Ansible
 

Viewers also liked

Puppet Camp Atlanta 2014: Continuous Deployment of Puppet Modules
Puppet Camp Atlanta 2014: Continuous Deployment of Puppet ModulesPuppet Camp Atlanta 2014: Continuous Deployment of Puppet Modules
Puppet Camp Atlanta 2014: Continuous Deployment of Puppet Modules
Puppet
 
Puppet Conf 2012 - Managing Network Devices with Puppet
Puppet Conf 2012 - Managing Network Devices with PuppetPuppet Conf 2012 - Managing Network Devices with Puppet
Puppet Conf 2012 - Managing Network Devices with Puppet
Nan Liu
 

Viewers also liked (20)

Sense and Sensu-bility: Painless Metrics And Monitoring In The Cloud with Sensu
Sense and Sensu-bility: Painless Metrics And Monitoring In The Cloud with SensuSense and Sensu-bility: Painless Metrics And Monitoring In The Cloud with Sensu
Sense and Sensu-bility: Painless Metrics And Monitoring In The Cloud with Sensu
 
Puppet Camp Atlanta 2014: Continuous Deployment of Puppet Modules
Puppet Camp Atlanta 2014: Continuous Deployment of Puppet ModulesPuppet Camp Atlanta 2014: Continuous Deployment of Puppet Modules
Puppet Camp Atlanta 2014: Continuous Deployment of Puppet Modules
 
Puppet Camp Sydney 2015: The (Im)perfect Puppet Module
Puppet Camp Sydney 2015: The (Im)perfect Puppet ModulePuppet Camp Sydney 2015: The (Im)perfect Puppet Module
Puppet Camp Sydney 2015: The (Im)perfect Puppet Module
 
Using Vagrant, Puppet, Testing & Hadoop
Using Vagrant, Puppet, Testing & HadoopUsing Vagrant, Puppet, Testing & Hadoop
Using Vagrant, Puppet, Testing & Hadoop
 
Devops, Dungeons & Dragons
Devops, Dungeons & Dragons Devops, Dungeons & Dragons
Devops, Dungeons & Dragons
 
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
 
Puppet - Configuration Management Made Eas(ier)
Puppet - Configuration Management Made Eas(ier)Puppet - Configuration Management Made Eas(ier)
Puppet - Configuration Management Made Eas(ier)
 
Docker
Docker Docker
Docker
 
A Introduction of Packer
A Introduction of PackerA Introduction of Packer
A Introduction of Packer
 
Docker internals
Docker internalsDocker internals
Docker internals
 
EC2 AMI Factory with Chef, Berkshelf, and Packer
EC2 AMI Factory with Chef, Berkshelf, and PackerEC2 AMI Factory with Chef, Berkshelf, and Packer
EC2 AMI Factory with Chef, Berkshelf, and Packer
 
Packer, where DevOps begins
Packer, where DevOps beginsPacker, where DevOps begins
Packer, where DevOps begins
 
Usecase examples of Packer
Usecase examples of Packer Usecase examples of Packer
Usecase examples of Packer
 
Docker and Puppet for Continuous Integration
Docker and Puppet for Continuous IntegrationDocker and Puppet for Continuous Integration
Docker and Puppet for Continuous Integration
 
C#: Globalization and localization
C#: Globalization and localizationC#: Globalization and localization
C#: Globalization and localization
 
Connascence
ConnascenceConnascence
Connascence
 
Puppet Conf 2012 - Managing Network Devices with Puppet
Puppet Conf 2012 - Managing Network Devices with PuppetPuppet Conf 2012 - Managing Network Devices with Puppet
Puppet Conf 2012 - Managing Network Devices with Puppet
 
Deploying puppet code at light speed
Deploying puppet code at light speedDeploying puppet code at light speed
Deploying puppet code at light speed
 
Dates aghhhh!!?!?!?!
Dates aghhhh!!?!?!?!Dates aghhhh!!?!?!?!
Dates aghhhh!!?!?!?!
 
Docker Architecture (v1.3)
Docker Architecture (v1.3)Docker Architecture (v1.3)
Docker Architecture (v1.3)
 

Similar to Puppet Development Workflow

Similar to Puppet Development Workflow (20)

Scaling to-5000-nodes
Scaling to-5000-nodesScaling to-5000-nodes
Scaling to-5000-nodes
 
Puppet Camp New York 2015: Puppet Enterprise Scaling Lessons Learned (Interme...
Puppet Camp New York 2015: Puppet Enterprise Scaling Lessons Learned (Interme...Puppet Camp New York 2015: Puppet Enterprise Scaling Lessons Learned (Interme...
Puppet Camp New York 2015: Puppet Enterprise Scaling Lessons Learned (Interme...
 
Bootstrapping Puppet and Application Deployment - PuppetConf 2013
Bootstrapping Puppet and Application Deployment - PuppetConf 2013Bootstrapping Puppet and Application Deployment - PuppetConf 2013
Bootstrapping Puppet and Application Deployment - PuppetConf 2013
 
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
 
Our Puppet Story (Linuxtag 2014)
Our Puppet Story (Linuxtag 2014)Our Puppet Story (Linuxtag 2014)
Our Puppet Story (Linuxtag 2014)
 
Lessons Learnt in 2009
Lessons Learnt in 2009Lessons Learnt in 2009
Lessons Learnt in 2009
 
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
 
It Sounded Good on Paper - Lessons Learned with Puppet
It Sounded Good on Paper - Lessons Learned with PuppetIt Sounded Good on Paper - Lessons Learned with Puppet
It Sounded Good on Paper - Lessons Learned with Puppet
 
Continuous feature-development
Continuous feature-developmentContinuous feature-development
Continuous feature-development
 
Large-scaled Deploy Over 100 Servers in 3 Minutes
Large-scaled Deploy Over 100 Servers in 3 MinutesLarge-scaled Deploy Over 100 Servers in 3 Minutes
Large-scaled Deploy Over 100 Servers in 3 Minutes
 
Puppet Camp NYC 2014: Build a Modern Infrastructure in 45 min!
Puppet Camp NYC 2014: Build a Modern Infrastructure in 45 min!Puppet Camp NYC 2014: Build a Modern Infrastructure in 45 min!
Puppet Camp NYC 2014: Build a Modern Infrastructure in 45 min!
 
DCRUG: Achieving Development-Production Parity
DCRUG: Achieving Development-Production ParityDCRUG: Achieving Development-Production Parity
DCRUG: Achieving Development-Production Parity
 
Our Puppet Story (GUUG FFG 2015)
Our Puppet Story (GUUG FFG 2015)Our Puppet Story (GUUG FFG 2015)
Our Puppet Story (GUUG FFG 2015)
 
Toplog candy elves - HOCM Talk
Toplog candy elves - HOCM TalkToplog candy elves - HOCM Talk
Toplog candy elves - HOCM Talk
 
From SaltStack to Puppet and beyond...
From SaltStack to Puppet and beyond...From SaltStack to Puppet and beyond...
From SaltStack to Puppet and beyond...
 
Performance Tuning Your Puppet Infrastructure - PuppetConf 2014
Performance Tuning Your Puppet Infrastructure - PuppetConf 2014Performance Tuning Your Puppet Infrastructure - PuppetConf 2014
Performance Tuning Your Puppet Infrastructure - PuppetConf 2014
 
A Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy SystemA Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy System
 
Ansible top 10 - 2018
Ansible top 10 -  2018Ansible top 10 -  2018
Ansible top 10 - 2018
 
Puppet getting started by Dirk Götz
Puppet getting started by Dirk GötzPuppet getting started by Dirk Götz
Puppet getting started by Dirk Götz
 
TYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source Tools
TYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source ToolsTYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source Tools
TYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source Tools
 

More from Jeffery Smith

More from Jeffery Smith (8)

Cutting Costs in COVID-19
Cutting Costs in COVID-19Cutting Costs in COVID-19
Cutting Costs in COVID-19
 
Moving from ops to dev ops
Moving from ops to dev opsMoving from ops to dev ops
Moving from ops to dev ops
 
Making On-Call More Humane - Ignite Version
Making On-Call More Humane - Ignite VersionMaking On-Call More Humane - Ignite Version
Making On-Call More Humane - Ignite Version
 
Elevate Your Career as an Ops Engineer
Elevate Your Career as an Ops EngineerElevate Your Career as an Ops Engineer
Elevate Your Career as an Ops Engineer
 
Dungeons and dragons and dev ops
Dungeons and dragons and dev opsDungeons and dragons and dev ops
Dungeons and dragons and dev ops
 
DevOps: What's Buried in the Fine Print
DevOps: What's Buried in the Fine PrintDevOps: What's Buried in the Fine Print
DevOps: What's Buried in the Fine Print
 
Starting with c
Starting with cStarting with c
Starting with c
 
Brainstorming failure
Brainstorming failureBrainstorming failure
Brainstorming failure
 

Recently uploaded

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Recently uploaded (20)

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 

Puppet Development Workflow

  • 2. Bio - Jeff Smith • Manager, Site Reliability Engineering at Grubhub • Puppet User for about 2 years • Yes, we are also hiring. • Yes, there is free food. Yes, it's totally awesome to work here. Email: jsmith@grubhub.com Twitter: @DarkAndNerdy Blog: http://www.allthingsdork.com
  • 3. Agenda • High level Environment Overview • Local workstation setup • How we solve problems • Branching strategy • Committing, Automated Testing and Publishing
  • 5. Local Workstation Setup Editor Setup • VIM • tmux • Nerd Tree • Powerline
  • 6.
  • 7. Local Testing Tools Listing tools can help you can syntax errors before you commit code! Local Linting Tools • jsonlint • puppet parser validate • erb syntax checker
  • 8. VIM Linting Function Example function LintFile() let l:currentfile = expand('%:p') if &ft == 'puppet' let l:command = "puppet-lint " . l:currentfile elseif &ft == 'eruby.html' let l:command = "erb -P -x -T '-' " . l:currentfile . "| ruby -c" elseif &ft == 'json' let l:command = 'jsonlint -q ' . l:currentfile end silent !clear execute "!" . l:command . " " . bufname("%") endfunction map :call LintFile()
  • 9. Guard Guard is a command line tool to easily handle events on file system modifications. guard-puppet - A configuration of Guard geared towards Puppet manifests and syntax. Find more at https://github.com/johnbintz/guard-puppet
  • 10. Vagrant Environment It's easier to make changes locally then to a committed repository. Use Vagrant for test VMs • Puppet Master • 2 Agents (only 1 started by default) • Shares the puppet repo on the Host machine and uses that as the module path in the VM
  • 11. config.vm.define "master" do |master| master.vm.box = "centos65-base-small" if not ENV['PUPPETREPO'].nil? puppet_path = ENV['PUPPETREPO'] else puppet_path = ENV['HOME']+'/Development/puppet' end config.vm.synced_folder puppet_path, "/manifests", type: "nfs" master.vm.network "private_network", ip: "172.16.1.10" master.vm.network :forwarded_port, host: 10443, guest: 443 config.vm.hostname = "pe.local.vm" master.vm.provision :hosts config.pe_build.version = '3.3.2' config.pe_build.download_root = 'http://s3.amazonaws.com/specialbuildbucket/' master.vm.provision :hosts do |provisioner| provisioner.add_host '172.16.1.11', ['agent.local.vm', 'agent'] provisioner.add_host '172.16.1.12', ['agent-2.local.vm', 'agent-2'] end master.vm.provision :pe_bootstrap do |provisioner| provisioner.role = :master #provisioner.relocate_manifests = true end master.vm.provision :shell, inline: "service iptables stop;chkconfig --level 3 iptables off" master.vm.provision :shell, path: 'bootstrap.sh' end
  • 12. How We Approach Development Guiding Principles • YAGNI - You Ain't Gonna Need It • DRY - Don't Repeat Yourself • Modules, Profiles, Roles • Have respect for what you're doing • Write your manifests in Puppet
  • 13. You Ain't Gonna Need It It's great to build your module to support CentOS, Ubuntu, Solaris, AIX. But if your shop only has CentOS, has only ever used CentOS and has plans to only use CentOS...........code for CentOS. • Adds too much time to development • Complicates a potentially simple solution • Not being tested in those environments so probably won't work anyways
  • 14. Don't Repeat Yourself When you see the same piece of code showing up over and over again, there's an opportunity. • Limit the scope of where changes need to happen • Compose your modules in a way that makes them reusable • Hard-Coding is the devil
  • 15. Modules, Profiles and Roles Compose your Puppet manifests into 3 separate categories • Modules - Contains the implementation details of a module. Responsible for the plumbing. • Profiles - Leverages modules to implement business logic. Takes your "Apache" module and turns it into "Payroll_Web" • Roles - Takes all of the profiles necessary to make a complete system. Only assign roles to a node and only 1 role per node
  • 16. Have Respect for What You're Doing YOU ARE PROGRAMMING
  • 17. Write Your Manifests in Puppet file { '/opt/app/config.ini': ensure => file, content => template('config.erb') } OR payroll_config { 'database_connection': property => 'dbserver', value => 'dbserver1.example.com:3306' }
  • 18. Time to Write Some Code!
  • 19. Puppet Forge is Your Friend • Someone has the same problem as you • More eyeballs on the same problem • More flexible • Less Work
  • 20. Branching Strategy Largely will depend on your environment. We have a single Puppet repository for everything. (Don't do this) 3 Phases of Development Local => Preprod => Production
  • 21. Local Development • Use Vagrant for test VMs • Make all changes prior to commit • Use linting • Test using your local Puppet Master VM and Agent • Set FACTS or variables via Custom Facts
  • 22. Writing Test Cases Be highly selective about what you test in Puppet. Puppet Code file { '/opt/app/config.ini': ensure => file, content => template('app/config.erb') } RSpec Puppet Test it { should contain_file('/opt/app/config.ini) }
  • 24. Things To Test 1. File Syntax 2. Conditional Branches 3. Interpreted Values (e.g. RegEx evaluations, Facts) 4. Catalog Compilation
  • 25. Getting Code to the Puppet Master • Work off a branch. Branch name should match your ticket • Push your branch to the remote origin server • Push your branch to the Pre-prod Puppet Master Remote Repo (optional) • Create a Pull Request from your branch, into the Develop Branch
  • 27. Automated Test Execution CI Server watches master/develop branch. Executes tests on change 1. Script executes to determine which files have changed 2. Linting is performed on changed files (if applicable) 3. Catalog compilation of changed manifests 4. Execution of manifests specific tests (if applicable) 5. Deployment of code to the Puppet Masters
  • 29. Building Confidence With enough confidence in the process you should be able to • Deploy your changes to production after a commit and successful automated testing • Regular Puppet runs on production systems • Iterate on changes faster Move slowly. Go piece by piece. Every small step you take adds value immediately. Bite off small bits.