Dev to Delivery with Puppet - PuppetConf 2014

44
DEV TO DELIVERY WITH PUPPET SAM BASHTON, BASHTON LTD

description

Dev to Delivery with Puppet - Sam Bashton, Bashton Ltd.

Transcript of Dev to Delivery with Puppet - PuppetConf 2014

Page 1: Dev to Delivery with Puppet - PuppetConf 2014

DEV TO DELIVERY WITHPUPPET

SAM BASHTON, BASHTON LTD

Page 2: Dev to Delivery with Puppet - PuppetConf 2014
Page 3: Dev to Delivery with Puppet - PuppetConf 2014
Page 4: Dev to Delivery with Puppet - PuppetConf 2014
Page 5: Dev to Delivery with Puppet - PuppetConf 2014

HOW DID WE GET HERE?Previously:

Devs built stuffLater, Ops came and built production infrastructure

This caused many IT problemsThe solution?

Page 6: Dev to Delivery with Puppet - PuppetConf 2014

OPSVELOPMENT

Page 7: Dev to Delivery with Puppet - PuppetConf 2014

DEVOPS

Page 8: Dev to Delivery with Puppet - PuppetConf 2014

WHAT IS DEVOPS REALLY?Devs doing Ops?Ops 'coding' infrastructure?Automating things?Word that recruiters use without understanding anythingabout it?

Page 9: Dev to Delivery with Puppet - PuppetConf 2014

WHAT IS DEVOPS?BE EXCELLENT TO EACH OTHER

Page 10: Dev to Delivery with Puppet - PuppetConf 2014

WHAT DOES THAT MEAN INPRACTICE?

Page 11: Dev to Delivery with Puppet - PuppetConf 2014

WHAT IS OPS?Working as part of a team to build a reliable environment

Page 12: Dev to Delivery with Puppet - PuppetConf 2014

WHAT IS DEV?Working as part of a team to build a reliable environment

Page 13: Dev to Delivery with Puppet - PuppetConf 2014

BEING GOOD AT DEVFollow 'The Twelve Factor App' - http://12factor.net/

Page 14: Dev to Delivery with Puppet - PuppetConf 2014

BEING GOOD AT OPSProvide consistency across all environments - includinglocal devProvide developers the means to understand what ishappeningProvide as much visibility of everything to everybody

Page 15: Dev to Delivery with Puppet - PuppetConf 2014

PEP20'Simple is better than complex''Complex is better than complicated'http://legacy.python.org/dev/peps/pep-0020/

Page 16: Dev to Delivery with Puppet - PuppetConf 2014

PROVIDING VISIBILITYAll infrastructure work (Puppet, CloudFormation, etc)should be checked in to a repository available to thewhole team (Devs + Ops)Make it easy to see and search logs from all environmentsGive as many people as possible access to these logs

Page 17: Dev to Delivery with Puppet - PuppetConf 2014

DEVELOPMENT

Page 18: Dev to Delivery with Puppet - PuppetConf 2014

WHAT AND WHY?Development environments need to match production asclosely as possibleBuilds confidence that something working in dev will workin production

Page 19: Dev to Delivery with Puppet - PuppetConf 2014

PUPPET EVERYWHEREPuppet should be used everywhere in the dev anddeployment process

ProductionStagingIntegration environmentsTest environmentsLocal dev machines

Page 20: Dev to Delivery with Puppet - PuppetConf 2014

PUPPET CONFIG DOGMAThe same Puppet manifests and modules should bedeployable to all environments without any modification

Page 21: Dev to Delivery with Puppet - PuppetConf 2014

PUPPET CONFIG DOGMAif statements in manifests are a 'bad smell' and should beavoided as much as possible

Page 22: Dev to Delivery with Puppet - PuppetConf 2014

PUPPET APPLICATIONCONFIG DOGMA

Separate config files per environment are a 'bad smell' tooAvoid manifests that look like below:

Make it easy to 'miss' replicating things betweenenvironments, or make mistakes

