Set up Puppet Master and Agent on AWS EC2 [Part 1]

Set up Puppet Master and Agent on AWS EC2 [Part 1]

This tutorial is the first of the two-part tutorial series which provides step by step instructions on how to set up Puppet Master and Agent on AWS EC2 instances. We are going to use two of the popular technologies in this tutorial which can be used to deploy and run applications on the cloud.

Introduction:

  1. Puppet: is an open-source software configuration management tool which follows a master-slave architecture. Puppet supports both Windows and Unix-like operating systems and also provides its declarative language to define the software configuration.
  2. AWS: stands for Amazon Web Services, and is a fully-featured cloud computing platform provided by Amazon. Its services include (but are not limited to) Compute, Storage, Network, Analytics and so on. We make use of AWS’ EC2 instances which is part of the compute service provided by AWS.

Puppet Master and Agent on AWS

In this first part, we are going to see how to set up EC2 instances in AWS and make sure these instances can communicate with each other.

Create EC2 instances:

We make use of 3 EC2 instances, 1 of them is going to be our Puppet Server (Master node), and the remaining two nodes are our agents (Agent nodes). The idea here is that the Puppet master should be able to deploy the software configuration on authorised agent nodes.

  1. Choose ubuntu-bionic-18.04 AMI.Select Ubuntu Bionic AMI | Puppet Server and Client on AWS
  2. Select the instance type.Select instance type
  3. Configure instance details: (Set number of instances to 3)Configure instance details
  4. Add storage.Add storage
  5. Add a Name tag.Add Name tag
  6. Configure Security Group: Make sure you allow traffic of type:
    1. All Traffic: Source (Anywhere)
    2. SSH: Port – 22 : Source (Anywhere)
    3. Custom TCP rule: Port – 8410 : Source (Anywhere)Add Security Group
  7. Confirm the configuration and click launch.confirm instance details
  8. Create a new key-pair; make sure you download and save that key-pair in a safe location.create a new key-pair
  9. The instances should be up and running in a few minutes. Edit the Name tag for each node and set its name (master, node1 and node2)Running instances | Puppet Server and Client on AWS

 

Setup communication between instances:

  1. SSH into the instance (If you are on Windows use Putty):
    • Open 3 terminal windows for sshing into each of the instances. You can get the whole command by right-clicking on the instance and selecting “connect”.connect to instance | Puppet Server and Client on AWS
      Make sure you are in the directory where your private-key (.pem file) is located. Copy the command below “Example” and paste in terminal.SSH into instance
  2. Set up hostname: Puppet nodes communicate with Puppet Master using the FQDN (Fully Qualified Domain Name). So we need to set the hostname to a FQDN that is easy to remember.
    1. On Master Node:
        • Login as root:
        • Set hostname:
    2. Exit and login as root again so that the changes get reflected.
  3. On Agent Node 1:
      1. Login as root:
      2. Set hostname:
  4. Exit the session and login as root again so that the changes get reflected.
  • On Agent Node 2:
      1. Login as root:
      2. Set hostname:
  • Exit the session and login as root again so that the changes get reflected.
  •  Update all the three instances:
  • Add entries to the hosts file: In this step we are adding IP and hostname entries to the /etc/hosts file so that the Master node can know the IP addresses of  the Agent nodes and similarly the Agent nodes can know the IP address of Master node.
    1. Get Private IP – Hostname string from both Agent nodes and copy it somewhere. The command to generate the Private IP-Hostname string is

      Output should be something like this:generate IP-hostname string

      Make sure you run the above command in both Agent nodes and copy the result somewhere. We are going to need them in the next step.

    2. On Master Node: Run the below commands to add the agent hostname entries to the hosts file.

      Make sure you use your Private IP – Hostname string and don’t just copy paste the command from above.

    3. If you cat the /etc/hosts file on Master node it should look something like this:Puppet master /etc/hosts | Puppet Server and Client on AWS
    4. Now try to ping both Agent nodes from Master, If all went well it should work.

      The output should look something like this:ping agents from master

    5. Now we need to add the Master hostname entry to both of our agent nodes.
      1. Get Private IP – Hostname string of Master Node and copy it in a safe place.

      2. On both Agent Nodes add the hostname entry.

      3. The /etc/hosts file should look something like this on both Agent nodes:Master node /etc/hosts
      4. Now try to ping Master node from both Agent nodes, and it should work.Ping Master node from Agent nodes

 

Well done!, we’ve now successfully set up our 3 EC2 instances which can communicate with each other. I’ve tried to add as much detail as possible here but if you still have any doubts or are stuck anywhere don’t hesitate to leave a comment!.

Now we let us move on to the next part of this tutorial which covers Puppet Master and Agent on AWS installation and configuration.

P.S:

You can also consider making a small donation to support me. Your donation will contribute to covering the running cost of this website and hopefully my college too 🙂

Paypal: https://www.paypal.me/sapneshnaik | UPI: [email protected]

 

1
Leave a Reply

avatar
1 Comment threads
0 Thread replies
1 Followers
 
Most reacted comment
Hottest comment thread
1 Comment authors
Saathwik Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
Saathwik
Guest
Saathwik

Thanks for this tutorial. Just amazing attention to smallest details!!!