Joni Junni

Configuring Puppetmaster and client-server testing

Categories: [school]
Tags: [apache], [linux], [puppet], [vagrant], [debian], [puppetmaster], [ubuntu], [linux-centralized-management-course]

Steps:

  1. Install Vagrant and create VMs using a Vagrantfile
  2. Setup Avahi and test connectivity between VMs
  3. Install and configure Puppetmaster
  4. Install and configure Puppet on client VMs
  5. Configure modules to deploy from master VM

Installing Vagrant and creating Vagrantfile

I started by installing Vagrant to my development machine:

sudo apt-get install vagrant

Then I created a new project directory and created a Vagrantfile into it:

mkdir -p ~/Projects/puppetmaster  
cd ~/Projects/puppetmaster  
nano Vagrantfile

I wrote this into the Vagrantfile:

    Vagrant::Config.run do |config|
            config.vm.define :puppetmaster do |master_config|
                    master_config.vm.box = "puppetmaster"
                    master_config.vm.box_url = "http://files.vagrantup.com/precise32.box"
                    config.vm.network :bridged
            end

            config.vm.define :apache do |apache_config|
                    apache_config.vm.box = "apache"
                    apache_config.vm.box_url = "http://files.vagrantup.com/precise32.box"
                    config.vm.network :bridged
            end

            config.vm.define :mysql do |mysql_config|
                    mysql_config.vm.box = "mysql"
                    mysql_config.vm.box_url = "http://files.vagrantup.com/precise32.box"
                    config.vm.network :bridged
            end
    end

The code above tells Vagrant to create two virtual machine instances named “apache” and “mysql” from the default Ubuntu Lucid box. It will also make Vagrant to put the virtual machines into a bridged network, so the virtual machines vill get the IP straight from the physical network that the host machine is connected.

Finally, I created the virtual machines:

vagrant up

After about 5 minutes, I had three functional virtual machines:

vagrant-three-vms

Configure the enviroment

To get the Puppetmaster working, it is needed that the virtual machines can connect to themselves and knows their hostnames. I needed to change the hostname in these files:

changed-hostname steps

After I changed the the hostname, I installed avahi-utils for the FQDN-names to work(eq. puppetmaster.local). Lastly i restarted the VM so the settings would come live. This step needs to be done all of the virtual machines, as I do not have a functional DNS-server in my environment.

Installing and configuring puppetmaster

I created three virtual machines in the previous step: puppetmaster, apache and mysql. First, I will install and configure Puppetmaster to the puppetmaster-machine:

vagrant ssh puppetmaster

Install Puppetmaster:

sudo apt-get update  
sudo apt-get install puppetmaster

Configure Puppetmaster

As in Tero’s tutorial, I needed to stop the service, remove created certificates, edit the config file to match my FQDN an restart the service:

sudo service puppetmaster stop  
sudo rm -r /var/lib/puppet/ssl  
sudo nano /etc/puppet/puppet.conf

In the puppet.conf I needed to add the dns_alt_names line to the configuration file:

puppet.conf-editing

sudo service puppetmaster start

After that it shows the newly created certificates:

sudo ls /var/lib/puppet/ssl/certs/

puppetmaster-certificates

Configuring the client machines

Install puppet:

sudo apt-get install puppet

Edit the /etc/puppet/puppet.conf and add the server FQDN to it:

sudo nano /etc/puppet/puppet.conf

agent-config

Because Puppet is not started automatically by default, we need to edit the /etc/default/puppet file and set START=yes:

puppet-autostart-config

After doing the configuration, restart the Puppet agent:

sudo service puppet restart

Accepting the client machine certificates

Go to the puppetmaster VM:

sudo puppet cert --list

Sources