Sunday, May 3, 2015

Issues with Salt.

As I keep playing with Salt, I’m forming a love/hate relationship with it. Love: It automates and codifies installing and configuring things on machines. Hate: The documentation and unexpected/odd behavior.

Many of the things that I hate are outlined in a blog post found here. I want to add to that.

First, documentation. Its more of a stream of thought, than documentation. For example, I tried adding a git repo as a ‘formula’. I found this webpage, in their documentation. Its supposedly a walk through. There is no complete example, and for many of the pieces, it said “do this” with no explanation of how to “do this”. "Do this” is some very specific configuration you must do, which leads to the documentation for that configuration, which has other configuration requirements. When you start discovering this, it feels like you’re going down a rabbit hole. “Here a walk through to do A. You must configure B”, “Here’s some documentation on B, in some circumstances you need to configure C first”, and so on. If you’re going to present yourself as a walkthrough, please put *all* of the requirements into that walkthrough.

The other problem I have is that the app sometimes does…. Nothing. No errors, warnings. Nothing. Turns out, that its a timeout situation, where the action just took too long. But the app doesn’t tell you that. It should tell me that it got sick of waiting, and how to determine when it finishes. What if I’m running 10 of these commands, and half timeout? I have no way of knowing when they are finished, or if they are successful.

Salt is a cool tool, but dangerous. Its quite easy to get some things going and working. As you start to use it though, it starts to show its lack of polish. The shininess is wearing off for me.

Sunday, April 12, 2015

Vagrant and Salt

I’ve recently discovered Vagrant (https://www.vagrantup.com/). It has changed my developer life. Having consistent environments for development and testing is ideal, and Vagrant gives us that. Before it was much more difficult to get everyone up and running, but now its as easy as a single Vagrant file.

The next thing I recently discovered is Salt (http://saltstack.com/). I don’t know much about Salt, but I want to. I have a side project I’m working on that will greatly benefit from it. 

So naturally, I wanted to use Vagrant to experiment with Salt. Vagrant even has built in support for Salt. But one thing I noticed is that there is not a simple example of running Vagrant and Salt, with a “master and minion”. The examples I found were either running “masterless”, or they have the master and minion on the same VM.

So after a bit of research and experimentation, I figure out how to set up a separate master and minion, in Vagrant. It takes care of the keys also. 

There are two files involved, the Vagrantfile and a salt_minion.conf. Here they are:

Vagrantfile

Vagrant.configure(2) do |config|
    config.vm.box = "ubuntu/trusty64"
    config.vm.box_url="https://atlas.hashicorp.com/ubuntu/boxes/trusty64"

    config.vm.define "master" do |infrastructure|
        infrastructure.vm.hostname="master"

        infrastructure.vm.network "private_network", ip: "192.168.0.128"

        # Make this bad boy into the salt-master
        infrastructure.vm.provision :salt do |salt|
            salt.install_master=true
            salt.no_minion=true
        end

        infrastructure.vm.provision "shell", inline: <<-SHELL
  rm -f /vagrant/minion.pem /vagrant/minion.pub
  salt-key --gen-keys=minion
  cp minion.* /vagrant/
  cp minion.pub /etc/salt/pki/master/minions/minion
        SHELL
    end

    config.vm.define "minion" do |minion|
        minion.vm.hostname="minion"

        minion.vm.network "private_network", ip: "192.168.0.2"

        minion.vm.provision :salt do |salt|
            salt.install_master=false
            salt.no_minion=false
            salt.minion_key = "./minion.pem"
            salt.minion_pub = "./minion.pub"
            salt.minion_config = "./salt_minion.conf"
        end
    end
end

salt_minion.conf
master: 192.168.0.128
id: minion
file_client: remote