continuous deployment of puppet modules

44
CONTINUOUS DEPLOYMENT OF PUPPET MODULES HOW WE DO IT AT MAILCHIMP

Upload: william-oneill

Post on 12-Apr-2017

238 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: Continuous deployment of puppet modules

CONTINUOUSDEPLOYMENT OF PUPPET

MODULESHOW WE DO IT AT MAILCHIMP

Page 2: Continuous deployment of puppet modules

BILL O'NEILL@WONEILL

Page 3: Continuous deployment of puppet modules
Page 4: Continuous deployment of puppet modules

EMAIL SERVICE PROVIDERDeliver ~500 million emails daily723 million emails delivered on Cyber Monday

of 97Sender Scorehttp://delivery.mailchimp.com/

Page 5: Continuous deployment of puppet modules

HISTORY

Page 6: Continuous deployment of puppet modules

Image source: https://blog.engineyard.com/2014/con�gure-before-you-boot

Page 7: Continuous deployment of puppet modules

CONFIGURATION MANAGEMENT IS HARD"With Chef, Puppet, and CFEngine we found anot-insigni�cant learning curve on setting upthe different server daemons and learning theDSL. This was particularly challenging whenwe were con�guring unique software not yet

given recipes by the existing community.Given our cluster sizes, we also didn't really

need any of the advanced features thosesystems provided."

- README from internally built tool

Page 8: Continuous deployment of puppet modules

MOVE TO COLOCATIONBuy vs. Lease analogyGrow our Operations teamNeeded a tool with dry-run mode

Page 9: Continuous deployment of puppet modules

PEOPLE MAKE MISTAKES

Page 10: Continuous deployment of puppet modules

HOW DO WE CATCH THESE MISTAKES AS EARLYAS POSSIBLE?

AUTONOMATION"automation with a human touch"

1. Detect the abnormality2. Stop3. Fix or correct the immediate condition

Page 11: Continuous deployment of puppet modules

HOW DO WE CATCH THESE MISTAKES AS EARLYAS POSSIBLE?

DSL toolsEditor SupportSource Code ManagementContinuous Integration

Page 12: Continuous deployment of puppet modules

DSL TOOLSPuppetERBYAMLPuppet Style Guide

Page 13: Continuous deployment of puppet modules

PUPPETpuppet parser validate mymanifest.pp

Page 14: Continuous deployment of puppet modules

package { 'openssh-server': ensure => installed, }

file { '/etc/ssh/sshd_config': source => 'puppet:///modules/sshd/sshd_config', owner => 'root', group => 'root', mode => '640', notify => Service['sshd'] /* sshd will restart whenever you edit this file. */ require => Package['openssh-server'], }

service { 'sshd': ensure => running, enable => 'true', hasstatus => 'true', hasrestart => 'true', }

Page 15: Continuous deployment of puppet modules

$ puppet parser validate validate_1.pp Error: Could not parse for environment production: Syntax error at 'require'; expected '}' at validate_1.pp:12

Page 16: Continuous deployment of puppet modules

ERBerb -P -x -T '-' mytemplate.erb | ruby -c

Page 17: Continuous deployment of puppet modules

restrict default kod nomodify notrap nopeer<% unless @service %> noquery restrict 127.0.0.1 restrict -6 ::1

driftfile /var/lib/ntp/drift

<% @serverlist.sort.each do |server| -%>server <%= server %> iburst maxpoll 6 restrict <%= server %> mask 255.255.255.255 nomodify notrap noquery <% end -%>

Page 18: Continuous deployment of puppet modules

$ erb -P -x -T '-' broken-ntp.conf.erb | ruby -c -:11: syntax error, unexpected $end, expecting kEND

Page 19: Continuous deployment of puppet modules

YAMLnpm install -g js-yaml; js-yaml hiera.yaml

ruby -e "require 'yaml'; YAML.load_file('hiera.yaml')"

Page 20: Continuous deployment of puppet modules

--- ntp::servers: - 0.us.pool.ntp.org - 1.us.pool.ntp.org - 2.us.pool.ntp.org - 3.us.pool.ntp.org hp::ilo::settings: ssh_status type: global value: true ssh_port type: global value: '22' http_port type: global value: '80' https_port type: global value: '443'

Page 21: Continuous deployment of puppet modules

$ js-yaml hiera.yaml JS-YAML: bad indentation of a mapping entry at line 9, column 13: type: global ̂ $ ruby -e "require 'yaml'; YAML.load_file('hiera.yaml')" yaml.rb:133:in ̀load': syntax error on line 9, col 14: ̀ value: true' (ArgumentError) from yaml.rb:133:in ̀load' from yaml.rb:144:in ̀load_file' from yaml.rb:143:in ̀open' from yaml.rb:143:in ̀load_file' from -e:1

Page 22: Continuous deployment of puppet modules

PUPPET STYLE GUIDEhttps://docs.puppetlabs.com/guides/style_guide.htmlgem install puppet-lint

puppet-lint --fix /my/puppet/code

