How to Install Puppet on Ubuntu Server
Puppet is a configuration management tool commonly used by system administrators to automate the provisioning and configuration of servers. In this tutorial, we will show you how to install Puppet on Ubuntu Server and get started with its usage.
Prerequisites
To install Puppet on your Ubuntu Server, you need to have the following prerequisites:
- A Ubuntu Server up and running.
- A sudo user account.
Step 1: Installing Puppet Repository
Puppet provides a repository to make it easy to install and update. Follow these steps to add the Puppet repository to your Ubuntu Server:
- Log in to your Ubuntu Server.
- Open the terminal application.
- Run the following command to download and add the Puppet repository:
$ wget https://apt.puppetlabs.com/puppet6-release-bionic.deb
$ sudo dpkg -i puppet6-release-bionic.deb
Step 2: Installing Puppet Server and Agent
After adding the Puppet repository, you can now go ahead and install the Puppet server and agent. Here is how to do it:
- Run the following command to update the local repository:
$ sudo apt update
- To install the Puppet server and agent, run the following command:
$ sudo apt install puppetserver puppet-agent
- After the installation is complete, start the Puppet server by running the following command:
$ sudo systemctl start puppetserver
Step 3: Configuring the Puppet Agent
Now that you have installed the Puppet server and agent, you need to configure the agent to connect to the server. Here is how to do it:
- Open the
/etc/puppetlabs/puppet/puppet.conffile using your favorite text editor.
$ sudo nano /etc/puppetlabs/puppet/puppet.conf
- Add the following lines to the file to set up the Puppet server:
[agent]
server = <PUPPET_SERVER_IP_ADDRESS>
Save the file and exit.
Restart the puppet agent by running the following command:
$ sudo systemctl restart puppet-agent
Step 4: Performing a Test Run
To verify that the Puppet server and agent are set up properly, you can perform a test run. Here is how to do it:
- On the Puppet server, run the following command to create a test manifest file.
$ sudo nano /etc/puppetlabs/code/environments/production/manifests/site.pp
- Add the following lines to the file:
node default {
file { '/tmp/testfile.txt':
content => "Hello Puppet!\n",
}
}
Save the file and exit.
On the agent machine, run the following command to trigger a Puppet run:
$ sudo /opt/puppetlabs/bin/puppet agent --test
- After the Puppet run is complete, check the
/tmp/testfile.txtfile on the agent machine to confirm that it was created.
Conclusion
You have successfully installed Puppet on your Ubuntu Server and performed a test run. You can now configure more complex configurations and automate your infrastructure. Refer to the official Puppet documentation for more information on how to use Puppet.