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



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.


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

Installed Salt Minion for the 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


sudoedit /etc/salt/minion

master: “master IP”
id: slave

and restarted salt minion


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.


sudo salt-key -A

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


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

Everything looks ok.

d) & f)

Try out one of the states from 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

	    - 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

  - pkgs:
    - cmatrix
  	- cowsay

sudoedit /srv/salt/shutter/init.sls


and top.sls -file

sudoedit /srv/salt/top.sls

  - 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


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 '*'

lists available grains


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

Course page:


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


Some old Samsung laptop running live Xubuntu 18.04.1