Puppet Agent Installation on CentOS 7

I have explained how to install Puppet master in my previous blog. I will now explain how to install Puppet agent on a CentOS 7.

Let’s first open Puppet Enterprise UI. If you click Unsigned Certs tab, you will see the command that you can use to install Puppet agent.

ssh into your host where you plan to run your Puppet agent. And execute the command.

curl -k https://puppet:8140/packages/current/install.bash | sudo bash

Once the execution is complete, go back to Puppet Enterprise web UI. You will see number “1” next to Unsigned certs. This means that the agent you have just installed is waiting for the certificate request to be accepted so that it can start to really communicate with the Puppet master. Let’s just accept the certificate.

After a little while, if you click Nodes tab, you will see the node you just accepted the certificate for shows up in the list.

Create VirtualBox VM with Bash Script

When you need to create multiple VMs with slightly different settings, bash script comes in handy. I found myself constantly creating and destroying CentOS VMs on VirtualBox, so I decided to spend some time to come up with a bash script to create VirtualBox VM. Here is the script.

VMName="CentOS"
VMDiskRoot="/mnt/firecuda/VMs"
DiskDir="$VMDiskRoot/$VMName"
DiskSize=$((1024*200))
MemorySize=$((1024*9))
VRamSize=128
CPUCount=2
OSTypeID="RedHat_64"
NetworkInterface="wlx503eaa732ee3"
ISOFilePath=~/Downloads/CentOS-7-x86_64-Minimal-1810.iso

echo "Creating $VMName disk at $DiskDir. Its size is $DiskSize."
if [ ! -d "$DiskDir" ]; then
    mkdir -p $DiskDir
fi

#VBoxManage list vms
echo "Creating disk..."
VBoxManage createhd --filename "$DiskDir/$VMName.vdi" --size $DiskSize 

echo "Creating VM..."
VBoxManage createvm --name $VMName --ostype "$OSTypeID" --register

echo "Adding the created disk to the VM..."
VBoxManage storagectl $VMName --name "SATA Controller" --add sata --portcount 1 --controller IntelAHCI
VBoxManage storageattach $VMName --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium "$DiskDir/$VMName.vdi"

VBoxManage storagectl $VMName --name "IDE Controller" --add ide
VBoxManage storageattach $VMName --storagectl "IDE Controller" --port 0 --device 0 --type dvddrive --medium "$ISOFilePath"

echo "Setting memory..."
VBoxManage modifyvm $VMName --memory $MemorySize --vram $VRamSize --cpus $CPUCount

echo "Setting boot sequence..."
VBoxManage modifyvm $VMName --boot1 dvd --boot2 disk --boot3 none --boot4 none

echo "Setting network..."
VBoxManage modifyvm $VMName --nic1 bridged --bridgeadapter1 $NetworkInterface

echo "VM Creation completed."

If you would like to fork the code, it can be found here.

Puppet Enterprise Installation

Puppet is the key to a successful server management. In my own blog, I’m switching my gear to Puppet. I’m going to focus on Puppet Enterprise because Puppet allows 10 free agent complimentary license. This is more than enough for me to test things out.

Puppet makes all versions of Puppet Enterprise available on their website. I will try to use the latest LTS (Long Term Supported) release. As of June 5, 2019, 2018.1.8 is the latest LTS.

Let’s click Puppet Enterprise 2018.1.8 – Long Term Supported Release.

Right click the link to copy the link to the PE for the platform where you are installing your Puppet Enterprise.

Open Terminal and execute the following command to download the file.

$ curl -JLO https://pm.puppetlabs.com/puppet-enterprise/2018.1.8/puppet-enterprise-2018.1.8-el-7-x86_64.tar.gz

Extract the tar file by executing the following command.

$ tar -xvf puppet-enterprise-2018.1.8-el-7-x86_64.tar.gz 

Now open port 3000 for us to be able to use the GUI mode during the installation process. Whether you use text mode or GUI mode is up to you, but I like to use GUI mode.

We’ll also open 443 and 8140 because 443 is used for the Web UI and 8140 will be used for Puppet agent to communicate with the master. 8170 will be used for API call to Puppet master.

$ sudo firewall-cmd --add-port=3000/tcp --permanent --zone=public
$ sudo firewall-cmd --add-port=443/tcp --permanent --zone=public
$ sudo firewall-cmd --add-port=4433/tcp --permanent --zone=public
$ sudo firewall-cmd --add-port=8140/tcp --permanent --zone=public
$ sudo firewall-cmd --add-port=8170/tcp --permanent --zone=public
$ sudo firewall-cmd --reload

One more thing before we can execute the Puppet Enterprise installer. Let’s edit /etc/hosts file to mimic DNS entry. My test Puppet Enterprise machine has “pem” as its host name and its IP address is 192.168.1.24, so we need 2 entries in the hosts file like the following. (Use sudo vi /etc/hosts to edit it in vi) If you don’t know how to use vi, go over the basics here.

192.168.1.24 pem
192.168.1.24 puppet

Save the file by hitting ESC and :wq and then Enter key. On the side note, if you have DNS server in your network, it’s better to create the entry in DNS server instead of using the hosts file.

In the terminal, cd into the directory where Puppet Enterprise was extracted to and execute the installer.

$ cd puppet-enterprise-2018.1.8-el-7-x86_64
$ sudo ./puppet-enterprise-installer

When you see How to proceed?, enter 2 for Graphical-mode Install and hit enter. After a little while, it awaits you to hit https://yourpuppetserver:3000 to start the setup process. Click Let’s get started!

Enter a new admin password and click Continue.

Once the validation is clear, you will see a screen like the following screenshot. Click Deploy now button to start the whole process.

Once the deployment process is complete, you should able to hit https://yourpuppetserver and login as admin.

Success!

Finally close the port 3000 because it’s no longer necessary for it to be open.

$ sudo firewall-cmd --remove-port=3000/tcp --permanent --zone=public
$ sudo firewall-cmd --reload