Haaga-Helia Business IT student.

I started to continue my own module, which i started earlier during my last lecture. Everyone in the class had to reserve a puppet module that could do something useful, for example I chose to create a module that could help our school’s programming students, by installing Java, IntelliJ/Eclipse, localhost (apache2) and to do the right configuration.

Everything so far installs fine, and localhost is running. BUT, when i first try to change the index.html file away from the apache2 default page, and after that changing the directory into /java, and change the index.html into index.java, It still cannot add java into there.

Not right…. To be continued. Next time I’ll install eclipse/IntelliJ text editor atleast.

Report ending time: 15:38

15.5.2017, 12:12

Time to continue my module, after a super stressful work week.

I decided to delete the file scripts for now, because first i want to get an IDE to work. I’m planning to install IntelliJ, or Eclipse, because those are the main programming environments for our programming students.

It seems that if i want to install one of those, it has to be downloaded and extracted as a .tar file…

Time flew and I started to work with a bash file, then I curiously tried to do a command: sudo-apt get install eclipse and it started to install everything!? I thought this can’t be true but it did.. and it works!

This is how it looks when you open eclipse.

Now it was time to put the eclipse installment script to my module, and my module now looks like this:

After a long day, and interviewing some programming students, I realized that they don’t even use localhost to do programming. They use eclipse or IntelliJ, and they run their java code in that platform. I still decided to keep localhost and apache if they want to implement some HTML code, and later add some java to it? (No idea if it’s possible though.).

Again I started xubuntu with livestick, and wrote setxkbmap fi and sudo apt-get update to get started! I also installed puppet, because I usually just create the manifests and init.pp and copy-paste my old puppet code from this report.

Now it was time to think about how to open eclipse after the installation of java and all the other required for this module. I tried to search the internet until I asked my classmate who is doing a module about music programs, and the module opens them all after the installations. So I asked him and he linked me to his github, and I found out that it has to be done as exec.

So i put the exec script to my module, cleaned the scripts a little bit, fixed some typos and this is how my code looks and it believe me or not, actually works! It installs all the required things, and after that it opens the eclipse, where the student can setup it with couple of clicks. I was too afraid to try to configure the path locations for eclipse, because it’s mainly done by the students, and they might feel more comfortable by being able to choose the locations themselves, when starting a new java project. Eclipse is a graphical (not terminal looking) IDE program, so thats why.

I also cleaned the outlook of the code a little bit, so it’s easier to recognize the main things.

Now it’s getting quite late, and tomorrow is the last day to do some final scripts. I was thinking about doing some shell scripts to bash open this module, and copy it from git.

Report ending time: 23:54

16.5, 13:19

Today I came to school to finish my module, I was accompanied with my classmate Leo Jääskeläinen. I can focus much better in school. So now I’m pretty much done with my module, except that I want to create a shell script combined with git, and it would also run my module.

I started with the commands: setxkbmap fi to get the nordic alphabets, and after that I continued by installing puppet, git and by doing sudo apt-get update.

I created a new git repository, and cloned it straightaway. That’s the repository where I’m going to put my module to.

After a lunch I started my linux again to run my scripts from the scratch. I wrote setxkbmap fi, sudo apt-get update and installed git with the command sudo apt-get install git.

After that I cloned my git repository from terminal and ran my script.

It takes quite a long time to run the script, and it never finishes it after eclipse pops. The script is over after I close eclipse. Then I realized that I had to put a & mark to one of the lanes in the openeclipse exec script, in my init.pp. Now the part looks like this:

I started by booting Xubuntu by a livestick, and the first thing i did, was to open terminal and to write the usual command: setxkbmap fi to get the nordic alphabets, (ä, å ö).

Now it was time for the homework:

h4. a) Master-slave. Start from an empty computer. Use the other computer as a slave, and the other computer as a master. Try that the slave gets a module from the master. Insert logs too!

Firstly, i opened our group’s github, where we wrote some material based on earlier class’s master-slave assignments. We’ve already tried master-slave during earlier class, but now it was time to do it independently(ish), with other classmates.

SLAVE:

I decided to be a slave first, so i started by updating my packets, and to install puppet (no need to install puppetmaster as a slave..):

$ sudo apt-get update
$ sudo apt-get install -y puppet

