191
Islands

Islands: Puppet at Bulletproof Networks

Embed Size (px)

DESCRIPTION

Bulletproof Networks provides managed hosting services to some of the largest companies in Australia. Bulletproof implements strong isolation of customer environments, and this can present unique challenges when re-using Puppet code across our customer base. Additionally, the environments range in size from small to very large, and our tools + processes need to be able to handle both uses cases equally well.In this talk Lindsay + Mick will cover how Bulletproof's approach to these problems has evolved over the last 4 years, and some of the tools Bulletproof has developed and built upon to provide an awesome service to our customers.

Citation preview

Page 1: Islands: Puppet at Bulletproof Networks

Islands

Page 2: Islands: Puppet at Bulletproof Networks
Page 3: Islands: Puppet at Bulletproof Networks

Who are these guys?

Page 4: Islands: Puppet at Bulletproof Networks

Mick Pollard@aussielunix

&

Lindsay Holmwood@auxesis

Page 5: Islands: Puppet at Bulletproof Networks

Puppet users for > 5 years

Page 6: Islands: Puppet at Bulletproof Networks

BULLETPROOF

Page 7: Islands: Puppet at Bulletproof Networks

IaaS &Managed Services

Page 8: Islands: Puppet at Bulletproof Networks

Movember Australian Museum Rebel Group

Blackmores Angus & Robertson Telstra

Perisher BlueScope Steel Woolworths

DMG Radio Clive Peters Deloitte

Clemenger budget.gov.au Nissan

AOC Nova Sydney Airports

Whirlpool Smooth Theiss

Borders Fosters Country Road

Midas Australian Geographic Sensis

Tourism Victoria ABS AusPost

DET FWA Vodafone

Page 9: Islands: Puppet at Bulletproof Networks

Using Puppet since 2008

Page 10: Islands: Puppet at Bulletproof Networks
Page 11: Islands: Puppet at Bulletproof Networks

Unique challenges

Page 12: Islands: Puppet at Bulletproof Networks

Strong isolation

Page 13: Islands: Puppet at Bulletproof Networks

Network segregationwith VLANs

Page 14: Islands: Puppet at Bulletproof Networks

Central Puppetmasterisnʼt an option

Page 15: Islands: Puppet at Bulletproof Networks

Thorough change control

Page 16: Islands: Puppet at Bulletproof Networks

Rapid growth

Page 17: Islands: Puppet at Bulletproof Networks
Page 18: Islands: Puppet at Bulletproof Networks

How do we use Puppet?

Page 19: Islands: Puppet at Bulletproof Networks

Standalone systems

(puppetmaster-less)

Page 20: Islands: Puppet at Bulletproof Networks

Internal infrastructure

Page 21: Islands: Puppet at Bulletproof Networks

Full customer environments

Page 22: Islands: Puppet at Bulletproof Networks
Page 23: Islands: Puppet at Bulletproof Networks

Standalone systems

(puppetmaster-less)

Page 24: Islands: Puppet at Bulletproof Networks

Campaign driven

business

Page 25: Islands: Puppet at Bulletproof Networks

budget.gov.au

Page 26: Islands: Puppet at Bulletproof Networks

movember.com

Page 27: Islands: Puppet at Bulletproof Networks

mamamia.com.au

Page 28: Islands: Puppet at Bulletproof Networks

Reverseproxies

Page 29: Islands: Puppet at Bulletproof Networks

Nginxwith customisation

Page 30: Islands: Puppet at Bulletproof Networks

Rump

Page 31: Islands: Puppet at Bulletproof Networks

More detail in

John Ferlitoʼstalk at 14.00

Page 32: Islands: Puppet at Bulletproof Networks
Page 33: Islands: Puppet at Bulletproof Networks

Internal infrastructure

Page 34: Islands: Puppet at Bulletproof Networks

Vanilla

Page 35: Islands: Puppet at Bulletproof Networks

One Puppetmaster

Page 36: Islands: Puppet at Bulletproof Networks

