h5

The assignment can found on:

http://terokarvinen.com/2017/aikataulu-palvelinten-hallinta-ict4tn022-3-5-op-uusi-ops-loppusyksy-2017-p5

search for “h5”

a) Create puppet slaves that contain at least two different operating systems

b) Customize windows desktop. You can for example install a software and make pre-determined changes to it


You will need a bootable USB stick with windows 10 image inside!

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

I will also using my laptop, booted from same USB stick

laptop specs:

  • Processor: Intel Core i5-2430M @ 2.40 Ghz (4 CPUs)
  • Ram: 8 GB
  • Graphics card: Intel HD Graphics 3000

I also have router that has Wi-Fi function to which I used my laptop to connect.

For the windows slave I use an another laptop with following specs:

  • Processor: AMD Athlon(tm) II P340 Dual-Core Processor
  • RAM: 8 GB

And needless to say I skip the next script for it will be a windows slave.

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 6 hours to complete.

a) Linux slave

Just like in the previous assignments (h2 and h3) I used the same method to create my linux slave, so I will go over this part very quickly.

$ hostnamectl set-hostname mas
$ sudoedit /etc/hosts

Inside hosts file name of the host next to xubuntu (mas)

$ sudo service avahi-daemon restart
$ sudo apt-get -y install puppetmaster
$ sudo service puppetmaster stop
$ sudo rm -r /var/lib/puppet
$ sudoedit /etc/puppet/puppet.conf

Inside: dns_alt_names =  mas.local

$ sudo service puppetmaster start

Slave:

$ hostnamectl set-hostname sla 
$ sudoedit /etc/hosts

Inside hosts file name of the host next to xubuntu (sla)
and master IP address to the next row with the name of the master

$ sudo apt-get -y install puppet
$ sudoedit /etc/puppet/puppet.conf

Inside:
[agent]
server = mas.local

$ sudoedit /etc/default/puppet

Inside: START=yes

$ sudo service puppet restart

Master

$ sudo puppet cert --list
$ sudo puppet cert --sign sla

Slave

sudo puppet agent -tvd

donedlinuxsla

a) Windows slave

For the next part I used my teachers own documentation for guidance:

http://terokarvinen.com/2016/windows-10-as-a-puppet-slave-for-ubuntu-16-04-master

http://terokarvinen.com/2016/automatically-install-a-list-of-software-to-windows-chocolatey-puppet-provider

With the bootable USB ready in the hand, I start by doing clean install.

I didn’t create or type my e-mail during the installation and I also disabled all the unwanted stuff (none of that express setting).

After the initial part we have to disable UAC, just search for uac and pull it down to Never:

uac

uac2

Now do reboot to apply this setting.
After the reboot download puppet agent, it has to be same version as the masters so check that before downloading.

To check your masters puppet version:

$ puppet --version

I have 3.8.5 installed so I will be installing that for my slave from here

https://downloads.puppetlabs.com/windows/

Pay attention to your master system image as well, my live usb which I used to boot my master had xubuntu-16.04.3-desktop-amd64. So the puppet agent I’m downloading is puppet-3.8.5-x64.msi

Install it as admin and type your masters name when asked:

ppmas

remember to put .local after it if it’s in local network which my laptop is.
Open your file explorer, and enable:

  • “Hidden files”
  • “File name extensions”

Press Ctrl + F1 on the file explorer and switch to View tab.
Then open notepad click on

File > Open

and head over to:

C:/ProgramData/PuppetLabs/Puppet/etc

Select “All files” if it’s on “Text Documents” and open the puppet.conf

asnee

Now check for your masters name if it’s there good, if it’s not you can add it right now.

adfij

Now download and install the Bonjour if you are using local network if not skip to the next part

Install it as admin:

https://support.apple.com/kb/DL999?locale=en_US

Now is time to ping you master

just open the cmd.exe as admin and ping it by it’s name.
After that search for “Start Command Prompt with Puppet” right click it and run it as admin. Then type and enter:

puppet agent -tvd

Switch to your master

Master

Classic key signing:

$ sudo puppet cert --list
$ sudo puppet cert --sign NAMEOFTHESLAVE

Switch to your slave

Slave

Type again:

puppet agent -tvd

Done!

Now switch to your master again for the next part.

Master

Type:

$ sudo puppet module install puppetlabs/windows

Then create a module:

