cloudstack talk

40
Integrating CloudStack with Puppet Saturday, December 1, 12

Upload: bodepd

Post on 08-May-2015

889 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Cloudstack talk

Integrating CloudStack with Puppet

Saturday, December 1, 12

Page 2: Cloudstack talk

About me:

Dan BodeIntegration Specialist at PuppetLabs

@bodepd

bodepd <on> freenode

Saturday, December 1, 12

Page 3: Cloudstack talk

Who is this talk for?

current CloudStack Users

Puppet beginners

Saturday, December 1, 12

Page 4: Cloudstack talk

It will cover

why integrate?

explanation of Puppet’s architecture as it applies to integration

using Puppet to model VM instances

Saturday, December 1, 12

Page 5: Cloudstack talk

Why Integrate?

Saturday, December 1, 12

Page 6: Cloudstack talk

Why integrate?

CloudStack provides an API for provisioning virtual machines

Self Service API

VM1

deployVirtualMachine

Saturday, December 1, 12

Page 7: Cloudstack talk

Why integrate?

Puppet converts freshly provisioned VMs into functional applications

Self Service APi

VM1

PuppetMaster

Make me anapache server

Here are theinstructions forbecoming anapache server

Saturday, December 1, 12

Page 8: Cloudstack talk

Why integrate?

Combined, they create fully automated application stacks.

Self Service APi

Apache1

deploy me a DB,then 2 apache servers

Apache2DB1

Saturday, December 1, 12

Page 9: Cloudstack talk

UnderstandingPuppet

Saturday, December 1, 12

Page 10: Cloudstack talk

2 run modes

puppet apply - all content is stored on the individual nodes. commonly used for testing (or for scale)

client/server - content is served from a central master (this is what we will be talking about)

Saturday, December 1, 12

Page 11: Cloudstack talk

A Puppet client/server run

VM1

Master

Facts Catalog

ModulesClassifier

Saturday, December 1, 12

Page 12: Cloudstack talk

Facter returns system specificinformation

Agent

Master

Facts Catalog

ModulesClassifier

Saturday, December 1, 12

Page 13: Cloudstack talk

Facter

to see a system’s facts, run

$ facterarchitecture => x86_64domain => localfacterversion => 2.0.0fqdn => DansLapTop.localhardwareisa => i386hardwaremodel => x86_64id => danbode

Saturday, December 1, 12

Page 14: Cloudstack talk

Facter

Nodes submit their facts as a part of the request for catalog.

Available as top scope variables from manifests

ie : $::fact_name

Creating custom facts is easy.

Saturday, December 1, 12

Page 15: Cloudstack talk

A Puppet client/server run

VM1

Master

Facts Catalog

ModulesClassifier

Saturday, December 1, 12

Page 16: Cloudstack talk

Modules

Sharable content composed of classes and defined resource types (configuration interfaces).

Saturday, December 1, 12

Page 17: Cloudstack talk

Module Forge

http://forge.puppetlabs.com/

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

Saturday, December 1, 12

Page 18: Cloudstack talk

Classes/defines compose resources

Saturday, December 1, 12

Page 19: Cloudstack talk

Resources

Describe the configuration state of individual system elements.

user { ‘dan’: ensure => present, shell => ‘/bin/bash’, }

Saturday, December 1, 12

Page 20: Cloudstack talk

Resources

Describe the configuration state of individual system elements.

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

Saturday, December 1, 12

Page 21: Cloudstack talk

Resources

package { ‘apache2’: # a package named apache2 ensure => present, # should be installed }

Saturday, December 1, 12

Page 22: Cloudstack talk

Puppet DSL and resources

Saturday, December 1, 12

Page 23: Cloudstack talk

Puppet DSL and Resources

The Puppet DSL can be used to compose collections of resources into classes or defined resources.

Saturday, December 1, 12

Page 24: Cloudstack talk

Example apache class

class apache { package { ‘apache2’: ensure => present, } file { ‘/etc/apache2/apache2.conf’: content => template(‘apache2/apache2.erb’), require => Package[‘apache2’], } service { ‘apache2’: ensure => running subscribe => File[‘/etc/apache2/apache2.conf’] }}

Saturday, December 1, 12

Page 25: Cloudstack talk

A Puppet client/server run

VM1

Master

Facts Catalog

ModulesClassifier

Saturday, December 1, 12

Page 26: Cloudstack talk

Classification

Process that determines how Puppet maps a role to a specific instance.

Saturday, December 1, 12

Page 27: Cloudstack talk

Site manifest

The master utilizes code from its site manifest to figure out how to assign a role to a node.

Master/etc/puppet/manifest/site.pp

Saturday, December 1, 12

Page 28: Cloudstack talk

Site manifest

Node blocks map a host’s certname to content from a module

node /^my_node/ { include apache }

Saturday, December 1, 12

Page 29: Cloudstack talk

Determine role based on facts

Self Service APi

Apache1

deploy me an apache server

Saturday, December 1, 12

Page 30: Cloudstack talk

Determine role based on facts

‘deployVirtualMachine’ -> userdata -> facts

node default { if $::role == ‘apache’ { include apache } else { fail(“Undefine role: ${role}”) }}

Saturday, December 1, 12

Page 31: Cloudstack 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

Saturday, December 1, 12

Page 32: Cloudstack 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

Saturday, December 1, 12

Page 33: Cloudstack talk

ENC

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

Master

ENC

Saturday, December 1, 12

Page 34: Cloudstack talk

ENC

You can set the ‘group’ attribute with classification information when instances are created.

The ENC can then query the ‘group’ attribute from the VM instance that needs to be classified.

Saturday, December 1, 12

Page 35: Cloudstack talk

A Puppet client/server run

VM1

Master

FactsCatalog

ModulesClassifier

Saturday, December 1, 12

Page 36: Cloudstack talk

Catalog

Collection of resources that describe how a node can achieve a specified configuration.

Saturday, December 1, 12

Page 37: Cloudstack talk

Catalog

Catalog

Package

Package

File

UserUserFile

ServiceService

Resources

Dependencies

Saturday, December 1, 12

Page 38: Cloudstack talk

VM provisioning with Puppet (experimental! use cases appreciated)

Saturday, December 1, 12

Page 39: Cloudstack 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', }}

Saturday, December 1, 12

Page 40: Cloudstack 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',}

Saturday, December 1, 12