Ubuntu(Lucid or Precise)

Page 37: Islands: Puppet at Bulletproof Networks
Page 38: Islands: Puppet at Bulletproof Networks

Full customer environments

Page 39: Islands: Puppet at Bulletproof Networks

Every customer has their own puppetmaster

Page 40: Islands: Puppet at Bulletproof Networks

“Islands of Puppet”

Page 41: Islands: Puppet at Bulletproof Networks

Copypasta

Page 42: Islands: Puppet at Bulletproof Networks

Configuration drift

Page 43: Islands: Puppet at Bulletproof Networks
Page 44: Islands: Puppet at Bulletproof Networks

apache

Page 45: Islands: Puppet at Bulletproof Networks

apache

Page 46: Islands: Puppet at Bulletproof Networks

apache

customer-a

Page 47: Islands: Puppet at Bulletproof Networks

apache

customer-a

Page 48: Islands: Puppet at Bulletproof Networks

apache

customer-a

customer-b

Page 49: Islands: Puppet at Bulletproof Networks

apache

customer-a

customer-b

Page 50: Islands: Puppet at Bulletproof Networks

apache

customer-a

customer-b

customer-c

Page 51: Islands: Puppet at Bulletproof Networks

apache

customer-a

customer-b

customer-c

Page 52: Islands: Puppet at Bulletproof Networks

apache

customer-a

customer-b

customer-c

customer-d

Page 53: Islands: Puppet at Bulletproof Networks
Page 54: Islands: Puppet at Bulletproof Networks

Poor code share

Page 55: Islands: Puppet at Bulletproof Networks

What if customers

edit the code?

Page 56: Islands: Puppet at Bulletproof Networks

How dowe maintain

common code?

Page 57: Islands: Puppet at Bulletproof Networks
Page 58: Islands: Puppet at Bulletproof Networks

Commonalities

Page 59: Islands: Puppet at Bulletproof Networks

Mix of Puppet

versions

Page 60: Islands: Puppet at Bulletproof Networks

0.25 (as provided by

Ubuntu)

Page 61: Islands: Puppet at Bulletproof Networks

2.7 (as provided by Puppet Labs)

Page 62: Islands: Puppet at Bulletproof Networks

Mix of Operating Systems

Page 63: Islands: Puppet at Bulletproof Networks

lucid precise

2.7 internal infrastructure some customers

0.25 most customers

Page 64: Islands: Puppet at Bulletproof Networks
Page 65: Islands: Puppet at Bulletproof Networks

Passenger > webrick

Page 66: Islands: Puppet at Bulletproof Networks

--no-daemonize

Page 67: Islands: Puppet at Bulletproof Networks

Default behaviour is orthogonal to

change control

Page 68: Islands: Puppet at Bulletproof Networks

We don't want systems to change

without control

Page 69: Islands: Puppet at Bulletproof Networks

All changes initiated byan engineer

Page 70: Islands: Puppet at Bulletproof Networks

nodes + roles

Page 71: Islands: Puppet at Bulletproof Networks

node 'stlyqy-lvs02.cust.bulletproof.net' { server { $fqdn: }

include snmp::server::lvs include sysctl::lvs

include keepalive::lvs

include network::conntrack::modules include network::conntrack::hashsize include network::bonding::activebackup include network::type::bonded_vlan

include ript}

Page 72: Islands: Puppet at Bulletproof Networks

node 'stlyqy-lvs02.cust.bulletproof.net' { server { $fqdn: }

include snmp::server::lvs include sysctl::lvs

include keepalive::lvs

include network::conntrack::modules include network::conntrack::hashsize include network::bonding::activebackup include network::type::bonded_vlan

include ript}

Page 73: Islands: Puppet at Bulletproof Networks

define server($collectd_client_report_to='collectd.bulletproof.net') { include motd include augeas include apt include utils include puppet::client

include ssh::server include ssh::authorized_keys include ntp::client include postfix::satellite

include ruby::dev include ruby::rubygems

include bzr::client include git::common include git::github

include snmp::server include vmware::tools

include apparmor::disable collectd::client { "${fqdn}": report_to => $collectd_client_report_to }}

