Skip to end of metadata
Go to start of metadata

Please make sure that you have configured your Puppet Master according to the steps in Step 2 - Configuring Puppet Enterprise before following the steps bellow.

Puppet needs an agent to be installed on all nodes (servers) it controls. We will setup our nodes to download and install the agent from the Puppet Enterprise server itself. 

Create install script

First, we will create an install script that downloads and installs the Puppet Agent. The script will also make sure that all custom Scalr environment variables are sent every time the Puppet Agent checks in with the Puppet Master.

Create a Puppet role

Now we will create a new Role which will have the Puppet Agent auto-installed and configured to be controlled by the Puppet Master.

  • Click on Roles in the top menu.
  • Click on New role.
  • Click on New role in the popup.
  • Enter the following details:
    • Name: Puppet-Agent
    • OS: CentOS
    • Version: 6.x
    • Category: Mixed
  • Under the Images section, click on Add Image.
  • Choose a base centos 6 64bit image located in the cloud location you plan to use for the rest of this tutorial.

Now we will attach the Puppet Agent install script that we created in the first step.

  • Click on the Orchestration tab to the left.
  • Click on New Rule.
  • Under the Trigger section, select the BeforeHostUp Event (this event gets triggered just before the server enters Running State).
  • Under the Action section, select Scalr script and pick the Install Puppet Agent script you just created.
  • Under the Target section, choose Triggering instance only (this will run the Script on the instance that fired the Event, which is the Server that has finished initializing).

The Puppet Agent Installation script needs to know the IP or Hostname of the Puppet Master. We will use the Scalr Global Variables for setting it.

  • Click on Global Variables in the left menu.
  • Click on New variable.
  • Enter the name PUPPET_MASTER_HOST (this variable will contain the Hostname or IP to the Puppet Master).
  • Click on the Shall be set on a lower scope icon (the exclamation mark), leave the scope to the default (Farm Role).
  • Enter ^[A-Za-z0-9.-:]+$ in the Validation Pattern field.
  • Click on Save to create your new role.

Create example Farm with a Puppet Role

Now, we will create an example farm with some webserver puppet roles. However, you should follow the same procedure for all farms/roles you want to be controlled by Puppet.

  • Click on Farms in the top menu.
  • Click on New farm.
  • Enter the name Puppet Farm.
  • Click on Add farm role.
  • Click on Application servers and chose Puppet-Agent.
  • Click on Add to farm.

We need to tell Scalr which Puppet Master host this Role should use and the Puppet class to be used.

  • Click on the Farm Role you just added to the left (Puppet-Agent).
  • Enter the alias webserver. You should substitute this with the Puppet class you wish to use if you have other classes configured on your Puppet Master.
  • Click on the  Global Variables tab.
  • Enter the following values:
  • Create another Global Variable with this name and value:
    • PUPPET_ROLE: webserver

If you are using AWS, we need to add this Farm Role to our scalr-puppet-agent Security Group (created at Step 1 - Installing Puppet Enterprise) to allow communication between the Puppet Agent and Puppet Master.

We also need to add an additional Security Group for allowing access to port 80 for Apache.

  • Click on the Security tab.
  • Click on Add security groups.
  • Click on Add Group.
  • Enter the following details:
    • Name: scalr-webserver
    • Description: Allow HTTP
  • Click on Add security rule.
  • Enter the following details:
    • Protocol: TCP
    • Port: Single port; 80
    • Source: CIDR IP; 0.0.0.0/0
  • Click on Add.
  • Click on Save.
  • Make sure that the scalr-webserver and scalr-puppet-agent groups are checked. The scalr-puppet-agent group was created in Step 1 - Installing Puppet Enterprise.
  • Click on Add 2 group(s).

Lastly, we will save our changes and launch our new Farm.

  • Click on Save & launch.
  • Lean back, relax, have a cup of coffee and watch Scalr and Puppet do their magic. (smile)

Confirm that everything works

When your new webserver has been launched and reaches a Running state (and after waiting some extra minutes to let Puppet configure it) you should be able to access Apache by pointing your web browser to http://IP-OF-YOUR-WEBSERVER.

If this is not the case, please read the Troubleshooting Puppet Integration page.

Workflow explained

This is what actually happens:

  1. A new server (instance) is created and launched.
  2. When the new server boots up, it will run the Puppet Agent Installation script.
  3. The script will download the Puppet Agent from the Puppet Master server, which was set in the PUPPET_ENTERPRISE_HOST global variable.
  4. The script will then install the Puppet Agent and add all Scalr built-in variables as Puppet Facts. Built-in variables includes things like farm name, environment name, etc. 
  5. Now, the Puppet Agent will start, connect to the Puppet Master (PUPPET_ENTERPRISE_HOST) and send all the Puppet Facts.
  6. The Puppet Master will check the value of the scalr_farm_role_alias fact and include this server into the webserver group (because we have told Puppet Enterprise to auto-assign scalr_farm_role_alias=webserver to the webserver group in Step 2 - Configuring Puppet Enterprise).
  7. Now, because the server is associated with the webserver group, Puppet Enterprise will notice that the webserver class should be used to configure this new server (again, this was setup in Step 2 - Configuring Puppet Enterprise).
  8. The Puppet Master will now send the webserver class to the Puppet Agent and the server will be configured accordingly. In the case of this tutorial, this means installing the Apache webserver and make sure it is running.

Next Steps

You will most likely want to customize the Puppet automation presented here. Remember that this is just a sample of what's possible using Scalr, not a prescribed solution.

Here are a few suggestions:

  • Add more Puppet classes to your Puppet Master, such as database, cache, application etc.
  • Configure your Puppet classes and Scalr to support multiple server with the same role. As an example, you might want to tell a loadbalancer about new webservers as they are launched.
  • Setup auto-scaling in Scalr to increase capacity automatically with.
  • Make your Puppet Enterprise redundant by adding more servers with fail-over.
  • Scale your Puppet Enterprise installation by splitting it into different components and spreading it across multiple servers to handle more Puppet nodes.

 

  • No labels