The document discusses integrating CloudStack with Puppet for automated provisioning and configuration of virtual machines. It explains that CloudStack provides an API for provisioning VMs, while Puppet can configure the VMs into functional applications. Together they allow fully automated application stacks. It then provides an overview of Puppet's architecture, including facts, modules, resources, catalogs, and classification. It proposes using Puppet resources and facts to model and provision VMs through CloudStack based on their roles.
1. Integrating
CloudStack
with Puppet
Saturday, December 1, 12
2. About me:
Dan Bode
Integration Specialist at PuppetLabs
@bodepd
bodepd <on> freenode
Saturday, December 1, 12
3. Who is this talk for?
current CloudStack Users
Puppet beginners
Saturday, December 1, 12
4. 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
6. Why integrate?
CloudStack provides an API for provisioning virtual
machines
deployVirtualMachine
Self Service API
VM1
Saturday, December 1, 12
7. Why integrate?
Puppet converts freshly provisioned VMs into
functional applications
Self Service APi
Make me an
VM1 apache server
Here are the
instructions for
becoming an
Puppet
apache server
Master
Saturday, December 1, 12
8. Why integrate?
Combined, they create fully automated application
stacks.
deploy me a DB,
then 2 apache servers
Self Service APi
DB1 Apache1 Apache2
Saturday, December 1, 12
10. 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
11. A Puppet client/server run
Classifier Modules
Master
Facts Catalog
VM1
Saturday, December 1, 12
12. Facter returns system specific
information
Classifier Modules
Master
Facts Catalog
Agent
Saturday, December 1, 12
13. Facter
to see a system’s facts, run
$ facter
architecture => x86_64
domain => local
facterversion => 2.0.0
fqdn => DansLapTop.local
hardwareisa => i386
hardwaremodel => x86_64
id => danbode
Saturday, December 1, 12
14. 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
15. A Puppet client/server run
Modules
Classifier
Master
Facts Catalog
VM1
Saturday, December 1, 12
16. Modules
Sharable content composed of classes and defined
resource types (configuration interfaces).
Saturday, December 1, 12
17. Module Forge
http://forge.puppetlabs.com/
http://forge.puppetlabs.com/puppetlabs/apache
Saturday, December 1, 12
19. Resources
Describe the configuration state of individual system
elements.
user { ‘dan’:
ensure => present,
shell => ‘/bin/bash’,
}
Saturday, December 1, 12
20. 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
21. Resources
package { ‘apache2’: # a package named apache2
ensure => present, # should be installed
}
Saturday, December 1, 12
23. Puppet DSL and Resources
The Puppet DSL can be used to compose collections of
resources into classes or defined resources.
Saturday, December 1, 12
24. 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
25. A Puppet client/server run
Classifier
Modules
Master
Facts Catalog
VM1
Saturday, December 1, 12
26. Classification
Process that determines how Puppet maps a role
to a specific instance.
Saturday, December 1, 12
27. Site manifest
Master
/etc/puppet/manifest/site.pp
The master utilizes code from its site manifest to figure
out how to assign a role to a node.
Saturday, December 1, 12
28. Site manifest
Node blocks map a host’s certname to content from a
module
node /^my_node/ {
include apache
}
Saturday, December 1, 12
29. Determine role based on facts
deploy me an apache server
Self Service APi
Apache1
Saturday, December 1, 12
30. Determine role based on facts
‘deployVirtualMachine’ -> userdata -> facts
node default {
if $::role == ‘apache’ {
include apache
} else {
fail(“Undefine role: ${role}”)
}
}
Saturday, December 1, 12
31. Decouple role assignment from
provisioning
After 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
32. 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
33. ENC
ENC
Master
The master can call out to arbitrary executables to
figure out how a node should be classified.
Saturday, December 1, 12
34. 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
35. A Puppet client/server run
Classifier Modules
Master
Facts
Catalog
VM1
Saturday, December 1, 12
36. Catalog
Collection of resources that describe how a node can
achieve a specified configuration.
Saturday, December 1, 12
37. Catalog
Resources
Catalog
Package
Package File
File
User User
Service
Dependencies Service
Saturday, December 1, 12
38. VM provisioning with Puppet
(experimental! use cases
appreciated)
Saturday, December 1, 12
39. 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
40. Use resource defaults for
common settings
Cloudstack_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