Page 74: Islands: Puppet at Bulletproof Networks

app_serverdatabase_serverfile_servermanagement_servermemcache_servermonitor_serverproxy_serverpuppetmaster_serverredis_serversingle_serversphinx_serverstatic_server

Page 75: Islands: Puppet at Bulletproof Networks

Heira is the future

Page 76: Islands: Puppet at Bulletproof Networks
Page 77: Islands: Puppet at Bulletproof Networks

We useCapistrano

Page 78: Islands: Puppet at Bulletproof Networks

ssh in-a-parallel-for-loop

Page 79: Islands: Puppet at Bulletproof Networks

Why cap and not mcollective?

Page 80: Islands: Puppet at Bulletproof Networks

We deploy everything with cap

Page 81: Islands: Puppet at Bulletproof Networks

Monitoring configurationFirewall configuration

Web applicationsInternal tools

Page 82: Islands: Puppet at Bulletproof Networks

Consistent deployment tool across all projects

Page 83: Islands: Puppet at Bulletproof Networks

Principle of least surprise

Page 84: Islands: Puppet at Bulletproof Networks

Engineers learn1 tool

Page 85: Islands: Puppet at Bulletproof Networks

Puppet is no different to the

rest of our stack

Page 86: Islands: Puppet at Bulletproof Networks
Page 87: Islands: Puppet at Bulletproof Networks

How do we usecap + Puppet?

Page 88: Islands: Puppet at Bulletproof Networks

Puppet changes

Page 89: Islands: Puppet at Bulletproof Networks

cap puppet:go ROLES=lvs options="--noop"cap puppet:go ROLES=lvs

Page 90: Islands: Puppet at Bulletproof Networks
Page 91: Islands: Puppet at Bulletproof Networks

Smoke tests

Page 92: Islands: Puppet at Bulletproof Networks

$ cap puppet:go options="--noop"

# ...

infmon hosts serves a Nagios page over https

Finished in 1.67 seconds1 example, 0 failures

Page 93: Islands: Puppet at Bulletproof Networks

Works out all roles that hosts within a

run belong to

Page 94: Islands: Puppet at Bulletproof Networks

Runs tests tagged with those roles

Page 95: Islands: Puppet at Bulletproof Networks

Fast feedback on

change success

Page 96: Islands: Puppet at Bulletproof Networks
Page 97: Islands: Puppet at Bulletproof Networks

Bootstrapping

Page 98: Islands: Puppet at Bulletproof Networks

cap node:bootstrap HOSTFILTER=lvs-08.bp.net

Page 99: Islands: Puppet at Bulletproof Networks

Takes VM in unknown state

Page 100: Islands: Puppet at Bulletproof Networks

Brings into known state for Puppet 2.7 run

Page 101: Islands: Puppet at Bulletproof Networks
Page 102: Islands: Puppet at Bulletproof Networks

Limitations

Page 103: Islands: Puppet at Bulletproof Networks

Singling out hosts is tricky

Page 104: Islands: Puppet at Bulletproof Networks

Re-using data across commands

requires... creativity

Page 105: Islands: Puppet at Bulletproof Networks

servers = []

run "mysql -e \"SHOW MASTER STATUS;\" | tail -n 1" do |channel, type, data| hostname = channel[:host] filename = data.split(/\s+/).first position = data.split(/\s+/).last servers << { :hostname => hostname, :filename => filename, :position => position }end

Page 106: Islands: Puppet at Bulletproof Networks

ROLESand

HOSTFILTER

Page 107: Islands: Puppet at Bulletproof Networks
Page 108: Islands: Puppet at Bulletproof Networks

TLDR;

Page 109: Islands: Puppet at Bulletproof Networks

There are edge cases

Page 110: Islands: Puppet at Bulletproof Networks

It does the job

Page 111: Islands: Puppet at Bulletproof Networks
Page 112: Islands: Puppet at Bulletproof Networks

