Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
246 lines (137 sloc) 5.17 KB

h1



c)

Install Salt Master and Slave with pull-architecture.

Following these instructions I started by installing Salt Master and checked my IP-address. I also made couple of holes to the firewall for Salt.

Master:

sudo apt install salt-master
hostname -I
sudo ufw allow 4505/tcp
sudo ufw allow 4506/tcp

Installed Salt Minion for the slave

Slave:

sudo apt install salt-minion

I then modified minion-file. I added masters IP-address so that slave knows where to connect and named the slave computer as... slave

Slave:

sudoedit /etc/salt/minion

master: “master IP”
id: slave

and restarted salt minion

Slave:

sudo systemctl restart salt-minion.service

The slave should have now sent a slave key to master.

I checked if there were unaccepted keys, found one and accepted it.

Master:

sudo salt-key -A

To test that I actually had a connection I ran some commands

Master:

sudo salt '*' cmd.run 'whoami'
sudo salt '*' grains.item virtual
sudo salt '*' grains.items|less
sudo salt '*' cmd.run 'ls /home/xubuntu'

Everything looks ok.

http://terokarvinen.com/2018/salt-quickstart-salt-stack-master-and-slave-on-ubuntu-linux

d) & f)

Try out one of the states from https://github.com/joonaleppalahti/CCM/tree/master/salt/srv/salt or modify one of them

I used these instructions as a reference.

Using master I started by creating /srv/salt -folder

sudo mkdir /srv/salt

to make sure everything works right, I created a test state called “hello”

sudoedit /srv/salt/hello.sls

/home/xubuntu/terve.txt:
  file.managed:
	    - source: salt://terve.txt

(.sls files are written in YAML, so indentation is done with spacebar, not tab) and a file called terve.txt to copy to the slave.

sudoedit /srv/salt/terve.txt

To get the file to the slave I had to apply it

sudo salt '*' state.apply hello

Here I’m applying a state called “hello” once to all (‘*’) my minions.

It’s very important to make sure that every computer has cmatrix and cowsay always installed and my minion(s) are no exception. The top.sls -state applies periodically automatically so that’s the perfect tool for this occasion.

I created a folder called important

sudo mkdir /srv/salt/important

and because I figured I might need to take screenshots with the slave, I also created a folder called shutter, which would be used to install Shutter

sudo mkdir /srv/salt/shutter

After that I created two init.sls files, one for important and one for shutter

sudoedit /srv/salt/important/init.sls

install_important:
  pkg.installed:
  - pkgs:
    - cmatrix
  	- cowsay


sudoedit /srv/salt/shutter/init.sls

shutter:
pkg.installed

and top.sls -file

sudoedit /srv/salt/top.sls

base:
'*':
  - important
	- shutter

I used

sudo salt '*' state.highstate

to apply top.sls immediately.

Here’s cmatrix and cowsay running on the slave. Picture was taken with shutter

https://github.com/joonaleppalahti/CCM/tree/master/salt/srv/salt

http://terokarvinen.com/2018/salt-states-i-want-my-computers-like-this

http://yaml.org/

https://github.com/abishekvashok/cmatrix

https://github.com/piuccio/cowsay

http://shutter-project.org/

e)

Use Grains to collect system information

The command

sudo salt '*' grains.items

dumps a bunch of information about the minions system(s) like IP -address, operating system, gpu etc.

sudo salt '*' grains.ls

lists available grains

and

sudo salt '*' grains.item “anything from the previous list”

gives info about specific grain.

I checked out my slaves gpu,

sudo salt '*' grains.item gpus

cpu model

sudo salt '*' grains.item cpu_model

and memory

sudo salt '*' grains.item mem_total



https://docs.saltstack.com/en/latest/topics/grains/


Course page: http://terokarvinen.com/2018/aikataulu-%E2%80%93-palvelinten-hallinta-ict4tn022-3004-ti-ja-3002-to-%E2%80%93-loppukevat-2018-5p

http://terokarvinen.com/2018/salt-quickstart-salt-stack-master-and-slave-on-ubuntu-linux

https://github.com/joonaleppalahti/CCM/tree/master/salt/srv/salt

http://terokarvinen.com/2018/salt-states-i-want-my-computers-like-this

http://yaml.org/

https://github.com/abishekvashok/cmatrix

https://github.com/piuccio/cowsay

http://shutter-project.org/

https://docs.saltstack.com/en/latest/topics/grains/

Master:

  • Lenovo Ideapad 720s
  • Dual boot Win 10 | Xubuntu 18.04.1 LTS
  • Intel Core i7-8550U
  • GeForce MX150
  • 8 GB RAM
  • 500 GB SSD

Slave:

Some old Samsung laptop running live Xubuntu 18.04.1