This article is part of a series I’m writing on using Saltstack.
Saltstack uses the master-slave architecture for communication and setting up Saltstack is one of the easiest configurations I’ve ever done. It involves installing the server software on the master and a client on the the slave device, known as a minion.
First, we will setup the salt-master:
- Fetch and run the bootstrap script:
12curl -o bootstrap-salt.sh -L https://bootstrap.saltstack.comsudo sh bootstrap-salt.sh -M git develop - Start the salt-master process:
1service salt-master start
salt-master will now be installed and running. You will need the IP address (or domain name) of your machine for setting up the salt-minion.
Next, we will setup the salt-minion:
- Fetch and run the bootstrap script (note the lack of ‘-M’):
12curl -o bootstrap-salt.sh -L https://bootstrap.saltstack.comsudo sh bootstrap-salt.sh git develop - Set the IP/Hostname to that of the salt-master in the salt-minion config file:
123# Set the location of the salt master server. If the master server cannot be# resolved, then the minion will fail to start.master: <salt-master-ip> - Restart the salt-minion:
1service salt-minion restart
That is enough config to begin working with Saltstack!
To test if everything is working, log onto the salt-master and fetch a list of all keys the salt-master is aware of:
1 |
salt-key -L |
The response will show different types of keys: Accepted, Denied, Unaccepted and Rejected. In Saltstack, it is the minion that initiates communication with the master and so each new minion must be allowed to connect. If the previous steps have worked correctly, you should see an entry under the ‘Unaccepted Keys’ section. This will likely be the hostname of the minion machine. By default the salt-minion used the hostname of the machine as the minion_id.
Quickly accept all keys:
1 |
salt-key -A |
Confirm as required and then rerunning ‘salt-key -L’ should show the minion has moved from unaccepted to accepted. Once this is complete you now have control over the minion!
Test the key has ben accepted by telling the minion to run a command:
1 |
salt '*' test.ping |
And that’s it! You now have a salt-master able to control a salt-minion.
Looks useful, will definitely try it out!