Installation and Setup
Courses:
For single node installation and stand-alone modes, check out the following tutorials:
Installation
You can follow the instructions based on your OS, but here is the instructions for Debian-based systems:
source (includes multi-node setup)
wget https://apt.puppet.com/puppet7-release-focal.deb
sudo dpkg -i puppet7-release-focal.deb
sudo apt-get update -y
# for puppet server:
sudo apt-get install puppetserver -y
# for puppet agent:
sudo apt-get install puppet-agent -y
The following script can be used to quickly setup the installation on a single-node configuration
where we can then use puppet apply to apply the configuration.
sudo apt update -y
sudo apt upgrade -qy
wget https://apt.puppet.com/puppet7-release-focal.deb
sudo dpkg -i puppet7-release-focal.deb
sudo apt-get update -y
sudo apt-get install puppetserver -y
/opt/puppetlabs/bin/puppet --version
/opt/puppetlabs/bin/puppet module install puppetlabs-docker --version 4.1.2
sudo cp -r /home/vagrant/.puppetlabs/etc/code/modules/* /etc/puppetlabs/code/environments/production/modules/
Then, log out and log back in for the puppet to be available again without having to provide
the full path.
The following script can be used to apply the configurations to the current VM:
sudo /opt/puppetlabs/bin/puppet apply /etc/puppetlabs/code/environments/production/manifests/test.pp
Setup Configuration
Before anything, set up host resolution for master and agent:
sudo nano /etc/hosts
# format: [puppet master ip] master.puppet.vm puppet
# format: [puppet client ip] agent.puppet.vm
Look at the puppet installation configurations:
sudo nano /etc/default/puppetserver
In the JAVA_ARGS section, you can update -Xms and -Xmx to change the amount of memory puppet is taking.
Then, start the puppetserver:
sudo systemctl start puppetserver
sudo systemctl status puppetserver
sudo systemctl enable puppetserver
Note: If there was error with permission creating folders, change the owner of puppet folder:
sudo chown -R puppet:puppet /etc/puppetlabs/
Then, we can change which puppet server the client is going to point to (can be itself):
sudo nano /etc/puppetlabs/puppet/puppet.conf
Then, we can add something like this (to point to itself):
[agent]
server = master.puppet.vm
or for the client:
[main]
certname = agent.puppet.vm
server = master.puppet.vm
Add the ruby installed with puppet to the PATH in .bashrc:
PATH=$PATH:/opt/puppetlabs/puppet/bin
Test the installation by using gem. Install the package r10k:
# r10k can be used to get the GitHub config down to our server
gem install r10k
Then, run the agent to test installation and configuration:
sudo puppet agent -t
Sign the certificates for agents using:
sudo puppetserver ca sign --all
Setup Control Repo
In this stage, we will setup the control repo using r10k:
mkdir /etc/puppetlabs/r10k
nano /etc/puppetlabs/r10k/r10k.yaml
Paste the following into the r10k.yaml file:
---
# The location to use for storing cached Git repos
:cachedir: '/var/cache/r10k'
# A list of git repositories to create
:sources:
# This will clone the git repository and instantiate an environment per
# branch in /etc/puppetlabs/code/environments
:my-org:
remote: 'https://github.com/$YOUR_GITHUB_USERNAME$/control-repo.git'
basedir: '/etc/puppetlabs/code/environments'
Then, we can use the r10k command to deploy the repo:
r10k deploy environment -p
Check the progress in our environments:
cd /etc/puppetlabs/code/environments/
ls
# we should have our branches here