Page 23: Continuous deployment of puppet modules

package { 'openssh-server': ensure => installed, }

file { '/etc/ssh/sshd_config': source => 'puppet:///modules/sshd/sshd_config', owner => 'root', group => 'root', mode => '640', notify => Service['sshd'], /* sshd will restart whenever you edit this file. */ require => Package['openssh-server'], }

service { 'sshd': ensure => running, enable => 'true', hasstatus => 'true', hasrestart => 'true', }

Page 24: Continuous deployment of puppet modules

$ puppet-lint validate_2.pp WARNING: quoted boolean value found on line 16 WARNING: quoted boolean value found on line 17 WARNING: quoted boolean value found on line 18 WARNING: indentation of => is not properly aligned on line 6 WARNING: indentation of => is not properly aligned on line 7 WARNING: indentation of => is not properly aligned on line 8 WARNING: indentation of => is not properly aligned on line 9 WARNING: indentation of => is not properly aligned on line 10 WARNING: mode should be represented as a 4 digit octal value or symbolic mode on line 9 WARNING: /* */ comment found on line 10

Page 25: Continuous deployment of puppet modules

$ puppet-lint --fix validate_2.pp FIXED: quoted boolean value found on line 16 FIXED: quoted boolean value found on line 17 FIXED: quoted boolean value found on line 18 FIXED: indentation of => is not properly aligned on line 6 FIXED: indentation of => is not properly aligned on line 7 FIXED: indentation of => is not properly aligned on line 8 FIXED: indentation of => is not properly aligned on line 9 FIXED: indentation of => is not properly aligned on line 10 FIXED: mode should be represented as a 4 digit octal value or symbolic mode on line 9 FIXED: /* */ comment found on line 10

Page 26: Continuous deployment of puppet modules

package { 'openssh-server': ensure => installed, }

file { '/etc/ssh/sshd_config': source => 'puppet:///modules/sshd/sshd_config', owner => 'root', group => 'root', mode => '0640', notify => Service['sshd'], # sshd will restart whenever you # edit this file. require => Package['openssh-server'], }

service { 'sshd': ensure => running, enable => true, hasstatus => true, hasrestart => true, }

Page 27: Continuous deployment of puppet modules

--- validate_2.pp 2014-12-08 09:43:38.000000000 -0500 +++ validate_2.pp-fixed 2014-12-08 09:50:51.000000000 -0500 @@ -3,18 +3,18 @@ } file { '/etc/ssh/sshd_config': - source => 'puppet:///modules/sshd/sshd_config', - owner => 'root', - group => 'root', - mode => '640', - notify => Service['sshd'], /* sshd will restart whenever you - edit this file. */ + source => 'puppet:///modules/sshd/sshd_config', + owner => 'root', + group => 'root', + mode => '0640', + notify => Service['sshd'], # sshd will restart whenever you + # edit this file. require => Package['openssh-server'], } service { 'sshd': ensure => running, - enable => 'true',- hasstatus => 'true',- hasrestart => 'true',+ enable => true, + hasstatus => true, + hasrestart => true, }

Page 28: Continuous deployment of puppet modules

EDITOR SUPPORT

Page 30: Continuous deployment of puppet modules

EMACShttp://www.emacswiki.org/emacs/PuppetProgramming

Page 31: Continuous deployment of puppet modules

GEPPETTOhttp://puppetlabs.github.io/geppetto/index.html

Page 32: Continuous deployment of puppet modules

SOURCE CODEMANAGEMENT

Page 33: Continuous deployment of puppet modules

COMMIT HOOKSSCRIPT RUNNING THE DSL TOOLS AGAINST NEW FILES

Page 34: Continuous deployment of puppet modules

PEER REVIEW

Page 35: Continuous deployment of puppet modules
Page 36: Continuous deployment of puppet modules

TRUNK BASEDDEPLOYMENT

Page 37: Continuous deployment of puppet modules

CONTINUOUSINTEGRATION

Page 38: Continuous deployment of puppet modules

JENKINSHTTPS://GITHUB.COM/VSTONE/JENKINS-

PUPPET-SCRIPTS

Page 39: Continuous deployment of puppet modules

WHY NOT RSPEC ORBEAKER?

Page 40: Continuous deployment of puppet modules

CONTINUOUSDEPLOYMENT

Page 41: Continuous deployment of puppet modules

REMEMBER TRUNK BASEDDEPLOYMENT?

# Keep environment up-to-date vcsrepo { '/etc/puppet/environments/production': ensure => latest, provider => hg, source => 'https://localhost/mercurial/puppet-modules', }

Page 42: Continuous deployment of puppet modules

REVIEW TIME!Catch mistakes earlyAutomation with a human touchTrunk Based Deployments

Page 43: Continuous deployment of puppet modules

QUESTIONS?

Page 44: Continuous deployment of puppet modules

Slide sources at

THANKS!BILL O'NEILL

[email protected]@WONEILL

http://github.com/woneill/puppetcamp_atlanta_2014