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

Cloud building talk

May 08, 2015

Download

Documents

bodepd
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Cloud building talk

Integrating the Cloud with Puppet

Tuesday, February 26, 13

Page 2: Cloud building talk

About me:

Dan BodeSome Dude at PuppetLabs

@bodepd

bodepd <on> freenode

Tuesday, February 26, 13

Page 3: Cloud building talk

Who is this talk for?

Cloud Users

Puppet beginners

Tuesday, February 26, 13

Page 4: Cloud building talk

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: Cloud building talk

Why Integrate?

Tuesday, February 26, 13

Page 6: Cloud building talk

Cloud

Provisions virtual machines

Self Service API

VM1

deployVirtualMachine

Tuesday, February 26, 13

Page 7: Cloud building talk

Puppet

VMs -> Applications

Self Service API

VM1

PuppetMaster

Here are yourinstructions

deployApacheServer

Make me anapache server

Tuesday, February 26, 13

Page 8: Cloud building talk

Together

PaaS

Self Service API

deployAppStack

Apache1 Apache2DB1 LB

Tuesday, February 26, 13

Page 9: Cloud building talk

Puppet

Tuesday, February 26, 13

Page 10: Cloud building talk

2 run modes

puppet apply

client/server

Tuesday, February 26, 13

Page 11: Cloud building talk

Puppet Client/Server

VM1

Master

Facts Catalog

ModulesClassifier

Tuesday, February 26, 13

Page 12: Cloud building talk

Facter

VM1

Master

Catalog

ModulesClassifier

Facts

Tuesday, February 26, 13

Page 13: Cloud building talk

Facter

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

Tuesday, February 26, 13

Page 14: Cloud building talk

Facter

Available as top scope variables from manifests

ie : $::fact_name

Creating custom facts is easy.

Tuesday, February 26, 13

Page 15: Cloud building talk

Modules

VM1

Master

Facts Catalog

ClassifierModules

Tuesday, February 26, 13

Page 16: Cloud building talk

Modules

Sharable Puppet content

Tuesday, February 26, 13

Page 17: Cloud building talk

Module Forge

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

I get all of my content from the

forge!

Tuesday, February 26, 13

Page 18: Cloud building talk

Classes/defines compose resources

Tuesday, February 26, 13

Page 19: Cloud building talk

ResourcesDescribe the configuration state of individual system elements.

Tuesday, February 26, 13

Page 20: Cloud building talk

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

Tuesday, February 26, 13

Page 21: Cloud building talk

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

Tuesday, February 26, 13

Page 22: Cloud building talk

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

Tuesday, February 26, 13

Page 23: Cloud building talk

Puppet DSL and resources

Tuesday, February 26, 13

Page 24: Cloud building talk

Puppet DSL

Composes collections of resources.

Tuesday, February 26, 13

Page 25: Cloud building talk

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: Cloud building talk

configure a node

include webserver

Tuesday, February 26, 13

Page 27: Cloud building talk

Classification (maps roles as classes)

VM1

Master

Facts Catalog

ModulesClassifier

Tuesday, February 26, 13

Page 28: Cloud building talk

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: Cloud building talk

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: Cloud building talk

Puppet Client/Server

VM1

Master

Facts

ModulesClassifier

Catalog

Tuesday, February 26, 13

Page 31: Cloud building talk

Catalog

Package

Package

File

UserUserFile

ServiceService

Resources

Dependencies

Tuesday, February 26, 13

Page 32: Cloud building talk

Integrationis all about

Classification

Tuesday, February 26, 13

Page 33: Cloud building talk

Using metadata/userdata

Self Service API

VM1

deployApacheServer (with metadata=’puppet_class=apache’)

PuppetMaster

Tuesday, February 26, 13

Page 34: Cloud building talk

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: Cloud building talk

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: Cloud building talk

Determine role based on facts

deployVirtualMachine (with metadata)

Tuesday, February 26, 13

Page 37: Cloud building talk

Determine role based on facts

deployVirtualMachine (with metadata) populate facter metadata service

Tuesday, February 26, 13

Page 38: Cloud building talk

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: Cloud building talk

Pros

- simple

- classification information set during provisioning process

Tuesday, February 26, 13

Page 40: Cloud building talk

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: Cloud building talk

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: Cloud building talk

Using instance annotation data

Self Service API

VM1

deployApacheServer (with group=‘apache’)

Tuesday, February 26, 13

Page 43: Cloud building talk

Using instance annotation data

Self Service API

VM1

PuppetMaster

deployApacheServer (with group=‘apache’)

here is my id

Tuesday, February 26, 13

Page 44: Cloud building talk

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: Cloud building talk

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: Cloud building talk

Pros

- provisioning credentials are used to determine role

- annotation field likely updatable

Tuesday, February 26, 13

Page 47: Cloud building talk

Cons

- puppetmaster must have API credentials

- may require a custom ENC

Tuesday, February 26, 13

Page 48: Cloud building talk

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: Cloud building talk

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: Cloud building talk

VM provisioning with Puppet (experimental! use cases appreciated)

Tuesday, February 26, 13

Page 51: Cloud building talk

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: Cloud building talk

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: Cloud building talk

More issues of trust

Tuesday, February 26, 13