OR2017 Workshop: Getting Started with Ansible and ServerSpec
June 27, 2017, half day workshop, afternoon
- Facilitated by:
- Hardy Pottinger, UCLA Library (orcid.org/0000-0001-8549-9354)
- Additional collaborators:
- Alicia Cozine, Data Curation Experts
- Anthony Vuong, UCLA Library
- Francis Kayiwa, Princeton University Library
Let's face it, repositories are services, no matter your definition of service. To offer a service like a repository, you need people: repository management staff, developers and operations staff (aka sysadmins). Many repositories scrape by with just a developer or two, maybe a shared sysadmin. A legendary few try to get by with a single staff member, who wears many hats. This isn't an uncommon challenge for IT professionals. But it's particularly common among people tasked with delivering a repository service. We do more with less.
One way to do more with less is with automation. There are tools to help you manage the task of delivering a service in a more organized fashion. This workshop will walk you through how to use Ansible, one such tool, to set up a new service on a new machine. The focus will be on hands-on learning, walking through the common mistakes one can make when using Ansible. You'll gain a confidence in the tool, and learn that the error messages Ansible returns are actually useful in finding those mistakes. You will quickly discover that using Ansible is pretty similar to what you've previously done by hand. You may even have shell scripts written to help you with provisioning; those existing scripts can easily be modified to work with Ansible. We will also make use of Serverspec, a tool which allows you to characterize the services running on an existing server, and then use this specification to test and verify the results of your efforts with Ansible.
At a minimum, you will need:
- a notebook computer
- an account with admin privileges on this computer, so that you can install software
Ideally, you will have already installed the following software packages before you arrive at the workshop space:
- Ruby, version 2.0.x or higher (see note below)
- the ServerSpec gem:
gem install serverspec
Optionally, if you think you'd like to explore more with Ansible after the workshop, it would be a good idea to have Ansible already installed.
However, for the workshop, we will be utilizing a VirtualBox VM with Ansible already configured and ready for you to play. You will take this VM home with you and will be able to continue using it to learn more. So, don't worry too much about installing Ansible on your own.
- Note: opinions differ on the "best way" to install Ruby on your computer. This really only matters if you plan to use Ruby extensively, if you already have Ruby installed, and it's version 2.0.x or higher, you will be fine for this workshop. However, you may have heard something about this "discussion" and the details might be confusing. Our recommendation is to use a Ruby version manager of some sort, either RVM or rbenv. We recommend rbenv, as it's a very light-weight/easy way to manage Ruby installations. RVM can be a bit strange. :-\
Workshop-o-matic, a Vagrant-managed workshop Virtual Machine
updated 2017-07-13 13:10 CDT If you attended this workshop, you'll remember that we ran into some difficulties with the pre-baked VirtualBox image we packaged on USB sticks for use at this workshop. We've revamped that machine to produce a new Vagrantfile, which you can use to bootstrap your own Vagrant-managed workshop VM. We're calling it workshop-o-matic and we're happy to report it has worked on every machine we've thrown it at so far.
If you did not attend this workshop, but you'd like to follow along with our slides, please do go ahead and make use of the workshop-o-matic.
Additional Ansible Resources
- Alicia Cozine's Ansible for Hydra tutorial we make use of this material in our workshop, but you might want to star this repository for later
- UCLA Library's Ansible Role Template we will mention this towards the end of our workshop, but you might want to star this repository for later
- Mr. Nice's blog post on Understanding Ansible a concise introduction to Ansible
- Ansible Tutorial by ServersForHackers.com another concise description of what Ansible is and how to use it, written mostly for devs
- Ansible Best Practices the official best practices guide from Ansible
- book: Ansible for Devops by Jeff Geerling
- code: Jeff Geerling's GitHub repositories
Additional ServerSpec Resources
Combining ServerSpec and Ansible
Here are two great articles on testing with ServerSpec and combining it with Ansible, however, a warning: save these for after you have gotten your bearings with Ansible and ServerSpec, do not let this more complex information scare you away from trying these tools out. You do not have to get any of this perfect, you are learning.
- Infrastructure Testing with Ansible and Serverspec - Part 1
- Infrastructure Testing with Ansible and Serverspec - Part 2
And the example repository from those two articles: