SaltStack - Creating a Simple Environment


In this chapter, we will create a simple SaltStack environment, one salt master and two salt minions. This environment will help us to learn the salt concept in the upcoming chapters.

Let us adhere to the following steps to create the SaltStack environment.

Install the VirtualBox Environment

VirtualBox is a cross-platform virtualization application. VirtualBox allows you to run more than one operating system at a time. VirtualBox runs on Windows, Linux, Macintosh and Solaris. It hosts and supports a large number of Guest Operating Systems.

You can download and install VirtualBox by visiting the following link − https://www.virtualbox.org/wiki/Downloads

We will create three virtual machines and run it using the VirtualBox.

Install Vagrant

Vagrant provides easy to configure, reproducible and portable work environments.

You can download and install the Vagrant by visiting the following link − https://www.vagrantup.com

After the successful installation of Vagrant, you need to configure it. Create a single file named as Vagrantfile in a folder and describe the type of machine and its properties.

Run Vagrant − To run the Vagrant, issue the following command −

vagrant up

After you run vagrant up, Vagrant creates and starts those machines, which are defined in the Vagrantfile using the VirtualBox in the background. These machines will be running until you close them.

Stop Vagrant − To stop all the running machines in the VirtualBox, type the following command −

vagrant halt

Download the Demo Environment

SaltStack provides a simple demo environment as Vagrant setup and it is hosted in the github. Let us download the setup using the following command −

cd /cd/to/path

git clone https://github.com/UtahDave/salt-vagrant-demo

Start Environment

Now, start the demo environment using the following command −

cd /cd/to/path/salt-vagrant-demo
vagrant up

After this command, you will see the following response −

result

Now, three servers are running, one with the salt master configured and two with the salt minion configured.

Run Salt master

Login to the Salt master using the following command −

vagrant ssh master

Now, move to the root user using the command below −

sudo su

Now we have successfully connected to the Salt master.

Let us now go through some of the basic commands in SaltStack.

List out all the Keys

The following command is to verify the Salt minion connections and view whether the connection is accepted, rejected or pending.

salt-key —list-all

It will produce the following output

Accepted Keys:
minion1
minion2
Denied Keys:

Unaccepted Keys:
Rejected Keys:

Verify Salt Minions

Now, we have accepted all the keys, you can send a command from Salt master to check whether Salt minions are listening or not,

salt '*' test.ping

It will produce the following output

minion1:
   True
minion2:
   True

From the above result, list out minion 1 and minion 2, which means minions are listening properly, otherwise minions might now respond properly.

Advertisements