Installation of Salt on Ubuntu 12.04

Introduction

A novel method for infrastructure management, Salt is a completely open source configuration management and remote execution tool. It is not only simple enough to be operational within minutes, but is also scalable enough for managing a large number of servers and is speedier enough for communicating with all of them within seconds.

Salt is a product of an amazing and open company called SaltStack. All features and code of Salt are released under Apache 2.0 license and it can be downloaded from https://github.com/saltstack/salt and any favored package manager of the OS.

In the following tutorial, we will be accomplishing a number of tasks as follows:

  • Installation of a Salt Master and a Salt Minion on a droplet operating Ubuntu 12.04
  • Execution of commands

This guide presumes that:

  • You already have developed a droplet operating Ubuntu 12.04
  • and you have the rights and are logged in as the default root user already.

Installation

Firstly, we need to add the SaltStack ppa:

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:saltstack/salt

Press Enter whenever prompted.

Next apt package database needs to be updated with the command below:

sudo apt-get update

Following the addition of ppa, now we can proceed with the installation of the Salt Master and the Salt
Minion:

sudo apt-get install salt-master
sudo apt-get install salt-minion

Next the Salt Minion needs to be told where it can locate its Salt Master. As both the Salt Master and the Salt Minion are running on a single host, we will fix the master config option to localhost.  You can utilize your favored editor for modifying the config file of Salt Minion :

vi /etc/salt/minion

Next edit the master config option to localhost and uncomment it by removing the #.

master: localhost

Then changes should be saved and the Salt Minion service should be restarted:

service salt-minion restart

Next list entire Minion keys that are known to your Master:

salt-key -L

Now, the key of Minion should display under Unaccepted Keys. The name of your droplet needs to displayed where dave03 is being displayed in the code below:

Accepted Keys:
Unaccepted Keys:
dave03
Rejected Keys:

Next the last thing to be done is to make the Master accept the public key of the Minion.
Instead of ‘dave03’, put the name of your droplet:

salt-key -a 'dave03'

The output should look like the output shown below:

The following keys are going to be accepted:
Unaccepted Keys:
dave03
Proceed? [n/Y] y
Key for minion dave03 accepted.

Thus, now you have an operational Salt Master and Salt Minion operating on your Ubuntu 12.04
server! We can check out some commands that can be run.

Check if the Minion responds or not through the command below:

salt '*' test.ping

Output:

dave03:
        True

We will list the IP addresses of the server:

salt 'dave03' network.ip_addrs

Output:

dave03:
        - 192.xxx.xxx.xxx

Installation of nginx:

[email protected]:~# salt 'dave03' pkg.install nginx

[email protected]:~# salt 'dave03' service.start nginx

Also See

We have developed only some key Salt formulas that utilizes in-built states of Salt for configuring our server. Yu can do a lot more with Salt!

A fabulous way of learning more about Salt is the Official SaltStack Walkthrough :
http://docs.saltstack.com/topics/tutorials/walkthrough.html

You can also read comprehensive documentation of Salt to know about all the methods through which it can aid you in managing your infrastructure:
http://docs.saltstack.com

Salt Development takes place at: https://github.com/saltstack/salt

You can also join the Salt community where anyone can post questions about SaltStack products and get the answers:
https://groups.google.com/forum/#!forum/salt-users

KB Admin has written 28 articles

Leave a Reply