Developing software in the Real World

An Ansible playbook for Swift

I’ve been learning Swift recently and now that it’s Open Source, I’m looking at using it on my Linux server.

Firstly however, I wanted to run it within a Vagrant box locally and as I provision all my boxes via Ansible, I created a simple playbook and am recording it here in case its useful to anyone else!

The installation instructions are easy to follow, so I simply replicated them as a set of actions. Note that the filename of the latest snapshot has the version and date included into it, so I created those as variables so that I could change them and just re-provision.

I usually run Ansible on my Vagrant VM directly as this means that I don’t need it installed locally and that my boxes are usable by people who have Windows. Hence, I use the shell provisioner to install Ansible first and then run the playbook. These are the files I use:

Vagrantfile:

Notice that I run the init.yml playbook as the vagrant user so that the correct home directory is used. This is the main playbook:

vm-provisioning/init.yml:

This doesn’t do much. It sets the variables for the swift snapshot that we want and also installs vim and curl as they are always useful!

Finally, we then install Swift itself into our home directory:

vm-provisioning/swift.yml:

That’s it. You can now vagrant ssh into the VM and run swift on the command line:

Swift1

Thoughts? Leave a reply

Your email address will not be published. Required fields are marked *