How have we tried to solve

them?

Page 113: Islands: Puppet at Bulletproof Networks

First iteration

Page 114: Islands: Puppet at Bulletproof Networks

Modules

Page 115: Islands: Puppet at Bulletproof Networks

modules/apache/

| manifests/init.pp

| files/

| templates/

| lib/

| README.markdown

Page 116: Islands: Puppet at Bulletproof Networks

Stored on GitHub

Page 117: Islands: Puppet at Bulletproof Networks

Drink from the firehose

Page 118: Islands: Puppet at Bulletproof Networks
Page 119: Islands: Puppet at Bulletproof Networks

puppet-module-tool

Page 120: Islands: Puppet at Bulletproof Networks

github.compuppetlabs/puppet-module-tool

Page 121: Islands: Puppet at Bulletproof Networks

gem install puppet-module

Page 122: Islands: Puppet at Bulletproof Networks

Modulefile

Page 123: Islands: Puppet at Bulletproof Networks

puppet-module build

Page 124: Islands: Puppet at Bulletproof Networks

Turns

Page 125: Islands: Puppet at Bulletproof Networks

modules/apache/

| manifests/init.pp

| files/

| templates/

| lib/

| README.markdown

Page 126: Islands: Puppet at Bulletproof Networks

into

Page 127: Islands: Puppet at Bulletproof Networks

bulletproofnetworks-apache-1.3.0.tar.gz

Page 128: Islands: Puppet at Bulletproof Networks

Puppet forge

Page 129: Islands: Puppet at Bulletproof Networks
Page 130: Islands: Puppet at Bulletproof Networks

Public by default

Page 131: Islands: Puppet at Bulletproof Networks

Not great if you don't want to open source all your secret sauce

Page 132: Islands: Puppet at Bulletproof Networks

But puppet-module-tool is interesting...

Page 133: Islands: Puppet at Bulletproof Networks

...can we fake the forge?

Page 134: Islands: Puppet at Bulletproof Networks
Page 135: Islands: Puppet at Bulletproof Networks

Pain points

Page 136: Islands: Puppet at Bulletproof Networks

Arduous release

workflow

Page 137: Islands: Puppet at Bulletproof Networks

Better suited for infrequent

changes

Page 138: Islands: Puppet at Bulletproof Networks

High barrier of entry for customers to submit patches

Page 139: Islands: Puppet at Bulletproof Networks

Sharing bugfixes & improvements

requires significant refactoring

Page 140: Islands: Puppet at Bulletproof Networks

Limited reporting on customer lag

Page 141: Islands: Puppet at Bulletproof Networks

Second iteration

Page 142: Islands: Puppet at Bulletproof Networks

Bundler

Page 143: Islands: Puppet at Bulletproof Networks
Page 144: Islands: Puppet at Bulletproof Networks

Gemfile

Page 145: Islands: Puppet at Bulletproof Networks

#!/usr/bin/env ruby

source :rubygems

gem 'capistrano', '2.9.0'gem 'capistrano-ext', '1.2.1'gem 'colorize'gem 'puppet', '2.7.13'gem 'puppet-module'

group :test do gem 'rspec', '2.8.0' gem 'mechanize' gem 'puppet-lint'end

Page 146: Islands: Puppet at Bulletproof Networks

Can we reuse it?

Page 147: Islands: Puppet at Bulletproof Networks

Tim Sharpe@ GitHub

(@rodjek)

Page 148: Islands: Puppet at Bulletproof Networks

Messy working prototype

Page 149: Islands: Puppet at Bulletproof Networks

pre-alpha quality

Page 150: Islands: Puppet at Bulletproof Networks

More research required

Page 151: Islands: Puppet at Bulletproof Networks

Librarian

Page 152: Islands: Puppet at Bulletproof Networks

“A framework for bundlers”

Page 153: Islands: Puppet at Bulletproof Networks

librarian-chefmanages Chef repositories

Page 154: Islands: Puppet at Bulletproof Networks

