In my last post, I wrote about how I got started with SaltStack. In this one, I want to help you get a minimal SaltStack deployment going just for testing and playing around with. We will install both a Salt Master and a Salt Minion on the same VM and make sure they can communicate.
So first, create a new VM. I use CentOS7 and so that's what these instructions are written for. If you use a Debian or one of it's derivatives such as Ubuntu or Mint, is shouldn't be that much different. Just change the 'yum' commands to 'apt-get' and you should be good to go.
yum -y install epel-release && yum -y install salt-master salt-minion
Now to tell the minion where to find the master. This is accomplished by changing the "master:" parameter in /etc/salt/minion. We will use 127.0.0.1.
sed -i 's/#master: salt/master: 127.0.0.1/' /etc/salt/minion
Now that the minion configuration has been changed appropriately, we need to restart the minion, but even before that we should go ahead and start the master.
systemctl start salt-master && systemctl restart salt-minion
The next step is to approve your minion key on the master. This is done using the salt-key command. The first command lists all minions and status, the second approves all minions awaiting.
salt-key -L && salt-key -A
To learn more about salt-key, check out the SaltStack documentation.
Now let's check to make sure that our Master and Minion are both working properly.
salt '*' test.ping
Let me break this command down for you. Obviously we're calling salt. But the next part, '*', is called the target. Here we are targeting all minions. But I could target by name or partial name just as easily by using globbing. Globbing though is not the only method of targeting. To see more, check out the SaltStack Documentation.
The last part is the module.function that we want Salt to run on the Minion. Below you can see that I used test.ping as before, but I also ran the version function of the test module and couple of functions from the status module.
And that is it. You now have a working Salt Master and Minion. Should see now that adding more minions is just a matter of install the salt-minion package on a new machine, setting the master param in the minion config, restarting the salt-minion service, and approving the new minion's key from the master.