Putting some “Salt” on Azure

It doesn’t matter if you simply need to run a single Bash command on multiple machines or deploy some package to multiple machines, the key is when you have more the 2 machines you need to deal with having some sort of distributed command line tool or package management system is key. There are multiple flavors of these out there like Puppet labs,  Chef or Salt. For the purpose of this post I’ll be focusing specifically on Salt.

Setting up salt onyou azure VM is probably one of the easiest things one can in terms of getting a VM up and running with azure IaaS. Though getting a few details correct for doing things a bit more complicated can be hard to find and the purpose of this post to share my quick learnings.

 For those unaware Salt is a new platform for automating package deployment on VM’s (like Puppet or Chef) and also running remote commands on clusters. I already like salt from the get go because it’s written in python which makes things fun for me when something isn’t working and  also it’s simplicity of setup.

Full documentation for salt can be found at (http://docs.saltstack.com/)

For this use case I was using ubuntu on my VM’s as the OS of choice.


Setting up 2 VM’s on Azure as easy as sending an email, it only involves a few clicks were anyone one that has logged into a linux machine can figure it out. However getting the 2 VM’s talking is not as obvious as the first step.

This might not seem obvious at first but having to VM’s in the same region doesn’t guarantee they are in the same subnet so you initially need to create a new affinity group and virtual network to run you vm’s on. Though the affinity group is not mandatory it is a good to have practice as it will help you put you VM’s in a closer vicinity in the datacenter.

Setting a virtual Network is literally a few clicks and a tutorial to that can be found here: http://www.windowsazure.com/en-us/manage/services/networking/create-a-virtual-network/

 For our purpose you don’t have to worry about DNS servers or Active Directory or VPN for that matter.

 We just need a simple subnet were our VM’s can talk to each other.

Now when you are creating your VM’s make sure you select the virtual network on all VM’s



Installing salt is a piece of cake simply run the command on both your VM’s

$>wget -O - http://bootstrap.saltstack.org | sudo sh


Once salt is installed you should get it going by starting the daemon on both you master and slave host.

But before we start running our daemons we need to make sure a few things on the network are in place.

I’ll be referring to these hosts as Master and  Slave  fashion just to point out that the master is the one where I’m executing the commands and pushing them out to my slaves.

Before getting things going we need to make sure we can ping each other.

I would recommend adding your hostnames into the /etc/hosts

azureuser@myhost1:~$ cat /etc/hosts localhost
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts myhost# bitnami-hosts-patch myhos1t# these are the important ones myhost2# these are the important ones

My 2 VM’s have the hostname myhost1 and myhost2

Hopefully after this you can ping your other host.

After this you need to make sure

After doing this make sure you  have the hosts set up properly in your slat configuration which can be found in /etc/salt/

You’ll find 2 files in here.



The file names are self explanatory here you just need to make sure that the hostnames are properly properly configured.

Here is how the entry would look in my minion config file:

# Set the location of the salt master server, if the master server cannot be
# resolved, then the minion will fail to start.
master: host1

You shouldn’t need to do anything else with the master config.

You can follow the rest of the tutorial on managing packages and running some commands through the saltstack walkthrough page which is quite thorough and I don’t think there is much value in repeating here.



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s