Configuring Salt Master&Slave- architecture (H1)

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, 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:

id: arttu

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 ‘*’ ‘hostname -I’ to test the connection to my slaves. “*” refers to all slaves, so all slaves would return their hostname.

For now, I have only two slaves.
Executing remote commands.
Installing packages.

I tried some salt states using examples posted here:
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.

The file looked like this.

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.

Error message after applying the state.

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.

System information about salt-master.

Time to test salt on windows, and make my host computer a slave. I downloaded and installed salt-minion from 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.

After updating repos, I tried to install VLC player on all slaves.

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.

State for installing apps.
After applying the state on master, I could install three apps at the same time to Windows using Linux. Amazing.

Leave a Reply

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

You are commenting using your 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 )

Connecting to %s