Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet...

53
Integrating the Cloud with Puppet Tuesday, February 26, 13

Transcript of Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet...

Page 1: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

Integrating the Cloud with Puppet

Tuesday, February 26, 13

Page 2: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

About me:

Dan BodeSome Dude at PuppetLabs

@bodepd

bodepd <on> freenode

Tuesday, February 26, 13

Page 3: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

Who is this talk for?

Cloud Users

Puppet beginners

Tuesday, February 26, 13

Page 4: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

It will cover

why integrate?

explanation of Puppet’s architecture as it applies to integration

using Puppet to model VM instances

Tuesday, February 26, 13

Page 5: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

Why Integrate?

Tuesday, February 26, 13

Page 6: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

Cloud

Provisions virtual machines

Self Service API

VM1

deployVirtualMachine

Tuesday, February 26, 13

Page 7: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

Puppet

VMs -> Applications

Self Service API

VM1

PuppetMaster

Here are yourinstructions

deployApacheServer

Make me anapache server

Tuesday, February 26, 13

Page 8: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

Together

PaaS

Self Service API

deployAppStack

Apache1 Apache2DB1 LB

Tuesday, February 26, 13

Page 9: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

Puppet

Tuesday, February 26, 13

Page 10: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

2 run modes

puppet apply

client/server

Tuesday, February 26, 13

Page 11: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

Puppet Client/Server

VM1

Master

Facts Catalog

ModulesClassifier

Tuesday, February 26, 13

Page 12: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

Facter

VM1

Master

Catalog

ModulesClassifier

Facts

Tuesday, February 26, 13

Page 13: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

Facter

$ facterarchitecture => x86_64domain => localfqdn => DansLapTop.localid => danbodeec2_instance_id => abc123abc123abc123operatingsystem => ‘Ubunbtu’osfamily => ‘Debian’.....

Tuesday, February 26, 13

Page 14: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

Facter

Available as top scope variables from manifests

ie : $::fact_name

Creating custom facts is easy.

Tuesday, February 26, 13

Page 15: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

Modules

VM1

Master

Facts Catalog

ClassifierModules

Tuesday, February 26, 13

Page 16: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

Modules

Sharable Puppet content

Tuesday, February 26, 13

Page 17: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

Module Forge

http://forge.puppetlabs.com/puppetlabs/apache

I get all of my content from the

forge!

Tuesday, February 26, 13

Page 18: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

Classes/defines compose resources

Tuesday, February 26, 13

Page 19: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

ResourcesDescribe the configuration state of individual system elements.

Tuesday, February 26, 13

Page 20: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