$ sudoedit /etc/puppet/modules/firevlc/manifests/init.pp

Inside:


class firevlc {
   include chocolatey

   Package {
       ensure => "installed",
       provider => "chocolatey",
   }

   package {["firefox", "vlc"]:}

}

Lastly we have to add it to site.pp

$ sudoedit puppet/manifests/site.pp

Inside:

class {firevlc:}

Go to your slave.

Slave

Type again:

puppet agent -tvd

Capture2Done!

Advertisements

H4

The assignment can found on:

http://terokarvinen.com/2017/aikataulu-palvelinten-hallinta-ict4tn022-3-5-op-uusi-ops-loppusyksy-2017-p5

search for “h4”

a) Try Ansible

b) Try Salt


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

I will also using my laptop, booted from same USB stick

laptop specs:

  • Processor: Intel Core i5-2430M @ 2.40 Ghz (4 CPUs)
  • Ram: 8 GB
  • Graphics card: Intel HD Graphics 3000

I also have router that has Wi-Fi function to which I used my laptop to connect.

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.

So point of this assignment is just familiar ourselves with Ansible and Salt. To this point I have been using exclusively puppet, so I have no background information on these centralized management tools beforehand.

a) Ansible

Start by install ansible:

$ sudo apt-get -y install ansible

Then edit the hosts file:

$ sudoedit /etc/ansible/hosts

inside I typed group name and below that IP address of my slave (or the ansible equivalent) you can add more IP addresses if you desire:

[test]
10.0.0.1

My module installed ssh already, so we can skip that part and type the next command:

$ ssh-keygen -t rsa

this will generate a key and will ask destination to destination to store it and passphrase
if we want. I didn’t change the default destination or gave it a passphrase so just by pressing enter you can skip those parts.

After that type:

$ ssh-copy-id SLAVENAME@10.0.0.1

Inkedsshyhteys_LI

It might doubt the authenticity of host but since just set it up just type “yes”.Inkedsshonnistui_LI

After typing the password just connect it with ssh to which terminal is showing us what to type. Which is:

$ ssh SLAVENAME@10.0.0.1

Inkedsshpart2_LI

It works! You can exit by typing exit. Next I wanted to do a “hello world” test.

Ansible hello world

Now you can change your directory to /etc/ansible and make your test there or you could do it elsewhere, but make sure you are situated in the same directory when launching hello world.

I made to files named: host.yml and setup.yml

Inside host.yml:

[xubuntu]
10.0.0.1

That is slave name and it’s IP address, next setup.yml:

---
- name: Hello Ansible - quick start
  hosts: xubuntu
  user: xubuntu
  sudo: yes

  tasks:
    – name: Hello server
      shell: date >> now.txt

Remember to change hosts: and user values if needed, you have to be very careful when typing for ansible as it’s very sensitive about it.

Next type and run:

$ ansible-playbook ./setup.yml  -v -vvvv -u ubuntu -i ./host.yml

Inkedhelloworld_LI

Head over to your slave which in my case is my laptop, and it should look like this:

toimiiansible

now.txt is there!

Salt

 Start by installing salt-master to your master machine:
$ sudo apt-get -y install salt-master

Then switch over to your slave machine and install minion version of the same command we just typed:

$ sudo apt-get -y install salt-minion

Edit your minions file by:

$ sudoedit /etc/salt/minion

and inside type your masters IP address:

$ master: 10.0.0.1

Now switch back to your master and type:

$ sudo salt-key --list all

You should see unacknowledged key waiting there accept it by:

$ sudo salt-key -a xubuntu

Then you can test if pinging by:

$ sudo salt '*' test.ping

saltworksiguess

Now to test it will we installing apache to my slave. You can do this by:

$ sudo salt xubuntu pkg.install apache2

salteroni

Over to your slave localhost should like this:

saltttii

Sources:

http://atpras.blogspot.fi/2014/02/ansible-hello-world.html

https://github.com/joonaleppalahti/CCM/blob/master/salt/Salt%20raportti.md

http://terokarvinen.com/2017/aikataulu-palvelinten-hallinta-ict4tn022-3-5-op-uusi-ops-loppusyksy-2017-p5

 

 

 

 

 

 

 

 

 

h3

The assignment can found on:

http://terokarvinen.com/2017/aikataulu-palvelinten-hallinta-ict4tn022-3-5-op-uusi-ops-loppusyksy-2017-p5

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:

