Sunday, March 17, 2013

HOWTO: Using CloudStack resources with Puppet, part 1

http://feedproxy.google.com/~r/open-source-cloud-computing/~3/Y3_hOHgq9-w/239-howto-using-cloudstack-resources-with-puppet%2C-part-1.html
Saturday, March 16, 2013 3:56 PMHOWTO: Using CloudStack resources with Puppet, part 1CloudStack Blogdavid@gnsa.us (ke4qqq)
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.






No comments:

Post a Comment