Managing servers: 3rd assignment

Using jinja template to make a state which adds a variable into a file.

I started by creating a new folder in the /srv/salt directory, simply called ‘jinjatest’.
Into this new folder I created a text file called monkey.txt

monkey_txt

Then I created an .sls file called ‘monkeycall’.

monkeycall

I ran the state and it worked.

monkeycall_works

SLS states and for-in loop with Jinja

I made an sls state which utilized the jinja for-in loop. I started the assignment by creating a folder called ‘files’ into the /srv/salt directory.
Then I proceeded to make an .sls file called makefiles.sls
I tried to use my previous .txt file monkey as a source, but when I ran the state it didn’t yield good results.

makefiles_sls_monkeymakefiles_error

So I decided to make sure that I could get this for-in loop to work and used code from Jinja template tutorial by Tero Karvinen as a base to get results.

makefiles_sls_worksstate_apply_makefiles

It works!

Installing SSH demon into a selected port

Trying out a salt state made by a fellow student

For this assignment I decided to use the salt state made by Lauri Mattila which installs
the nmap and ack programs.

Nmap is a security scanner that builds a ‘map’ of a network by discovering hosts and services on it.
‘ack’ on the other hand is a command line utility similar to ‘grep’, but it uses shorter commands and you can use simple filetype specifications to search source code for anything you want.

It’s always important to check what the programs do before installing them, even if you’re using code from a trusted friend.

I made a new .sls file into the /srv/salt directory called programscopy.sls

programscopy_state

Then I ran sudo salt ‘*’ state.apply programscopy and saw that the state worked as planned.

programscopy_worksprogramscopy_works2

Sources: 

Server Management course by Tero Karvinen

Lauri Mattila – Harjoitus 1

Jinja Templating Salt States by Tero Karvinen

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

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 )

w

Connecting to %s