Install Puppet Master and Slave on AWS

·

4 min read

Installation Guide For Creating Test Environment :

Below are the Steps to Install Puppet Server and Puppet Agent Architecture on AWS, In Below Installation we are using 3 EC2 instances (1 Master and 2 Slave) on Redhat Enterprise Linux 8 AMI with arch x86_64.

**Requirements :

  • AWS Account to install EC2 Instances
  • Any SSH Client ( e.g Terminus), you can get it on Appstore in your Macbook
  • Basics of AWS and Linux**

Steps:

  • On AWS go to EC2 Service

  • Click on "Launch Instance"

  • Ideal configuration you can select for EC2 instance is as follows:

  • Number of Instances : 3

  • Give Name to Instances

  • Select "Redhat Enterprise Linux 8 AMI"

  • Architecture : 64bit

  • Instance Type : Minimum t2.large

  • Key Pair: Either Use Exisiting Key pair or create new Key Pair.

  • Network Settings:

  • Allow SSH Traffic from Either "Anywhere" or You can Add "Specific IP's"

  • Allow ICMP for IPv4 from Either "Anywhere" or You can Add "Specific IP's"

  • Allow TCP for Port 8140 from Either "Anywhere" or You can Add "Specific IP's" [We need to Open/Allow

  • TCP Port 8140, which is used by Puppetserver /Agent]

  • Allow HTTPS Traffic from Either "Anywhere" or You can Add "Specific IP's

  • VPC : You can select Default VPC or Create new VPC and select Subnet as default or create new.

  • Also select "Enable" Auto-assign public IP

  • Configure Storage: Minimum 10Gb of Storage for each drive.

  • Once Everything is Done, Click on "Launch Instance" and if it errors out, try changing recommendation given in Error Message.

  • Once our EC2 are Launched and in Running State, we are good with EC2 Side.

  • Now Connect to Those EC2 Instances using our SSH Client which is "Terminus" or any other Client. (use the (Private Key File, i.e. .Pem file) keypair we created while connecting )

Puppet Installation Steps:

At this Stage, it is expected that, you have connected to Launched EC2 instances

Now switch user to "root" using below command

sudo su -

once you have switched to root user, Configure hostname for all 3 EC2 instances using below Command

hostnamectl set-hostname puppet-master.sandbox.local

On Master Server (Choose any Ec2 instance which will act as your Master puppet Server)

Simillar way, do it on other 2 slave machine

hostnamectl set-hostname puppet-slave1.sandbox.local

hostnamectl set-hostname puppet-slave2.sandbox.local

Before installing Puppet, update the Linux binaries using below command

yum update -y

Once update is completed, you are ready to install puppet server and Puppet Agent.

Configure /etc/hosts Properly, on all 3 host edit the /etc/hosts file and add Puppet Master and Slave IP, example is given below:

Example /etc/hosts:

Puppet Server Installation:

On Master Node Run Below Command

sudo rpm -Uvh https://yum.puppet.com/puppet7-release-el-8.noarch.rpm

Then install puppetserver using below command

yum install puppetserver -y

Once Puppetserver installation is done, Change the virtual memory config of puppetserver, edit the puppetserver sysconfig file using below command

vi /etc/sysconfig/puppetserver

Use Insert mode under it and change the Mem value as shown in below image ( we have to modify "JAVA_ARGS" value to 250mb), it should look like below image

Once it is done, Start the puppet server using below command

systemctl start puppetserver.service

verify the status using below Command: [The services should show us "Active and running" in status]

systemctl status puppetserver.service

Now we have Enable the puppetserver services, so in the event of server reboot, puppetserver should start automatically, for that run below command

systemctl enable puppet.service

you can refer the official Installation Guide from Puppet Website: Puppet Installation

Now Puppet Server is installed on our Master Node, its time to install Puppet Agents on remaining 2 ec2 nodes.

Puppet Agent Installation:

For Both Slave Nodes follow below instructions:

On Slave Nodes to install Puppet Agent first enable the puppet repos, run below commands

sudo rpm -Uvh https://yum.puppet.com/puppet7-release-el-8.noarch.rpm

Now install Puppet Agent, run below command

yum install -y puppet-agent

Now Start the Puppet agent service on both node using below command

sudo /opt/puppetlabs/bin/puppet resource service puppet ensure=running enable=true

Now Configure Puppet slave nodes for using "Puppet" commands, run below command to configure.

source /etc/profile.d/puppet-agent.sh

Configure the Puppet Server Setting, run below command on both agent nodes, this will add puppetserver entry in agent configs

puppet config set server puppet-master.sandbox.local --section main

Now Puppet agent is installed on Both Nodes, it's time to generate Slave Certificate. On Slave node run below test command to Generate Slave ca certificate

puppet agent -t

this will generate Slave certificate, however it will display the message "Manually sign the ca Certificate" Now to Manually Sign the Slave Certificate, go to master node and run below commands, that will sign the slave certificates.

puppetserver ca sign --certname puppet-slave1.sandbox.local

and

puppetserver ca sign --certname puppet-slave2.sandbox.local

To Validate the signed certificate, run below command on Master node:

puppetserver ca list --all

Puppet Master and Slave Installation is now Completed on all 3 Nodes and We have validated both Slaves certificate on Master, which indicates that slaves can now communicate with Master Nodes.