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.
Pre-requisites
The following things need to be setup before the Puppet CloudFormation Face can be installed:
- 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.
- 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.
Installation
These tools can be easily evaluated with the Learning Puppet VM, or you can follow the manual installation instructions in the README on GitHub.
- 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.
- 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-v0.0.1.tar.gz | tar -xz && mv puppetlabs-cloudformation-0.0.1 cloudformation
- Export the ec2 region you created your keypair for in the prerequisites section.
example: export EC2_REGION=us-west-1
- Make sure time on the virtual machine is up to date.
ntpdate pool.ntp.org
- 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’, }
- Apply the modified manifest:
puppet apply examples/install.pp
This will install the CloudFormation client tools and create the file: bashrc_cfn
- Source the bashrc_cfn file to set up all of the necessary environment variables.
source bashrc_cfn
- Verify that the CloudFormation client tools were successfully installed and configured by running the following:
cfn-describe-stacks
A return of ‘No Stacks found’, validates that the client tools are correctly configured.
- 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 \ --disable-rollback \ --master-type m1.small \ --keyname <your-ec2-key-name>
Once the stack has successfully launched, use:
cfn-describe-stacks
and
cfn-describe-stack-events <StackName>
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://
- install_modules – List of modules that should be downloaded from the Puppet Forge. The modules are downloaded to the modulepath of the master and all classes contained in these modules are populated into the Enterprise Console.
- dashboard_groups – Specifies a list of groups that should be added to the Enterprise Console. Groups are specified as hashes with the following keys:
- classes – list of classes that should be contained in the group
- parameters – hash of parameters to be contained in the group
- parent_groups – list of parent groups
- puppet_agents – List of PE Agents that should be provisioned along with their classification information. Agents are specified as a hash with the following keys:
- groups – Groups from the dashboard that should be applied to the agent.
- classes – Classes that should be applied to the agent.
- parameters – Node specific parameters to be added
- ports – Creates a security group
The configuration file and its settings specify all required information to compose a stack. The information is sufficient for bootstrapping environments of PE from scratch. Although no information about a Puppet master has been specified in the configuration file, one is always created by default. This Puppet master installation includes the Puppet Enterprise Console and a security group to allow tcp access from agents to ports: 443, 8140, and 61613. It also allows tcp access on port 22 from any address.
Related Content:
- Learn more about CloudFormation
- Getting started with the Learning Puppet VM
- Download Puppet Enterprise 2.0 and test out ten nodes for free
- Learn more about Live Management with resource browsing and cloning and controlling Puppet and invoking agents






