In this tutorial, you will see how to add a new server to an existing
Catalyst Cloud network and configure it with Puppet and have it check in to
the Puppet Master.

To achieve this, you will create a heat template that will handle the
creation of the instance and then run a nested cloud-config script via
cloud-init that will handle the provisioning of Puppet on the new server.

You will make use of Heat template to deploy a single instance into an existing
network hosted in the Catalyst Cloud. In order to make this work, you need to
retrieve the relevant network IDs and add them into the template.

The two networks you will be connecting to are front-end and public-net. To
find these values, you need to run the following OpenStack commands.

Here is the Heat template that is responsible for creating the new instance.
The network ID values found previously have been added to the relevant
parameters as defaults. It is also possible to pass these values in as
arguments from the command line, as shown here.

heat_template_version:2013-05-23description:>Heat template to deploy a single server into an existing Neutron tenantnetwork, assign a floating IP addresses and ensure it is accessible fromthe public network.It also uses a cloud-init script to bootstrap the server with Puppet.parameters:key_name:type:stringdescription:Name of keypair to assign to serversdefault:mykeyimage:type:stringdescription:Name of image to use for serversdefault:ubuntu-14.04-x86_64flavor:type:stringdescription:Flavor to use for serversdefault:c1.c1r1public_net_id:type:stringdescription:>ID of public network for which floating IP addresses will be allocateddefault:849ab1e9-7ac5-4618-8801-e6176fcccf30private_net_id:type:stringdescription:ID of private network into which servers get deployeddefault:e7adca02-5b8b-4c2e-9946-2e2eff55997aprivate_subnet_id:type:stringdescription:ID of private sub network into which servers get deployeddefault:279a71ca-6772-4235-bbb4-c0ddf2029f67resources:server1:type:OS::Nova::Serverproperties:name:server1image:{get_param:image}flavor:{get_param:flavor}key_name:{get_param:key_name}networks:-port:{get_resource:server1_port}user_data_format:RAWuser_data:get_file:/home/user1/cloud/puppet_bootstrap.yamlserver1_port:type:OS::Neutron::Portproperties:network_id:{get_param:private_net_id}fixed_ips:-subnet_id:{get_param:private_subnet_id}security_groups:[{get_resource:server_security_group}]server1_floating_ip:type:OS::Neutron::FloatingIPproperties:floating_network_id:{get_param:public_net_id}port_id:{get_resource:server1_port}server_security_group:type:OS::Neutron::SecurityGroupproperties:description:Add security group rules for servername:security-grouprules:-remote_ip_prefix:0.0.0.0/0protocol:tcpport_range_min:22port_range_max:22-remote_ip_prefix:0.0.0.0/0protocol:icmpoutputs:server1_private_ip:description:IP address of server1 in private networkvalue:{get_attr:[server1,first_address]}server1_public_ip:description:Floating IP address of server1 in public networkvalue:{get_attr:[server1_floating_ip,floating_ip_address]}

This is the cloud-init script that is called via the user-data
command. It ensures that the Puppet package is installed and sets some
basic configuration to ensure that the server can identify itself and
locate the Puppet Master.

It performs the following tasks:

creates a host entry for the Puppet Master

adds environment and Puppet Master server variables to puppet.conf

runs Puppet agent with an optional 120 second wait for the certificate
request to be signed by the Puppet Master

#cloud-config# This is an example of how to have Puppet agent installed and run# when the instance boots for the first time.# It needs to passed in valid YAML format to user-data when starting# the instance.# bootcmd required as it runs very early in the boot process# add a host entry so server can correctly identify itselfbootcmd:-echo 127.0.0.1 server1.example.co.nz server1 >> /etc/hosts# Install additional packages on first boot# if packages are specified then apt_update will be set to true and run# firstpackages:-puppetpuppet:# Every key present in the conf object will be added to puppet.conf:# [name]# subkey=valueconf:agent:server:"puppet.example.co.nz"environment:dev# add Puppet Master host entry and do initial Puppet runruncmd:-echo 10.20.40.12 puppet.example.co.nz puppet >> /etc/hosts-puppet agent --test --server puppet.example.co.nz --waitforcert 120# Capture all subprocess output into a logfile# Useful for troubleshooting cloud-init issuesoutput:{all:'|tee-a/var/log/cloud-init-output.log'}