The assignment can found on:


search for “h3”

a) Install more than one slaves for a master. At least one real machine and many virtual slaves.

b) gather information about your slaves: MAC-numbers, virtual or real etc.

c) slave script: make a script that turns a machine into a slave for dedicated master

I do this assignment on my home pc which has following specs:

  • Processor: Intel(R) Core(TM) i5-4460 CPU @ 3.20GHz (4 CPUs), ~3.2GHz
  • RAM: 24 Gt
  • Graphics card: Radeon (TM) RX 480 Graphics 8 Gt

Motherboard: ASRock H97M Anniversary edition

Operating system is xUbuntu 16.04.3 LTS on a Live-USB stick which has 4 GB of RAM

Before starting I did the following :

  • Copy my startup script which will do the following:
     – Changes keyboard layout to finnish “
    – Installs updates “
    – Installs git “
    – Installs puppet “
    – Copies h1 module from https://github.com/EmreJM/h1.git
    – Moves module to where it should be which is /etc/puppet/modules “
    – Applies the h1 module (which just installs ssh currently)”
  • We don’t need every single thing that this script does but it will do some of them with two commands and I’m lazy. So to get my script:
    $ wget https://raw.githubusercontent.com/EmreJM/startupscript/master/startupsettings.sh
  • Run it:
    $ bash startupsettings.sh

Whole assignment took me 8 hours to complete.


I won’t do the assignment immediately step by step as it’s been given, instead I will first do a regular vagrant slave by hand and then a script that will do bunch of virtual slaves. Then I will gather the information and switch to my laptop, try to create slave script, run it, gather it’s information and complete the assignment.


So I will create my slave by using vagrant, first things first I need to change hostname just to simplify things.

$ hostnamectl set-hostname mas

“mas” is the hostname, it’s just first three letters of master.

$ sudoedit /etc/hosts

I added mas next to xubuntu just like in the previous assignment.
Then install vagrant:

$ sudo apt-get -y install virtualbox vagrant

After that I like to just create a new directory for my virtual machine command for that was:

$ mkdir nameofthedirectory

Install virtual machine by:

$ vagrant init bento/ubuntu-16.04

Start it:

$ vagrant up

Now open up a new terminal to make things easier by pressing:


In this new clean terminal connect to your new virtual machine by:

$ vagrant ssh

There is our new virtual machine! Now switch back to your original terminal since we this whole master-slave setup.


Install the puppet master:

$ sudo apt-get -y install puppetmaster

Stop it:

$ sudo service puppetmaster stop

Delete old certificates:

$ sudo rm -r /var/lib/puppet

Edit puppet.conf file:

$ sudoedit /etc/puppet/puppet.conf

Inside type the following:

dns_alt_names = mas

Then start it again:

$ sudo service puppetmaster start

Slave – Virtual Machine

(if you are asked for a password anywhere just type default password for vagrant which is “vagrant”)

Again let’s change the hostname to simplify things:

$ hostnamectl set-hostname sla

and then check your master machine’s IP address if you don’t know it, and copy it. Command for that is ifconfig and IP address is next to “inet addr:”

After that type the following:

$ sudoedit /etc/hosts

Type your new name next to vagrant.vm and under it type your master’s IP address and it’s name next to it.


Save it, leave it and then install puppet:

$ sudo apt-get -y install puppet

Edit .conf file:

$ sudoedit /etc/puppet/puppet.conf

In the very end of this file type:

server = mas


$ sudoedit /etc/default/puppet

Inside type the following:


Restart puppet agent

$ sudo service puppet restart

Now switch to your master

Master (mas)

Get certificate list:

$ sudo puppet cert --list

sign sla:

$ sudo puppet cert --sign sla.vm

(wordpress tend to change some of the commands so if you see single line before a command it’s actually double line)

Now switch back to the vm

Slave – Virtual Machine

Just use the following command:

$ sudo puppet agent -tvd

You should read the outcomes and make changes to according to those, sometimes the requited command is also given for you to use for example $ sudo puppet agent –enable

After that I did the same helloworld method found on my teachers website ( http://terokarvinen.com/2012/puppetmaster-on-ubuntu-12-04 ) , I did the same thing on the previous assignment.


This is it we made a new vm and established a connection to it! Now a script that will do three virtual machines.


Before writing the script I would like you to create new folder at /home then type and enter following just to get a better grasp on things or you can just skip to the script itself:

$ vagrant init bento/ubuntu-16.04
$ nano Vagrantfile

Inside Vagrantfile youcan find a bunch of comments and some text which works as a template. Now in this file we will be writing our script you could delete the comments (lines starting with #) or leave them although if you haven’t done this before whole thing seem a lot more confusing and you just delete whole file with:

$ rm Vagrantfile

then create a new one with the same name and write in the empty file. What I did is the latter one but the point is we are not writing a shell script like the last time instead a file that is know to vagrant beforehand.

The Script

I found this script at: https://github.com/poponappi/vagrant-puppet/blob/master/Vagrantfile

Here’s the script:


# https://github.com/poponappi/vagrant-puppet/blob/master/Vagrantfile
# http://TeroKarvinen.com/
# vim: filetype=ruby

$tscript = <<TSCRIPT
apt update
apt install -y puppet
echo "MASTERIPADDRESS NAMEOFTHEMASTER" |sudo tee --append /etc/hosts
echo "[agent]"|sudo tee --append /etc/puppet/puppet.conf
echo "server = NAMEOFTHEMASTER"|sudo tee --append /etc/puppet/puppet.conf
puppet agent --enable
service puppet restart

Vagrant.configure(2) do |config|
config.vm.box = "bento/ubuntu-16.04"
config.vm.provision "shell", inline: $tscript

config.vm.define "slave01" do |slave01|
slave01.vm.hostname = "slave01"

config.vm.define "slave02" do |slave02|
slave02.vm.hostname = "slave02"

config.vm.define "slave03" do |slave03|
slave03.vm.hostname = "slave03"


It’s very simple when you look at it just like the last time’s shell script, if start from the top and go down you can see that the regular commands and the steps that we used in this previous assignment can be found here, just remember to change hostipaddress and hostname in if you copy this.

There are some parts that we have to do for ourselves so after you are done with your Vagrantfile save it, leave it and then start it:

$ vagrant up

after that the just have to sign the certificates, slaves are named “slave01”, “slave02” and “slave03” so when signing, names should be exactly the same but if not you can see the actual name after the $ sudo puppet cert list command, for now I will sign only one slave:

$ sudo puppet cert list
$ sudo puppet cert --sign slave02

After that switch to you slave and type -tdv command:

$ vagrant ssh slave02
$ sudo puppet agent -tvd


Now  for the miscellaneous informations, they can be found on /var/lib/puppet/yaml/facts/NAMEOFTHESLAVE

to access the yaml you will need root rights for that type:

$ sudo su

after you’re done with it just type:

$ exit

anyway here’s the info of slave02:


We still have to do one slave on a real machine and make a script for it.


I got the base script from here: https://github.com/suomisim/puppet/tree/master/modules

the script that turns my laptop into a slave, it can be found here:


it’s just an module version of previous assignment. It’s also lacking in some parts so it’s not completely automated but works none the less.
















Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s