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
The puppetserver version used here is 6.20.0
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
- 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
-
Install puppetserver:
sudo apt-get install puppetserver -
Start the puppertserver service:
sudo systemctl start puppetserver
To check if the puppetserver is running
- 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:
- Restart the puppetserver:
sudo systemctl restart puppetserver
Configuration
- Edit the puppet.conf file in the directory above, Change the
certnamepart in the the end of the puppet.conf to this:
[main]
certname=mgmt-c.foo.org.nz
- 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
- Go inside that directory above and create the file
site.pp - 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
- 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
-
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) -
In the nano editor, add this to the end of the file:
- Restart the puppet server:
sudo systemctl restart puppet - 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
Restart the puppet agent: sudo systemctl restart puppet
- Setup certificate
- Check that the connection is successful:
sudo /opt/puppetlabs/puppet/bin/puppet agent --server=mgmt-c --no-daemonize --verbose --onetime
Sign the certificate for the database server in the mgmt server
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 }
}