by Jay Feldblumgithub.com

applicationsonline/librarian

Page 155: Islands: Puppet at Bulletproof Networks
Page 156: Islands: Puppet at Bulletproof Networks

librarian-puppet

Page 157: Islands: Puppet at Bulletproof Networks

“You can all stop using git submodules now”

Page 158: Islands: Puppet at Bulletproof Networks

gem install librarian-puppet --pre

Page 159: Islands: Puppet at Bulletproof Networks

github.comrodjek/librarian-puppet

Page 160: Islands: Puppet at Bulletproof Networks

Bundler-like behavior

for Puppet

Page 161: Islands: Puppet at Bulletproof Networks

Puppetfile

Page 162: Islands: Puppet at Bulletproof Networks
Page 163: Islands: Puppet at Bulletproof Networks

#!/usr/bin/env ruby

forge "http://forge.puppetlabs.com"

mod "puppetlabs/razor"mod "puppetlabs/ntp", "0.0.3"

Page 164: Islands: Puppet at Bulletproof Networks

#!/usr/bin/env ruby

forge "http://forge.puppetlabs.com"

mod "puppetlabs/razor"mod "puppetlabs/ntp", "0.0.3"

mod "stdlib", :git => "git://github.com/puppetlabs/puppetlabs-stdlib.git"

Page 165: Islands: Puppet at Bulletproof Networks

#!/usr/bin/env ruby

forge "http://forge.puppetlabs.com"

mod "puppetlabs/razor"mod "puppetlabs/ntp", "0.0.3"

mod "apt", :git => "git://github.com/puppetlabs/puppetlabs-apt.git" :ref => 'feature/master/dans_refactor'

mod "stdlib", :git => "git://github.com/puppetlabs/puppetlabs-stdlib.git"

Page 166: Islands: Puppet at Bulletproof Networks

One canonical module

Page 167: Islands: Puppet at Bulletproof Networks

modules/ in

.gitignore

Page 168: Islands: Puppet at Bulletproof Networks

librarian-puppet outdated

tells you what needs to be updated

Page 169: Islands: Puppet at Bulletproof Networks

librarian-puppet update

updates your modules

Page 170: Islands: Puppet at Bulletproof Networks

Demo!http://aussielunix.github.com/jenkins-appliance/

Page 171: Islands: Puppet at Bulletproof Networks
Page 172: Islands: Puppet at Bulletproof Networks

Policy

Page 173: Islands: Puppet at Bulletproof Networks

Always use a module'smaster

Page 174: Islands: Puppet at Bulletproof Networks

Make changes to modules as

usual

Page 175: Islands: Puppet at Bulletproof Networks

git commit &&

git push the module

Page 176: Islands: Puppet at Bulletproof Networks

Make module changes generic

by default

Page 177: Islands: Puppet at Bulletproof Networks

Only branch a module when:

Page 178: Islands: Puppet at Bulletproof Networks

1. something is superclient specific

Page 179: Islands: Puppet at Bulletproof Networks

2. there is an unmissable deadline

Page 180: Islands: Puppet at Bulletproof Networks

3. testing ideas

Page 181: Islands: Puppet at Bulletproof Networks

Set a reminder to merge changes into

master

Page 182: Islands: Puppet at Bulletproof Networks

Use pull requests on GitHub for

dangerous changes

Page 183: Islands: Puppet at Bulletproof Networks
Page 184: Islands: Puppet at Bulletproof Networks

Take aways:

Page 185: Islands: Puppet at Bulletproof Networks

Puppet modulesare pretty neat

Page 186: Islands: Puppet at Bulletproof Networks

Keep feedback loops short

Page 187: Islands: Puppet at Bulletproof Networks

Code shareis king

Page 188: Islands: Puppet at Bulletproof Networks
Page 189: Islands: Puppet at Bulletproof Networks

Do you have similar

problems?

Page 190: Islands: Puppet at Bulletproof Networks

How do you solve them?

Page 191: Islands: Puppet at Bulletproof Networks

Thank you!