Introduction
Puppet is an open-source, cross-platform, enterprise automation tool that performs 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 a puppet on CentOS 7 system.
Prerequisites
- A root or non-root user with
sudo
privileges. - Two CentOS 7 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
- Update the systems and install the required packages on both machines.
# sudo yum -y update
# sudo yum -y install wget curl vim bash-completion
- Open a host file on both machines.
# sudo vi /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.
Add Puppet 7 Repositories
- Add Epel repository to both machines.
# sudo yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# sudo yum -y install https://yum.puppet.com/puppet-release-el-7.noarch.rpm
Install and configure Puppet on Master(machine1) Node
- Install the Puppet server from the added repository on the master(machine1) node.
# sudo yum -y install puppetserver
- Open
puppetserver
file, modify the following line to change the memory size to 1 GB normally the default allocated value is 2GB.
# sudo vi /etc/sysconfig/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 and configure Puppet agent on the client(machine2) node
- Install the Puppet agent on the client(machine2) node.
# sudo yum -y install puppet-agent
- Once installed, open the Puppet configuration file.
# sudo vi /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
Connect Puppet Client to Puppet Master
- Generate certificates from your Puppet Client(machine2) for the Master(machine1) to sign.
# sudo /opt/puppetlabs/bin/puppet agent -t
- Now on the Puppet master(machine1), list the Puppet client nodes and certificates with the command.
# sudo /opt/puppetlabs/bin/puppetserver ca list
- Sign all the certificates on the master(machine1) node.
# sudo /opt/puppetlabs/bin/puppetserver ca sign --all
- Test the Puppet communication from both machines.
# sudo /opt/puppetlabs/bin/puppet agent -t