homeblogusing cloudformation to build out fully functional stacks of puppet enterprise

Using CloudFormation to Build out Fully Functional Stacks of Puppet Enterprise

The Puppet CloudFormation Face integrates Puppet Enterprise (PE) with CloudFormation so that users can reliably create entire Puppet Enterprise “stacks” in Amazon’s EC2 from their workstation. A “stack” refers to a collection of launched Amazon Web Services (AWS) “resources” that can be specified as a “template” in CloudFormation’s declarative json modeling language. Templates support a wide range of AWS resources, including: EC2 instances, security groups, credentials, as well as a host of other resources. EC2 meta-data and user data can be associated with AWS resources in a CloudFormation template. This meta-data allows CloudFormation to not only provision EC2 instances, but also to bootstrap those instances into a functioning application stack. The CloudFormation Face is a command line tool that can use this meta-data to specify all of the required information to bootstrap an entire Puppet Enterprise stack, including: modules to be downloaded from the Puppet Forge, groups to be created in the Enterprise Console, Puppet Agents to be provisioned, as well as security groups and classification information to be associated with those agents.


The following things need to be setup before the Puppet CloudFormation Face can be installed:
  1. AWS credentials are required. These credentials must be associated with an account that has full administrative rights. Instructions for how to sign up for Amazon Web Services (AWS) can be found here.
  2. Requires that a keypair exist within the region in which resources will be launched. This keypair is used to refer to user public keys that can be injected into created EC2 instances. We recommend us-west-1. Remember what region you made a keypair for, you’ll need it later.


These tools can be easily evaluated with the Learning Puppet VM, or you can follow the manual installation instructions in the README on GitHub.
  1. Download the Learning Puppet VM, follow instructions to boot the virtual machine and log-in as root. Note: You may want to ssh into your running Learning Puppet VM for easy copying and pasting.
  2. Once logged in, use the following command string to download the CloudFormation Face from the Puppet Forge, unpack it to Puppet’s module path and rename it to cloudformation.
    cd /etc/puppetlabs/puppet/modules && curl http://forge.puppetlabs.com/system/releases/p/puppetlabs/puppetlabs-cloudformation-0.0.2.tar.gz | tar -xz && mv puppetlabs-cloudformation-0.0.2 cloudformation
  3. Export the ec2 region you created your keypair for in the prerequisites section.
    example: export EC2_REGION=us-west-1
  4. Make sure time on the virtual machine is up to date.
    ntpdate pool.ntp.org
  5. CD into the cloudformation directory and edit examples/install.pp to include your AWS credentials and insert your java home. It will look something like this:
      class { 'cloudformation':
        aws_access_key => '< your key here >',
        aws_secret_key => '< your secret key here >',
        java_home => ‘/usr/lib/jvm/jre-1.6.0-openjdk’,
  6. Apply the modified manifest:
     	puppet apply examples/install.pp
    This will install the CloudFormation client tools and create the file: bashrc_cfn
  7. Source the bashrc_cfn file to set up all of the necessary environment variables.
      	source bashrc_cfn
  8. Verify that the CloudFormation client tools were successfully installed and configured by running the following:
    A return of ‘No Stacks found’, validates that the client tools are correctly configured.
  9. Verify that the CloudFormation Face is properly configured by running:
    	puppet help cloudformation deploy
    Basic usage information should be returned.

Creating a Puppet Enterprise environment from scratch

Since puppetlabs-cloudformation can reliably build out fully functional Puppet Enterprise environments, it is an ideal tool for evaluation or experimentation in EC2. Let’s build an example stack. The ‘puppet cloudformation deploy’ action can be used to build out complete stacks of PE. The command below shows how to build out an prepared Puppet Enterprise evaluation environment. Supply your own ‘keyname’ and ‘stack-name’ to the above command.
	puppet cloudformation deploy 
		--stack-name DemoStack 
		--config config/pedemo.config 
		--master-type m1.small 
Once the stack has successfully launched, use:
to check the current state of this stack. Once you see the state of CREATE_COMPLETE, you’ll also receive the public dns name of your new Puppet Master. You can open your web browser and browse to https://and log in with the user name cfn_user and cfn_password to visit the Puppet Enterprise Console. Check out the video below to see this in action. controlling Puppet and invoking agents