user { ‘dan’: # a user named dan ...

Tuesday, February 26, 13

Page 21: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

user { ‘dan’: # a user named dan ensure => present, # should exist ...

Tuesday, February 26, 13

Page 22: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

user { ‘dan’: # a user named dan ensure => present, # should exist shell => ‘/bin/bash’, # with this shell}

Tuesday, February 26, 13

Page 23: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

Puppet DSL and resources

Tuesday, February 26, 13

Page 24: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

Puppet DSL

Composes collections of resources.

Tuesday, February 26, 13

Page 25: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

Package/File/Service

class webserver { package { ‘apache2’: ... } file { ‘/etc/apache2/apache2.conf’: ... require => Package[‘apache2’], } service { ‘apache2’: ... subscribe => File[‘/etc/apache2/apache2.conf’] }}

Tuesday, February 26, 13

Page 26: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

configure a node

include webserver

Tuesday, February 26, 13

Page 27: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

Classification (maps roles as classes)

VM1

Master

Facts Catalog

ModulesClassifier

Tuesday, February 26, 13

Page 28: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

Site manifest

(/etc/puppet/manifests/site.pp)

Map a host’s certname to content from a module

node /^my_node/ { include apache }

Tuesday, February 26, 13

Page 29: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

ENC

The master can call out to arbitrary executables to figure out how a node should be classified.

Master

ENC

Tuesday, February 26, 13

Page 30: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

Puppet Client/Server

VM1

Master

Facts

ModulesClassifier

Catalog

Tuesday, February 26, 13

Page 31: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

Catalog

Package

Package

File

UserUserFile

ServiceService

Resources

Dependencies

Tuesday, February 26, 13

Page 32: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

Integrationis all about

Classification

Tuesday, February 26, 13

Page 33: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

Using metadata/userdata

Self Service API

VM1

deployApacheServer (with metadata=’puppet_class=apache’)

PuppetMaster

Tuesday, February 26, 13

Page 34: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

Using metadata/userdata

Self Service API

VM1

PuppetMaster

deployApacheServer (with metadata=’puppet_class=apache’)

I was provisionedwith metadatapuppet_class=apache

Tuesday, February 26, 13

Page 35: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

Using metadata/userdata

Self Service API

VM1

PuppetMaster

Oh cool!You must be anapache server

deployApacheServer (with metadata=’puppet_class=apache’)

I was provisionedwith metadatapuppet_class=apache

Tuesday, February 26, 13

Page 36: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

Determine role based on facts

deployVirtualMachine (with metadata)

Tuesday, February 26, 13

Page 37: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

Determine role based on facts

deployVirtualMachine (with metadata) populate facter metadata service

Tuesday, February 26, 13

Page 38: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

Determine role based on facts

node default { include $::meta_data_role}

deployVirtualMachine (with metadata) populate facter metadata service

use fact for classification

Tuesday, February 26, 13

Page 39: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

Pros

- simple

- classification information set during provisioning process

Tuesday, February 26, 13

Page 40: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

Cons

- hosts become authoritative over their role

- a single rooted host can pretend to be anyone else

- metadata/userdata is not always read/write

Tuesday, February 26, 13

Page 41: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

Using instance annotation data

Self Service API

VM1

PuppetMaster

Let me consultthe cloud system

deployApacheServer (with group=‘apache’)

here is my id

You were provisionedas an apache server

Tuesday, February 26, 13

Page 42: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

Using instance annotation data

Self Service API

VM1

deployApacheServer (with group=‘apache’)

Tuesday, February 26, 13

Page 43: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

Using instance annotation data

Self Service API

VM1

PuppetMaster

deployApacheServer (with group=‘apache’)

here is my id

Tuesday, February 26, 13

Page 44: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

Using instance annotation data

Self Service API

VM1

PuppetMaster

Let me lookup yourrole based on your id

deployApacheServer (with group=‘apache’)

here is my id

Tuesday, February 26, 13

Page 45: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

Using instance annotation data

Self Service API

VM1

PuppetMaster

deployApacheServer (with group=‘apache’)

here is my id

You were provisionedas an apache server

Let me lookup yourrole based on your id

Tuesday, February 26, 13

Page 46: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

Pros

- provisioning credentials are used to determine role

- annotation field likely updatable

Tuesday, February 26, 13

Page 47: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

Cons

- puppetmaster must have API credentials

- may require a custom ENC

Tuesday, February 26, 13

Page 48: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

Decouple role assignment from provisioningAfter provisioning is completed, ssh into a machine, set a custom fact (using facts.d), and trigger a puppet run.

pros - you can easily execute a script to install and bootstrap puppet

cons - extra step

Tuesday, February 26, 13

Page 49: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

facts.d

facts.d comes with stdlib (http://forge.puppetlabs.com/puppetlabs/stdlib)

it converts any ‘key=value’ pairs listed in /etc/facts.d/*.txt into facts

Tuesday, February 26, 13

Page 50: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

VM provisioning with Puppet (experimental! use cases appreciated)

Tuesday, February 26, 13

Page 51: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

Share Application Stacks as text

class my_app_stack { cloudstack_instance { 'foo4': ensure => present, group => 'role=db', }

cloudstack_instance { 'foo3': ensure => present, group => 'role=apache', }}

Tuesday, February 26, 13

Page 52: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

Use resource defaults for common settingsCloudstack_instance { image => 'CentOS 5.6 key+pass',

flavor => 'Small Instance', zone => 'ACS-FMT-001', network => 'puppetlabs-network', keypair => 'dans_keypair4',}

cloudstack_instance { 'foo4': ensure => $::ensure, group => 'role=db',}cloudstack_instance { 'foo3':

ensure => $::ensure, group => 'role=apache',}

Tuesday, February 26, 13

Page 53: Integrating the Cloud with Puppet - SCALE 18x | 18x › scale11x-supporting › ... · Puppet beginners Tuesday, February 26, 13. It will cover why integrate? explanation of Puppet’s

More issues of trust

Tuesday, February 26, 13