I try to keep our infrastructure fairly up to date. I like using devops best practices, so I’m using Ansible for server provisioning and upgrade. I used Chef and I played around with Puppet, but I found both too complicated for our current infrastructure. Ansible has been a pleasure to use so far.
Just this week I have updated a few of our servers. All of them feature Ubuntu Precise.
Ubuntu Precise ships with Redis version 2.2. That version is over two years old, so I can’t just rely on Precise packages. Besides, since we are using a bit of Lua scripting we need at least version 2.6 or higher. This means either compiling or getting an alternative PPA. I always prefer to avoid manual package compilation. But, luckily, Rowan’s keeps a very well maintained PPA.
The playbook —that’s how you call recipes in Ansible— is as simple as
# Add redis repo
- apt_repository: repo='ppa:rwky/redis'
- apt: pkg=redis-server update_cache=yes state=latest
If you are using redis, don’t forget to set overcommit memory setting to 1, as stated in the documentation
- name: Set overcommit_memory to 1
sysctl: name=vm.overcommit_memory value=1 state=present
I also updated to PostgreSQL 9.3.3, released a few weeks ago with security fixes. I had the same problem as with redis, Ubuntu ships with version 9.1. In this case there is an official postgres repository with the latest version
Here you are the Ansible playbook.
# Add postgres repo
- apt_repository: repo='deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main' state=present
- apt_key: url=https://www.postgresql.org/media/keys/ACCC4CF8.asc state=present
- apt: pkg=postgresql-9.3,postgresql-contrib-9.3 update_cache=yes state=latest
To complete the week, after a few days testing ruby 2.1.1 in our local and staging environments —and being sure the ruby 2.1.1 regression is not affecting us— I have upgraded the production servers.
To simplify installation, I am using ruby-install. I am not attaching the Ansible playbook because it is a bit long, but you can find several examples for ruby installation in Ansible Galaxy.
And that’s all. My ops tasks are done for the week and I can get back to coding.
If you have any questions about this post, just leave us a comment. In case you prefer to get in touch privately, contact us at firstname.lastname@example.org