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 '*' cmd.run 'whoami' sudo salt '*' grains.item virtual sudo salt '*' grains.items|less sudo salt '*' cmd.run 'ls /home/xubuntu'
Everything looks ok.
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.
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
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
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
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
sudo salt '*' grains.item cpu_model
sudo salt '*' grains.item mem_total
- 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