Platinum Partner
cloud,cloudstack

How to Use CloudStack Resources with Puppet, Part 1

Curator's Note: The content of this article was originally written by David Nalley over at the Build a Cloud  blog.

I've written a bit about the CloudStack resources written by Dan Bode and how awesome they are. And while cheerleading and telling people it is awesome should be enough - it doesn't really tell you how to actually use it. I will try and remedy that in the next few posts.

CloudStack Resources

Grab the resources from here: https://github.com/bodepd/cloudstack_resources Copy that into your modules directory in your puppet repository.

FOG

You need to ensure that you have fog installed. And by installed, I mean on the machine that will be talking with CloudStack. In our example we'll be using the puppetmaster machine. In an enlightened distribution like Fedora you can install by:
yum install rubygem-fog
In less englightened distributions you can use:
gem install fog

Configuration

You'll need to add a transport.yaml file to /etc/puppet Exercise caution with this file, it will contain API credentials Mine looks similar to:
     cloudstack: api_key: 'WgOdxLuGFA2h2g-Ln2Hg9yWwEN1D3W4aqdXNXKTt_4xIOu234sdfs32NfDRM43JK3j1szDJzZf6CIgNAA' secret_access_key: 'S9Bd2JnuKComulSaqqyaudfwsdfsfesnM6ss7aydWof9QUT9zQ9Jhtja1GhbKcjrquSv7eV11ZpL9bybHxS0xg' host: 'cloud.cloudstack.org' port: '8080' path: '/client/api' scheme: 'https' 

Defining some infrastructure

We'll set up a simple class with a single machine defined, and install as it: modules/infra/manifests/init.pp
class infra { cloudstack_instance { 'foo': ensure => present, flavor => 'Small Instance', zone => 'SanJose', image => 'CentOS63KVMPW', group => 'role=db', } } 

Applying the class

Now that we have a class defined it's time for us to apply that - I am going to assume that you have a site.pp - if you don't, I figure you must be using something like and ENC and are smart enough to figure out how to apply the infra class. in site.pp you likely some lines like:
     node 'puppetserver.cloudy.loc' { include puppet::master } 
You want that to look like:
     node 'puppetserver.cloudy.loc' { include puppet::master include infra } 
The next time that puppet runs on the puppetmaster you should see log messages that say: Notice: /Stage[main]//Cloudstack_instance[foo]/ensure: created This has us using Puppet to define our infrastructure. In the next part we'll hook up puppet to reading CloudStack metadata.





 

Published at DZone with permission of {{ articles[0].authors[0].realName }}, DZone MVB. (source)

Opinions expressed by DZone contributors are their own.

{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}