Introduction
Puppet is an open-source, cross-platform, enterprise automation tool used to perform administrative tasks and server management remotely. Puppet can automatically configure all computer systems via the network, add users, install and update packages, and many more.
This article will explain how to install puppet on Ubuntu 20.04 OS.
Prerequisites
- A root or non-root user with
sudo
privileges. - Two Ubuntu systems with at least 2GB RAM are required for master as machine1 and client as machine2 nodes.
Configure Hosts
- Set the hostname for the master(machin1) machine using the below command.
$ hostname puppetmaster
- Set the hostname for the client(machine2) machine using the below command.
$ hostname puppetclient
- Open a host file on both machines.
$ sudo nano /etc/hosts
- Add the following lines on both machines.
Replace your master machine IP withmaster-node-ip puppetmaster puppet
client-node-ip puppetclientmaster-node-ip
and client machine IP withclient-node-ip
in the above command.
Install Puppet Server on Master(Machine1) Node
- Download the latest Puppet version on the master(machine1) node.
$ wget https://apt.puppetlabs.com/puppet7-release-focal.deb
- After a successful download, run the following command to install it.
$ sudo dpkg -i puppet7-release-focal.deb
- Update the package repository on both machines.
$ sudo apt update -y
- Install the Puppet server on the master(machine1) node.
$ sudo apt install puppetserver -y
- Open
puppetserver
file, modify the following line to change the memory size to 1 GB normally the default allocated value is 2GB.$ sudo nano /etc/default/puppetserver
JAVA_ARGS="-Xms1g -Xmx1g -Djruby.logger.class=com.puppetlabs.jruby_utils.jruby.Slf4jLogger" - Now, you can start the Puppet service and enable it to start at system reboot.
$ sudo systemctl start puppetserver
$ sudo systemctl enable puppetserver
Install Puppet Agent on Client(Machine2) Node
- Download the latest version of Puppet on a client(machine2) node.
$ wget https://apt.puppetlabs.com/puppet7-release-focal.deb
- Install the puppet package using the following command.
$ sudo dpkg -i puppet7-release-focal.deb
- Update the package repository.
$ sudo apt update -y
- Install the Puppet agent on the client(machine2) node.
$ sudo apt install puppet-agent -y
- Open the Puppet configuration file.
$ sudo nano /etc/puppetlabs/puppet/puppet.conf
- Add the following lines at the end of the file.
[server]
vardir = /opt/puppetlabs/server/data/puppetserver
logdir = /var/log/puppetlabs/puppetserver
rundir = /var/run/puppetlabs/puppetserver
pidfile = /var/run/puppetlabs/puppetserver/puppetserver.pid
codedir = /etc/puppetlabs/code
dns_alt_names=puppetmaster,puppetserver
[main]
certname = puppetclient
server = puppetmaster - Start and enable the Puppet service on the client node.
$ sudo systemctl start puppet $ sudo systemctl enable puppet
Sign Puppet Agent Certificate on the Master node
- Request for certificates from your Puppet Client(machine2) for the Master(machine1) to sign.
$ sudo /opt/puppetlabs/bin/puppet agent -t
- List all the available certificates on the master(machine1) node.
$ sudo /opt/puppetlabs/bin/puppetserver ca list --all
- Sign all the certificates on the master(machine1) node.
$ sudo /opt/puppetlabs/bin/puppetserver ca sign --all
- The Puppet Master(machine1) is now able to communicate with the client(machine2) node. Confirm by running the below command on the client (machine2) node.
$ sudo /opt/puppetlabs/bin/puppet agent --test