Now that we have puppet installed, we don’t even necessarily need to create manifests folders etc, because the master will have them for us. (t-thank you master.)

First its good to change the hostname, so it’s easier for the master to recognize the accessing people. I changed the hostname with the command:

$ sudo hostnamectl set-hostname kermorvant

Now my hostname is changed, and it’s time for the next changes.

The master’s hostname is apina, so now i have to change information from my puppet.conf file.

$ sudoedit /etc/puppet/puppet.conf

Now inside the puppet.conf, I have to crate an [agent] bracket, and add the master’s hostname .local, like this:

Now it was time for the real connection. First i tried to ping apina.local, but it didnt let me, because we realized that my master’s laptop was not connected to the lab connection.. After connecting to the lab computer, the ping works!

Now to connect to the apina.local, I use the command:

$ sudo puppet agent -tdv

This had to be done 2 times. First you try to connect to master, but can’t access because the master has to sign it, after that I had to write the same command again, and we’re in!

And now it was time to try the master’s own module:

$ cd /tmp
$ cat apinat.txt

The module was based in the /tmp/ location.

MASTER:

Now it was time to be a master.

First i purged my puppet, and installed puppetmaster:

$ sudo apt-get purge puppet
$ sudo apt-get install puppetmaster

First it didn’t let me do any further installing/uninstalling commands because I had forgotten to change my hostname from the hosts file to kermorvant, it was still marked as xubuntu. To change the hostname, i fixed it like this:

$ sudoedit /etc/hosts

Now it was time to officially start as a master.

Now it was time to change some information again in the puppet.conf file.

$ sudoedit /etc/puppet/puppet.conf

I took the [agent] bracket away, and created a [master] bracket and inserted some new info (written below).

I created a dns_alt_names with my hostname and .local to the end, so my upcoming slaves can connect to me.

Now before I start my puppetmaster, it’s time to do a module to a /tmp/ file, which the slaves can run with a cat command. I did the module (as usual) to the manifests folder. The order goes like this:

After writing the module, there’s one new thing to do also. We have to go back to the original manifests folder, which is located in the /etc/puppet location, and then have to write some new script there, which is simple:

$ cd /etc/puppet
$ cd manifests
$ sudo nano site.pp

class {"helloyk":}

Now it was time to start puppetmaster, with the command:

$ sudo service puppetmaster start

Now it was time for the slave to make a connection.

Now that the slave did his agent tdv command, i had to accept the connection with the commands:

$ sudo puppet cert list -all
$ sudo puppet cert sign "name"

After signing the cert, the slave had to do the tdv command again for the real connection.

As you can see, the cert is signed!

Now the slave wandered around my /tmp/, and ran the helloyk module that i did.

it works!

During my master phase, we stopped for quite a long time to wonder, why the slave couldnt connect to me. We had deleted the logs with the command

$ sudo rm -rf /var/lib/puppet/ssl/

without realizing that it should be done when puppetmaster is stopped, not on.. So figuring that out everything started to work. We tried to restart the slave’s computer etc before that, that’s why his hostname changed too.

I booted my Xubuntu from my USB memory stick (Livestick), which once again means that it’s started fresh and i need to do my rituals.

First thing i did when i booted Linux, was to open terminal and type setxkbmap fi to get the nordic alphabets (ä, ö, å).

This time i was afraid to do anything else, for example sudo apt-get update, or to install anything because it might affect the homeworks, which are:

h3. a) Package-File-Server. Install and configure some demon in package-file-server style. Do something else than the sshd’s port switch that was shown in earlier class.

Most of the readers might know (classmates) that were at the earlier class, that we did a script using puppet, that installs SSH, switches port and shows changes done to the sshd- file. Now it was time to do something new… but what?

Inspired by at least two of my classmates, i decided to do a script that installs apache2, customizes the default index.html test page, and does the command sudo apt-get update before installing.

First it was time to install puppet to create my own module, and manifests inside that.

$ sudo apt-get update

$ sudo apt-get install puppet

$ y (I forgot to put -y before).

$ cd /etc/puppet/modules/

$ sudo mkdir helloyael

$ cd helloyael

$ sudo mkdir manifests

$ cd manifests

$ sudo nano init.pp

