Using git submodules
In my previous post, I set up a simple Nginx server using Vagrant, Salt Stack and Digital Ocean. However, there was a nagging issue with the salt-vagrant-plugin – I could not get it to install Salt correctly. In this post, I am revisiting my Salt installation process.
From my previous post:
Also note that technically, the
vagrant-salt-pluginis able to install Salt for you as well. However, for some reason the plugin has decided that this requires a complete recompile of
python-zmq, which I am not interested in. So I use the official method of installing Salt before I start the plugin.
This Shell provisioning annoyed me mightily, and I went out to investigate. As it turns out, the latest official
release of the
salt-vagrant-plugin is still using version 1.5.2 of the
Salt-Boostrap script, while the shell provisioning line uses the much improved, highly praised
and vastly superior 1.5.5 release.
salt-vagrant-plugin supports custom Salt bootstrap scripts using the aptly named
configuration parameter. Unfortunately, we can’t point it to e.g.
https://bootstrap.saltstack.org, but we must point it to a locally existing
file because…, er…, because Ruby.
So, all that remained now was a way to make sure my infra-as-a-repo project always contains a local copy of the
correct version of the bootstrap script. After some mucking about with
eventually brought me to the long journey of understanding:
Git Submodules. As it turned out, this was a surprisingly short journey. Writing this post took more time than understanding submodules. Git submodules allow you to add a live link to a fixed version of a 3rd part dependency in another git repository.
And that’s it. I changed my Salt provisioning block in the Vagrant file to this:
and voilà!, I could remove the entire Shell provisioning line.
This exercise has brought me three things. First of all, I now understand git submodules. Try it yourself. It’s nice.
Second, the separate shell provisioning step really bugged me. I no longer have to roam the streets at 2AM, moaning about this annoying hack.
And finally, the
salt-vagrant-plugin is actually quite smart; my happy shell hack reprovisioned Salt Stack at every
run, while the plugin does some nifty detection stuff. This has improved the speed of reprovisioning. Which is nice
when you’re doing this in your spare time and need to
reprovision a lot.
Of course, the exact commit at the time of writing has been preserved in my repository. Go ahead and fork my repo on Github.
Do the wave
Follow the path
Choosing your target
the humble beginnings