Breaking News
Home / How To / Install Puppet Master and Agent on Ubuntu 20.04

Install Puppet Master and Agent on Ubuntu 20.04



Puppet is a free and open source automated administrative engine for Linux, Unix and Windows operating systems. It is used to distribute, configure and manage servers and performs administrative tasks such as adding users, installing packages and many more. It helps system administrators free up time and mental space by automating tasks on thousands of physical and virtual machines. It uses a client server model. Where the Puppet master checks configuration information for Puppet agents while Puppet agents talk to and drag down configuration profiles from the Puppet master.

In this tutorial we will explain how to install a Puppet server and agent on the Ubuntu 20.04 server.

Conditions

  • Two servers running Ubuntu 20.04.
  • A root password is configured on both servers.

Getting Started

First you need to update all packages on the Puppet master and Puppet client systems. You can update them by running the following command:

apt-get update -y

Once all packages are updated, you can proceed to the next step.

Set host name resolution

Then you need to set the hostnames on both nodes. So each node can communicate with each other by hostname. You can do this by editing the / etc / hosts file on both nodes:

nano /etc/hosts

Add the following lines to both nodes:

puppet-master-ip puppetmaster puppet
puppet-client-ip puppetclient

Save and close the file when you are done. Then you can move on to the next step.

Install Puppet Server

First you need to install the Puppet server on the master node. The Puppet package is not available in the standard Ubuntu 20.04 repository by default. So you need to install the Puppet archive on your server.

First download the latest version of Puppet with the following command:

wget https://apt.puppetlabs.com/puppet6-release-focal.deb

Once the package has been downloaded, install it by running the following command:

dpkg -i puppet6-release-focal.deb

When the installation is complete, update the repository and install the Puppet server by running the following command:

apt-get update -y
apt-get install puppetserver -y

After installing the Puppet server, you will need to change the allocation size of the Puppet Java process memory. You can do this by editing / etc / default / puppetserver file:

nano /etc/default/puppetserver

Change memory size to 1g as below:

JAVA_ARGS="-Xms1g -Xmx1g -Djruby.logger.class=com.puppetlabs.jruby_utils.jruby.Slf4jLogger"

Save and close the file when you are done. Then start the Puppet service and reactivate it at system startup with the following command:

systemctl start puppetserver
systemctl enable puppetserver

You can then verify the status of the puppet service with the following command:

systemctl status puppetserver

You should see the following command:

? puppetserver.service - puppetserver Service
     Loaded: loaded (/lib/systemd/system/puppetserver.service; disabled; vendor preset: enabled)
     Active: active (running) since Sat 2020-09-05 09:33:55 UTC; 3s ago
    Process: 3673 ExecStart=/opt/puppetlabs/server/apps/puppetserver/bin/puppetserver start (code=exited, status=0/SUCCESS)
   Main PID: 3715 (java)
      Tasks: 42 (limit: 4915)
     Memory: 962.3M
     CGroup: /system.slice/puppetserver.service
             ??3715 /usr/bin/java -Xms2g -Xmx2g -Djruby.logger.class=com.puppetlabs.jruby_utils.jruby.Slf4jLogger -XX:OnOutOfMemoryError="kill>

Sep 05 09:33:08 puppetmaster systemd[1]: Starting puppetserver Service...
Sep 05 09:33:55 puppetmaster systemd[1]: Started puppetserver Service.

When you are done, you can move on to the next step.

Install and configure Puppet Agent

At this time, the Puppet server is installed and configured. Now you need to install the Puppet Agent on the client node.

First download and install the Puppet archive with the following command:

wget https://apt.puppetlabs.com/puppet6-release-focal.deb
dpkg -i puppet6-release-focal.deb

Then update the repository and install the Puppet Agent by running the following command:

apt-get update -y
apt-get install puppet-agent -y

After installing the Puppet agent, you must edit the Puppet configuration file and define the Puppet master information:

nano /etc/puppetlabs/puppet/puppet.conf

Add the following lines:

[main]
certname = puppetclient
server = puppetmaster

Save and close the file when you are done. Then start the Puppet agent service and activate it at startup with the following command:

systemctl start puppet
systemctl enable puppet

Then check the status of the doll with the following command:

systemctl status puppet

You should get the following output:Advertisement

? puppet.service - Puppet agent
     Loaded: loaded (/lib/systemd/system/puppet.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2020-09-05 09:43:15 UTC; 22s ago
   Main PID: 1435 (puppet)
      Tasks: 2 (limit: 2353)
     Memory: 52.8M
     CGroup: /system.slice/puppet.service
             ??1435 /opt/puppetlabs/puppet/bin/ruby /opt/puppetlabs/puppet/bin/puppet agent --no-daemonize

Sep 05 09:43:15 puppetagent systemd[1]: Started Puppet agent.

At this time, the Puppet Agent is installed and configured. Now you can move on to the next step.

Sign the Puppet Agent Certificate

Puppet uses a client-server architecture so you must approve a certificate request for each agent node before it can configure it.

Run the following command on the Puppet master node to view all certificates:

/opt/puppetlabs/bin/puppetserver ca list

You should see the following output:

Requested Certificates:
    puppetclient       (SHA256)  A4:9A:E9:87:8B:54:0A:4F:A0:78:65:1A:3C:99:B5:EC:31:9E:BB:4C:17:8A:50:16:E9:1E:3D:D6:27:74:89:85
    puppetmaster       (SHA256)  E9:25:4C:51:4E:47:D7:44:11:1F:C5:A9:4E:96:D9:E8:3A:EB:A0:01:48:06:B5:EF:3F:C4:09:03:90:3E:D8:2D

Now sign the entire certificate with the following command:

/opt/puppetlabs/bin/puppetserver ca sign --all

You should get the following output:

Successfully signed certificate request for puppetclient
Successfully signed certificate request for puppetmaster

Now the Puppet master can communicate and control the agent node.

On the Puppet agent node, test the Puppet master and agent communication with the following command:

/opt/puppetlabs/bin/puppet agent --test

If all goes well, you should get the following output:

Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Info: Caching catalog for puppetclient
Info: Applying configuration version '1599300398'
Notice: Applied catalog in 0.02 seconds

Conclusion

Congratulations! you have installed and configured Puppet master and agent on Ubuntu 20.04 server. You can now easily add multiple agents and manage them easily with Puppet.Advertisement


Source link