file { '/etc/nginx/nginx.conf': source => "puppet:///localmodules/data/nginx/${hostname}.conf",}

Page 23: Dev to Delivery with Puppet - PuppetConf 2014

VAGRANTBuilds virtual machines from Puppet manifestsMakes it easy to spin up short-lived dev instancesQuick to get working

Avoid ops being a blocker for dev

Page 24: Dev to Delivery with Puppet - PuppetConf 2014

VAGRANT + DOCKERReduce dev environment spin-up timeDocker makes it easier to create more realisticenvironmentsDocker images for drop-in use with Vagrant available: https://github.com/BashtonLtd/docker-vagrant-images

Page 25: Dev to Delivery with Puppet - PuppetConf 2014

BETTER MATCH LIVEENVIRONMENTS

Page 26: Dev to Delivery with Puppet - PuppetConf 2014

ONE SET OF MANIFESTS,MANY ENVIRONMENTS

Different environments need different configResource locationsSettings

Page 27: Dev to Delivery with Puppet - PuppetConf 2014

DEALING WITH DIFFERINGENVIRONMENTS

HieraAllows separation of logic from dataPut anything that differers by environment in a separatefileCombine with custom facts

Page 28: Dev to Delivery with Puppet - PuppetConf 2014

HIERA.YAML:hierarchy: - env/%{envname} - services/%{service} - common

Page 29: Dev to Delivery with Puppet - PuppetConf 2014

CUSTOM FACTS IN VAGRANT config.vm.provision :puppet do |puppet| puppet.manifests_path = "puppet/manifests" puppet.manifest_file = "site.pp" puppet.module_path = ["puppet/localmodules","puppet/modules"] puppet.hiera_config_path = "puppet/hiera.yaml" puppet.facter = { "envname" => "vagrant", "service" => "web", } end

Page 30: Dev to Delivery with Puppet - PuppetConf 2014

CUSTOM FACTS ON MACHINESDrop a file into /etc/facter/facts.d

service=webenvname=stage

Page 31: Dev to Delivery with Puppet - PuppetConf 2014

HIERA IN ACTIONenv/vagrant.yaml:

web::hostname: vagrantdev.local

env/stage.yaml:web::hostname: stage.example.com

Page 32: Dev to Delivery with Puppet - PuppetConf 2014

HIERA IN ACTIONcommon.yaml:

postfix::server::relayhost: '[mailtrap.io]:2525'

env/live.yaml:postfix::server::relayhost: 'email-smtp.eu-west-1.amazonaws.com:587'

Page 33: Dev to Delivery with Puppet - PuppetConf 2014

PRODUCTION

Page 34: Dev to Delivery with Puppet - PuppetConf 2014

'WORKED IN DEV'Devs and ops need the right data to be able to debugIf only ops have access the the data, how much can devsreally help?

Page 35: Dev to Delivery with Puppet - PuppetConf 2014

PROVIDING VISIBILITYMetrics and Service HealthLoggingDashboards

Page 36: Dev to Delivery with Puppet - PuppetConf 2014

METRICS AND SERVICEHEALTH

SensuHealth checksCollection of statistics and export to Graphite

Page 37: Dev to Delivery with Puppet - PuppetConf 2014

CENTRALISED LOGGINGVariety of approaches availableLogstashGraylog2

Page 38: Dev to Delivery with Puppet - PuppetConf 2014

GRAYLOG2Simple to get up and runningPuppet module available: https://forge.puppetlabs.com/graylog2/graylog2

Page 39: Dev to Delivery with Puppet - PuppetConf 2014
Page 40: Dev to Delivery with Puppet - PuppetConf 2014
Page 41: Dev to Delivery with Puppet - PuppetConf 2014

VISIBILITYDashboards show (near) realtime metrics let everyone seethe current state of the systemDon't just include system data - business metrics addcontext

Page 42: Dev to Delivery with Puppet - PuppetConf 2014
Page 43: Dev to Delivery with Puppet - PuppetConf 2014
Page 44: Dev to Delivery with Puppet - PuppetConf 2014