Upgrade to Pro — share decks privately, control downloads, hide ads and more …

From Zero to Puppet - PuppetConf 2012

Server Density
September 27, 2012

From Zero to Puppet - PuppetConf 2012

Switching from nothing to everything in Puppet config management and how we use it for automating failover at Server Density.

Presented at http://puppetconf.com 2012 by Pedro Pessoa.

Video at https://www.youtube.com/watch?v=4fvFSzWEgvc

Server Density

September 27, 2012
Tweet

More Decks by Server Density

Other Decks in Technology

Transcript

  1. Servers HTTP Load Balancer – 5x Apache - 14x Build

    - 2x MongoDB - 19x data, 13x routing, 6x configuration, 6x arbiter,
  2. HTTP Load Balancer $globalIPs_array = split($globalIPs, ',') <% globalIPs_array.each do

    |globalIP| ­%> ListenHTTP # primary public IP address Address <%= globalIP %> Port 80
  3. file { 'vhost': path => "/etc/apache2/sites­enabled/${::siteDomain}", ensure => file, content

    => template('apache­php/vhost.erb'), notify => Service['apache2'], } Apache
  4. <VirtualHost *:80> ServerName <%= siteDomain %> DocumentRoot <%= documentRoot %>

    ... ErrorLog /var/log/apache2/error­<%= siteDomain %>.log <% if @requestLogging and requestLogging == "yes" %> CustomLog /var/log/apache2/access­<%= siteDomain %>.log vhost_combined <% end %> <% if enableSSL == "yes" %> <VirtualHost *:443> SSLEngine On SSLCertificateFile /var/www/ssl/<%= siteDomain %>.crt SSLCertificateKeyFile /var/www/ssl/<%= siteDomain %>.key ... Apache
  5. exec { 'ufw allow is­1': command => '/usr/sbin/ufw allow from

    184.173.178.67', unless => '/usr/sbin/ufw status verbose | grep "184.173.178.67"', } exec { 'ufw enable': command => '/usr/sbin/ufw enable', unless => '/usr/sbin/ufw status | grep "Status: active"', Require => [Exec['ufw allow is­1']], notify => Exec['ufw reload'], } exec { 'ufw reload': command => '/usr/sbin/ufw reload', require => Exec['ufw enable'], refreshonly => true, }
  6. SSH file { 'sshd_config': path => '/etc/ssh/sshd_config', ensure => file,

    content => template('sshd/sshd_config.erb'), } Port 22 Protocol 2 AllowUsers david pessoa chris rob wes Compression yes ... <% if @duoSecKey and @duoIntKey and @duoHost %> ForceCommand /usr/sbin/login_duo PermitTunnel no AllowTcpForwarding no <% end %>
  7. System updates CANARIES=" \ aws­prod­apac­singapore­exm­a1 \ a2.wdc.sl \ exm1.wdc.sl \

    mtx­web1.wdc.sl \ sdapp­web1.wdc.sl \ sdapi­web1.wdc.sl \ " function canaries { echo "REMOVE *­web1.wdc.sl FROM ROTATION!" echo "press ENTER" read echo "have you REALLY removed *­web1.wdc.sl from rotation?" echo "press ENTER" read for i in $CANARIES do echo $i mco rpc puppetral ­I $i create type=exec \ title="/bin/bash ­c 'apt­get dist­upgrade ­y'" done }
  8. System updates function reboot_canaries { echo "REMOVE *­web1.wdc.sl FROM ROTATION!"

    echo "press ENTER" read echo "have you REALLY removed *­web1.wdc.sl from rotation?" echo "press ENTER" read for i in $CANARIES do echo $i mco rpc puppetral ­I $i create type=exec \ title="/bin/bash ­c 'reboot'" echo "­­­­­­­­­­­­­­" done }
  9. What to Reboot mco rpc puppetral create type=exec \ title="/bin/bash

    ­c 'ls /var/run/reboot­required'" \ | grep ­B 1 "Resource was created" \ | grep ".sl" exm­md1a.wdc.sl Status: Resource was created Resource: {"tags"=>["exec"], "title"=>"/bin/bash ­c 'ls /var/run/reboot­required'", "type"=>"Exec", "parameters"=>{:returns=>:notrun}, "exported"=>false} exm1.wdc.sl Status: change from notrun to 0 failed: /bin/bash ­c 'ls /var/run/reboot­required' returned 2 instead of one of [0]
  10. Live Management - Emergency # Metrics <%= metricsIP %> metrics­svc

    # Infrastructure services 184.173.178.66 puppet ...