Tag Archives: top.sls

SALTSTACK: MASTER & SLAVES

GOAL:

Setup Salt master and minion -architecture.
Create a module for the minions.

PERQUISITES:

SaltStack installed on the machines.
https://juhosyrjanen.com/2015/11/05/salty-assignment-i-saltstack/

ENVIRONMENT:

Three virtual machines.
VM1: Running Mint 17.2, Salt master || specs
VM2: Running Mint 17.2, Salt minion
VM3: Running Mint 17.2, Salt minion

SETTING UP SALT MASTER AND MINIONS

I started setting up my master and minions following the walk-through in doc.saltstack. 

First I started the salt master -service.

sudo service salt-master start

Capture6

For the minion – master needs to be defined. So I added my master VMs IP to the minions /etc/salt/minion -file.
Capture7

I started the minion with

sudo salt-minion -d

This will generate a minion id, which will be stored in /etc/salt/ as shown in the pictures bellow

Capture8 Capture9

Now when I ran sudo salt-key -L on the master VM:
Capture10

I accepted the pending key with

sudo salt-key -A

And ran the sudo salt-key -L again:
Capture11

Capture12

I verified that the keys do match by running salt-key -F master on the master VM and salt-call key.finger --local on the minion VM.
Capture13Capture14

I verified that the master can ping the minion by running the test.ping command:
Capture15

The master can now start sending command to the minion! Installation successful!

I repeated the steps for the other VM and ran the test command again:
Capture1

MODULE

I created a top.sls file, in which I set states to be installed to my slaves. The file looks a little something like this:

top2

 

In the top.sls -file, I set Apache -state to be installed on all the slaves and specified the other packages to certain individual slaves.

I tested that all my states work on my master VM:

MySQL:
mysql

Apache:
apa

SSH:
ssh

Running the top file

All the individual states worked fine, so I ran the top file!
sudo salt '*' state.highstate

Salt took a while to run the file, but it seemed to have worked without any errors.
result1

result2

result3

Success

I ran the highstate again to confirm the results, and everything seemed to have worked fine.

  • Copying, modifying and redistributing this and all the other documents in this blog is allowed according to the GNU General Public License (version 2 or newer).http://www.gnu.org/licenses/gpl.html
  • Based on the Linux course by Tero Karvinen 2015: terokarvinen.com
Advertisements