CTRL+ALT+T

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.


Master

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.

20171112_163643

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:

[agent]
server = mas

Then:

$ sudoedit /etc/default/puppet

Inside type the following:

START=yes

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.

tdv

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


Script

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
TSCRIPT

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"
end

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

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

 


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

itworks

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:

slave02.jpg

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


SlaveScript:

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:

https://github.com/EmreJM/makeslave

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.

 

Sources:

https://github.com/poponappi/vagrant-puppet/blob/master/Vagrantfile

http://terokarvinen.com/2015/install-ubuntu-virtual-machine-in-minutes-with-vagrant

http://terokarvinen.com/2017/multiple-virtual-computers-in-minutes-vagrant-multimachine

http://simosuominen.com/

http://terokarvinen.com/2017/provision-multiple-virtual-puppet-slaves-with-vagrant

http://terokarvinen.com/2012/puppetmaster-on-ubuntu-12-04

http://terokarvinen.com/2017/virtual-machine-in-two-minutes-install-vagrant-and-virtualbox-on-ubuntu-16-04-3-live-usb

https://stackoverflow.com/questions/8221820/cd-into-directory-without-having-permission

https://www.edureka.co/blog/10-steps-to-create-multiple-vms-using-vagrant/

http://simosuominen.com/2017/04/27/palvelinten-hallinta-kotitehtavat-4/#comments

https://github.com/suomisim/puppet/tree/master/modules

 

h2

Päätin tehdä blogi postaukset englannin kielellä tästä eteenpäin jotta blogini pääsee tavoittelemaan laajempaa yleisöä. Käännän aiemmat blogi postaukset myös ajan myötä.

I decided that from now on I will writing my blog posts in English to reach a wider audience. I will be translating my older posts as the time goes by.


The assignment can found on:

http://terokarvinen.com/2017/aikataulu-palvelinten-hallinta-ict4tn022-3-5-op-uusi-ops-loppusyksy-2017-p5

search for “h2”

a) Make script for your live-USB that will setup all your needed custom configurations with just two commands

b) Try Puppets master-slave architecture with two computers. Include list of keys (sudo puppet cert list) and log information from masters http log (sudo tail -5 /var/log/puppet/masterhttp.log)


Whole assignment took me 5 hours to complete.

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 :

  • I change the keyboard layout to finnish command for that is:
    $ setxkbmap -layout fi
  • Updates:
    $ sudo apt-get update

a) Script

(The script that I have made can be found over in case you are confused and need the finished file: https://github.com/EmreJM/startupscript/blob/master/startupsettings.sh )

In terminal create a shell script, command for that is:

$ nano startupsettings.sh

(you can put any other name that you desire just before .sh)

Inside the blank file type the following:

tput -T xterm setaf 6

echo ” This script will initialize/change next settings: “
echo ” “
echo ” – Changes keyboard layout to finnish “
echo ” – Installs updates “
echo ” – Installs git “
echo ” – Installs puppet “
echo ” – Copies h1 module from https://github.com/EmreJM/h1.git
echo ” – Moves module to where it should be which is /etc/puppet/modules “
echo ” – Applies the h1 module (which just installs ssh currently)”

tput -T xterm sgr0

setxkbmap -layout fi
sudo apt-get update
sudo apt-get install -y git puppet
git clone https://github.com/EmreJM/h1.git
cd h1
sudo mv sshnova /etc/puppet/modules/
cd
sudo puppet apply -e ‘class {“sshnova”:}’

tput -T xterm setaf 6

echo ” Done!”

tput -T xterm sgr0

Let’s take a look at the script

tput -T xterm setaf6 and sgr0: These commands will just change color of the text in the terminal

echo ” “: Here I have put my comments, which just describes what the script will do

after that I have put regular xubuntu commands just as they are in order I want them to be entered, and lastly I’m just informing the user that script has reached it’s end.

and now we can try this script. You can download my script that I have mentioned in the beginning of this post with the following command:

$ wget https://raw.githubusercontent.com/EmreJM/startupscript/master/startupsettings.sh

( You can get this link if you have your script in github just by opening it in raw format which is situated next to Blame and History buttons)

next we run the script

$ bash startupsettings.sh

doen

seems to be working fine!


b) Master-slave