Now that i started to write init.pp, i had forgotten how the template for file-package-service looks like, so i opened my shared github repository where we wrote the sshd example that we did during earlier class. The github is made by me, and two other students in the same server management course.

Now it was time to see if the page worked. To open firefox and the wanted url, which is localhost, i wrote:

firefox “localhost”

and it opened a firefox and my localhost page, and it looked absolutely right!

b) Modules from Git. Do a script, which clones your module from git and ran for example through livestick. You can check an example from terokarvinen/nukke GitHub-varastosta.

First i started this part by installing git, with the command:

$ sudo apt-get install -y git

I had this kind of script already done in our “Touhutiimi” github folder, so it was time to use it.

It looks like this. It differs a lot from the previous puppet script because this is a shell script.

This script works as an excellent starting script, which writes you these commands to your terminal automatically. It unlocks the nordic alphabets, installs puppet and git, and finally clones your github repository and goes there automatically.

Now it was time to run this script by writing:

$ bash start.sh

Yep, it works.

Even though i already had git and puppet installed, it managed to clone my github repository, which i simply checked by writing the command ls and it was there.

It’s time to continue further with linux, but this time more specifically with Linux server management! I decided to start writing reports to this course in English, because i want to improve myself, and possibly get some international benefits (workplace abroad etc..).

Report starting time: 18:51

Once again i started my Xubuntu Linux OS as a livestick (Try Xubuntu for free) through my USB-stick.

To get the nordic alphabets (ä, ö), i need to do a command setxkbmap fi in terminal. So i did that.

Now was the time to open my homework for this report:

h1.

a) Two resources. Make and try a module that uses at least two resources (for example. file and package).

I re-opened my terminal, and it was time to do one of my old routines, which is the command Sudo apt-get update, it’s important to update the packages before we install anything.

Now it was time to install puppet! We already used puppet in our previous class, so i installed it with the command sudo apt-get install puppet. After installing puppet, and to make a module it was time to browse through puppet directories to the modules folder. cd /etc/puppet/modules inside the modules folder i have to make a new folder, and inside that folder i need to make a folder called manifests.

So first inside the modules folder i did sudo mkdir mymodule, after that to get inside the folder mymodule, i did the command cd mymodule and inside that folder i had to do the folder called manifests with the same command sudo mkdir manifests.

Inside the manifests folder, i did an init.pp file with the command sudoedit init.pp, but at this point i forgot what to exactly write inside.. AND i had to use two different resources.. I did some research in Google and i found a site called Puppet Cookbook, which told me how to install multiple packages with puppet. I was still lost because i had to find instructions for the file resource too.

Got it! With the file i could write for example helloworld, and with the package i can install a package. I found instructions for the file from a website called upguard.

Now i remembered about the /tmp/ path and content => “text” and i was ready to write.

The code looks like this now. 2 different commands(?) in 1 script. separated with a } mark.

Now it was time to try the script with the command sudo puppet apply -e ‘class {mymodule:}’. And it didn’t work… The problem looked like this:

It said it didn’t install. Use “allowcdrom” to override this failure. 2 times.

I googled allowcdrom in puppet, and i found a guide from stackoverflow. It was time to edit the script.

Like this!

Now we did the same sudo puppet apply -e ‘class {mymodule:}’ command and it went through! Now it was time to try if the cmatrix i tried to install worked, by just writing cmatrix to terminal. (cmatrix was my first “funny” installation to terminal, which i installed during the earlier Linux course as an assignment).

Tadaa! Cmatrix works!

And last, but not least it was time to try the file resource. I did the command cat /tmp/mymodule and the content text works!!

b) Watch a video about puppet, and other similar program. This was my homework, because i didn’t attend an IT exhibition..).

So.. it was time to compare Puppet with an other similar program, and i bumped into quite many similar programs called Chef, Salt and Ansible. Now was the time to watch the video and compare all 3 of them with puppet.

Quite amazing, all of them. I discovered a funny fact, that Puppet was developed in Ruby!

Puppet is an open source configuration management tool. Works great as a master client program. Puppet is the oldest of these!

Salt was written in Python, and it’s motivated to enable high speed communication with large amount of systems. (At least according to them). Salt is highly scalable and it has a syndicate feature where one master manages multiple masters.

Ansible was written in Python and uses SSH to communicate. It is also highly scalable.