Bootstrap Rackspace Cloud Servers with Puppet and libcloud
This article is republished from the Rackspace Developers blog with the kind permission of our friends from Rackspace, who wanted to share how their customers can manage Cloud Servers with Puppet open source.
First, follow the steps in my last article to set up your puppet master. The puppet agent portions are not required as we will bootstrap our agent servers. Now, let’s install the libcloud library:
pip install apache-libcloud==0.11.3
You may need to install other Python libraries like paramiko for deployments.
Create a Shell Script for Installing Puppet
You need to create a short shell script that will be executed on your new puppet agents. This script should install Puppet and configure the client to talk to your puppet master. All of the files I create here are in a local directory called “puppet-deploy.”
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
Create a JSON File for Your Credentials
For security purposes, you can create a separate file with your Rackspace Cloud API credentials. Just replace the `username` and `apikey` values with those from your Rackspace Cloud account:
1 2 3 4
Use libcloud to Deploy a Puppet Agent
Next we use libcloud to create a server with our SSH key and a puppet agent that is ready to get instructions from our puppet master.
Since I didn’t have the client SSL certificates installed, I’m electing to not verify the SSL certificate from Rackspace. This can open you up to man-in-the-middle attacks, so it’s best to install those. This is for testing only.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
This script is basically authenticating with Rackspace using our API credentials, then creating a 1GB Ubuntu 12.04 server in Chicago with our SSH key. Our puppet install script is then run to upgrade packages and configure puppet. As soon as the server is online, the puppet agent will connect to the puppet master for instructions. The only thing left to do is sign the certificate on the puppet master:
puppet cert --list "puppet02" (5A:A0:BB:FA:DF:2A:E6:24:70:24:63:85:67:2F:DC:08) puppet cert --sign puppet02 notice: Signed certificate request for puppet02 notice: Removing file Puppet::SSL::CertificateRequest puppet02 at '/var/lib/puppet/ssl/ca/requests/puppet02.pem'
Your puppet agent will start getting manifests and modules from the puppet master and installing your application.
- Read up on libcloud, or follow the project on Twitter
- Just getting started with Puppet technologies? [Download our docs as a convenient PDF][docs].
- We recently unveiled [the Puppet Labs Workshop][online], a self-paced online learning environment where you can learn about Puppet Labs products and technologies no matter what your skill level.