Starting with salt stack. I haven’t used Linux that much yet, and I haven’t heard about salt stack before this course started. Controlling hundreds of slave computers does sound interesting for sure! I have read some get started-tutorials at docs.saltstack.com, and there is much to learn. Citing the tutorial: “You can get a general understanding of how Salt works by seeing it in action.” so let’s get started.
At first I installed salt by using ubuntus apt packet manager: sudo apt install salt-master salt-minion
After the package installation, I configured the slave by editing the minion file: sudoedit /etc/salt/minion. I added two lines of text:
Then i restarted the daemon: sudo systemctl restart salt-minion.service. In this case, master and slave was the same computer. Now I had to accept the slaves key on the master by typing sudo salt-key –accept-all which would then accept that computer as a slave. I also started another virtual machine to make it a slave for my master computer. I repeated the above steps on the another machine, and changed the id so I could identify my slaves. Then I would type in: sudo salt ‘*’ cmd.run ‘hostname -I’ to test the connection to my slaves. “*” refers to all slaves, so all slaves would return their hostname.
I tried some salt states using examples posted here: https://github.com/joonaleppalahti/CCM/tree/master/salt/srv/salt
I used the firewall.sls as and example to apply firewall settings on my slaves. I began by creating a directory /srv/salt/. This directory contains instructions of the slave machines. I wanted to make firewall state so I created a file called firewall.sls.
After adding some firewall rules (sudo ufw allow 22,80,443,4505,4506/tcp), I tried out the state.
At first, I encountered some errors.
Apparently, there were incorrect syntax in my firewall.sls file. It was fixed by removing the space at the start of fourth line. And after that, it worked!
With salt grains I am able to collect information about my slaves and master. Command sudo salt ‘*’ grains.items returns a lot of information about computers under my control, such as processor type, IP address, OS type, memory and other system information.
Time to test salt on windows, and make my host computer a slave. I downloaded and installed salt-minion from https://docs.saltstack.com/en/latest/topics/installation/windows.html on my windows 10 host machine. Installation was fast and simple, all I had to do was to type in my masters IP address, and set a hostname for windows slave. Then i accepted the key on my master.
To enable salt windows repositories, I need git. Using command sudo salt ‘*’ pkg.install git, I can do the installation easily to all computers. After git was installed, I updated windows repos.
Installing VLC from master to all slaves worked. Soon after running command shown above, a shortcut of VLC player appeared on my host Windows desktop! Maybe I should install more apps using my master. I recently reinstalled my windows, so I dont have many apps installed at the moment. So why dont I install few useful apps at the same time, from my guest machine with salt.