Cloud Zone is brought to you in partnership with:

Build a Cloud.org is a resource for those users who want to build cloud computing software with both open source and proprietary software. Mark is a DZone MVB and is not an employee of DZone and has posted 73 posts at DZone. You can read more from them at their website. View Full User Profile

How to Use CloudStack Resources with Puppet, Part 1

03.19.2013
| 2350 views |
  • submit to reddit
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 Mark Hinkle, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)