For the next part of the assignment I use my Dell Latitude E5520 laptop which has following specs:

  • Processor: Intel Core i5-2430M @ 2.40 Ghz (4 CPUs)
  • Ram: 8 GB
  • Graphics card: Intel HD Graphics 3000

I also have router that has Wi-Fi function to which I used my laptop to connect.

Since I had only one Live-USB what I did was restart my PC and open up boot menu, after that I picked UEFI: USB Drive to boot from USB just as I would normally but this time when system asks if I want to Try xubuntu or install it I pressed “E” on my keyboard to while “Try without installing” selected and added toram just before the lines “—” on the second row with space, so the added line will look like:

toram —

This way I can remove my USB stick from my PC after it’s done with the boot up and stick it to the laptop.

First I pinged between my computers just to check if my setup do really work

for that i need IP addresses of both computers which can be found by typing:

$ ifconfig

The IP address is on the second row with the inet addr: in the beginning.

and pinging happens with the next command

$ ping IPADDRESS

It works! Now to simplify things I changed the hostnames but that is entirely optional, to change hostname:

$ hostnamectl set-hostname mas

I named mine “mas” but you changed to whatever you want.
Next I have to put this name to hosts file, to do that:

$ sudoedit /etc/hosts

My PC didn’t have USB stick inserted so it takes some time to accomplish some commands thats totally normal.
One open type the hostname next to xubuntu

hosts.jpg

Next restart the avahi-daemon:

$ sudo service avahi-daemon restart

I did the same thing on slave computer and named it “sla”

Come back to master and do the following

mas (Master)

Install puppetmaster:

$ sudo apt-get -y install puppetmaster

Stop the puppetmaster, because we are going to some purging

$ sudo service puppetmaster stop

and

$ sudo rm -r /var/lib/puppet

We have to edit puppet.conf file

$ sudoedit /etc/puppet/puppet.conf

Type the following to the very end:

$ dns_alt_names = puppet, mas.local

And then start it by:

$ sudo service puppetmaster start

Now switch to the slave and do the following

sla (Slave)

Install puppet:

$ sudo apt-get -y install puppet

edit conf

$ sudoedit /etc/puppet/puppet.conf

Again type the following to the very end

[agent]
server = mas.local

Next a brand new file will be created with:

$ sudoedit /etc/default/puppet

Inside type the following:

START=yes

Let’s restart it:

$ sudo service puppet restart

Go to your mastes now

mas (Master)

And type the following

$ sudo puppet cert –list

$ sudo puppet cert –sign sla

Next I will be testing if this is working, I did the exact same thing on my teachers site here http://terokarvinen.com/2012/puppetmaster-on-ubuntu-12-04

We are still on master so lets type the following

$ cd /etc/puppet

$ sudo mkdir -p manifests/ modules/helloworld/manifests/

$ sudoedit manifests/site.pp

Inside type exactly the following

include helloworld

Save it, leave it and then type the next:

$ sudoedit modules/helloworld/manifests/init.pp

Inside write:

class helloworld {
file { ‘/tmp/helloFromMaster’:
content => “Is this working?\n”
}
}

And now hop on to your slave, type the following

$ sudo service puppet restart

$ cat /tmp/helloFromMaster

Done!

Lastly informations that were requested:

certlist

Sources:

https://mikkoknutas.wordpress.com/2017/11/02/h2-scriptin-asennus-ja-master-slave-arkkitehtuurin-testaus/#more-194

http://renki.dy.fi/linux2/tehtava2.php

http://terokarvinen.com/2012/puppetmaster-on-ubuntu-12-04

H1

Tehtävänanto löytyy sivulta:

http://terokarvinen.com/2017/aikataulu-palvelinten-hallinta-ict4tn022-3-5-op-uusi-ops-loppusyksy-2017-p5

 

h1. a) Asenna jokin muu demoni kuin Apache. Raportoi, miten rakensit, selvitit ja testasit kunkin osan (esim. sudo puppet resource, puppet describe, lähteet…). Julkaise myös modulisi lähdekoodi niin, että sen voi helposti ottaa käyttöön.

b) Opiskele esitiedot (yllä) (tästä b-kohdasta ei tarvitse raportoida, kysellään tunnilla).

c) Opiskele

http://terokarvinen.com/2013/hello-puppet-revisited-%E2%80%93-on-ubuntu-12-04-lts

https://docs.puppet.com/puppet/3.8/lang_summary.html

http://terokarvinen.com/2016/publish-your-project-with-github

(tästä c-kohdasta ei tarvitse raportoida, kysellään tunnilla).

Vinkkejä:

– Käytä package-file-service -rakennetta.

– Voit julkaista modulisi GitHubissa.

– Raportti on helppo kirjoitaa GitHubiin MarkDown-tekstinä.

– Lue opiskeltavat artikkelit ennenkuin teet tehtävän

– SSH lienee helpoin demoni asentaa. Jos olet jo taitava Puppetissa, voit asentaa haastavampia vaihtoehtoja, kuten LAMP:in.


Koneen tiedot jossa harjoitusta tein:

  • Prosessori: Intel(R) Core(TM) i5-4460 CPU @ 3.20GHz (4 CPUs), ~3.2GHz
  • RAM: 24 Gt
  • Näyttöohjain: Radeon (TM) RX 480 Graphics 8 Gt
  • Emolevy: ASRock H97M Anniversary edition

Käyttöjärjestelmänä USB Live tikussa sijaitseva xUbuntu 16.04 LTS.

Ennen harjoitusta varten tehdyt valmistelut:

  • Näppäinmistön kielen vaihtaminen suomen kieliseksi, koodi siihen on:
    $ setxkbmap -layout fi
  • Päivitys:
    $ sudo apt-get update

SSH puppet moduuli

Aloitin heti asentamalla puppetin, koodi siihen on:

$ sudo apt-get install puppet && sudo apt-get install ssh

mennään mooduulit kasioon jotta päästään luomaan alustavat kansiot polku siihen on:

/etc/puppet/modules/

 

loin kansion nimeltä sshnova” nimellä kuitenkaan ei ole väliä kunhan muistat laittaa oikean nimen sitten init.pp tiedostoon class kohdalle mikä tulee myöhemmin.

kuitenkin komento kansion luomiseen oli:

$ sudo mkdir sshnova

mennään tähän kansioon ja luodaan kaksi uutta kansiota tänne

$ cd sshnova

$ sudo mkdir manifests/ templates/

kopiodaan ssh_config tiedostoa mikä tuli kuin asennettiin ssh:ta tämän harjoituksen alussa ja liitettään sitä juuri luomaamme templates/ kansioon

$ sudo cp /etc/ssh/sshd_config templates/

(jos sshd_config tiedostoa ei löydy asenna ssh demoni erikseen komennolla

$ sudo apt-get install openssh-server

)

mennään manifests kansioon mitä me luottiin ja tänne luodaan init.pp tiedosto

$ sudo nano init.pp

Kirjoitetaan seuraavasti:


 

class sshnova {

package { ‘ssh’:

ensure => ‘installed’,

allowcdrom => true,

}

file { ‘/etc/ssh/sshd_config’:
content => template(‘sshnova/sshd_config’),
notify => Service[‘ssh’],
}
service { ‘ssh’:
ensure => ‘running’,
enable => true,
provider => ‘systemd’,
}

}


 

Ctrl + X, y ja Enter

Nyt ollaan valmiita poistetaan ssh ja ajetaan meidän moduuli, katotaan miten käy.

komento ssh:n poistamiseen on:

$ sudo apt-get purge ssh

komento moduulin ajamiseen on:

$ sudo puppet apply -e ‘class {“sshnova”:}’

Screenshot_2017-10-26_18-54-18

Nyt pitäis asentaa git ja heittää tämä moduli sinne.

Tallennus Git repository:iin

Asennetaan git

$ sudo apt install git

Kopioidaan hakemisto

$ git clone https://github.com/EmreJM/h1.git

mennään tähän kopioduun hakemistoon ja siirretään meidän moduulit

$ cd h1

(Tällää löytyy repossitory:n tiedostot)

$ sudo cp -R /etc/puppet/modules/sshnova/ /home/xubuntu/h1

Tallennetaan meidän lisäykset

$ git add .

Annetaan käyttäjätunnus ja salasana

$ git config –global user.email “sählöposti@jotain.com”

$ git config –global user.name “Erkki Esimerkki”

Tämän jälkeen hyväksytään muutokset ja kerrotaan että mitä ollaan lisätty

git commit

sitten

$ git pull && git push

annetaan käyttäjätunnus ja salasana ja se olis siinä

Tähän meni 4 tuntia.