Puppet ‐ How to setup and configure - KeegMitch/Operations-Engineering-group-c GitHub Wiki

Set up puppetmaster on the management server

Installation

Note: The Puppet version we used in this example is 6.28.0

image

The puppetserver version used here is 6.20.0

image

Make sure any version of puppet that exists is uninstalled and removed as it will conflict any version you're using. If you need to do this , use this command: sudo apt remove puppet/sudo apt remove puppetserver, you may need to do sudo apt autoremove as well

  1. Download the puppet version 6.2:
sudo wget https://apt.puppetlabs.com/puppet6-release-bionic.deb
sudo dpkg -i puppet6-release-bionic.deb
sudo apt update
  1. Install puppetserver: sudo apt-get install puppetserver

  2. Start the puppertserver service: sudo systemctl start puppetserver

To check if the puppetserver is running

image

  1. Before you go to the config, go to sudo vim /etc/hosts, and add the private ip addresses of both the mgmt and db server (on the mgmt server itself) and the new dns name:

image

image

  1. Restart the puppetserver: sudo systemctl restart puppetserver

Configuration

  1. Edit the puppet.conf file in the directory above, Change the certname part in the the end of the puppet.conf to this:
[main]
certname=mgmt-c.foo.org.nz

image image

  1. Create this directory: sudo mkdir /etc/puppet/code/environments/production/manifests
cd /etc/puppet
sudo mkdir code
cd code
sudo mkdir environments
cd environments
sudo mkdir production
cd production
sudo mkdir manifests
cd manifests
sudo touch site.pp
  1. Go inside that directory above and create the file site.pp
  2. Restart puppetmaster with the command, sudo systemctl restart puppetmaster

Install and connect an agent

Make sure any version of puppet that exists is uninstalled and removed in the db server as well as it will conflict any version you're using. If you need to do this , use this command: sudo apt remove puppet, you may need to do sudo apt autoremove as well

  1. Download, install, and start the puppet agent service using the following commands:
wget https://apt.puppetlabs.com/puppet6-release-bionic.deb
sudo dpkg -i puppet6-release-bionic.deb
sudo apt update

sudo apt-get install puppet-agent
sudo systemctl start puppet

image

  1. Configure the puppet agent server using this command: sudo nano /etc/puppetlabs/puppet/puppet.conf (you can't use vim on the db server as it's uninstalled)

  2. In the nano editor, add this to the end of the file:

image

  1. Restart the puppet server: sudo systemctl restart puppet
  2. Before checking the connection, go into the hosts file on the db server and enter the private ip address and the new dns hostname using the nano editor: sudo nano /etc/hosts

image

Restart the puppet agent: sudo systemctl restart puppet

  1. Setup certificate

image

image

  1. Check that the connection is successful: sudo /opt/puppetlabs/puppet/bin/puppet agent --server=mgmt-c --no-daemonize --verbose --onetime

image

image

image

Sign the certificate for the database server in the mgmt server

image

Add a node to site.pp on mgmt server

Path is: /etc/puppetlabs/code/environments/production/manifests/site.pp

node 'db-c.foo.org.nz' {
package { 'vim': ensure => present }
}

image

References: