Learning Ansible

I have recently been working on setting up servers for different applications and having to build quite a lot of identical servers. I have been frustrated with our old infrastructure setup. Some of the problems are different package versions across clusters and having to manually update each box (which is prone to human error). This has caused many problems, for example one server in a load balanced cluster displaying issues the others not. This can cause customers issues and can take a long time to debug such issues. Also, building new servers is teduous, slow and error prone.

At other organisations, I have previously used Puppet for this situation. By using Puppet I can automate the build process on the server and since the instructions are in code, I can repeat them on as many servers as needed. Testing it also a lot easier. Even though all of these benefits of Puppet there were still a few frustrations. The configurations would get quite complex and sometimes things would not work as expected and took a long time to debug what was going wrong. Also being an agent based system, I would need to install puppet on the servers first and I wanted to be able to do as much setup as possible automatically.

Doing some research on solutions to this opportunity, I short listed down to the modern tools that looked like improvements on Puppet. The options were Salt Stack, Chef and Ansible. For my proof of concept and analysis I chose Ansible.

Ansible is an agentless solution which uses SSH to perform all of its operations. This means it works with very little installed on the remote machine and a lot of different types of servers. When Ansible starts, it gathers “facts” about the server which it uses in its playbooks. This means you can target specific OS versions for particular operations.

The way to build an Ansbile playbook is to describe how you would like the end state of the server to be and then Ansible will ensure that the server ends up in that state by installing any missing applications or configuration. It has a large amount of Modules inbuilt that wrap common tasks that you would like to do. This makes my playbooks look quite simple and easy to read.

I have been very impressed with Ansible for quite a few projects and I plan to use it for future projects as its easy to use and get a server up and running, configured the way I need with little effort.

I plan to post some further posts in the future about my experiences and share some of my code from my playbooks.


I will be attending GovHack this year and I will be with a new team this year.

Our team is a lot more balanced and not as technical as last year so this should give us a better chance at delivering a more well rounded product this year. What is really exciting is that we have people with a technical skill focus well as business, data crunching and creative talent. These skills are really important and you want to be able to build something during the event, ensure that the idea targets the needs of the government agencies that are running the various competitions and creative talent to create an exciting video as well as the whole team to collaborate on your message to communicate effectively to your judges what your idea is all about.

If you are entering the competition, good luck!

RubyMotion Android Beta Tip

I have been trying out the new Android RubyMotion beta and have been trying out the code samples.

One thing I was frustrated about was having to keep putting the NDK and SDK path in the Rakefile. Here is a quick tip to make it easier.

Create a file somewhere like ~/motion/common.rb

@app.sdk_path = '/Android/sdk'
@app.ndk_path = '/Android/ndk'
@app.api_version = "19"
# other common configs

Inside the Rakefile for each app:

require 'motion/project/template/android'

Motion::Project::App.setup do |app|
# Use `rake config' to see complete project settings.
app.name = 'Paint'
@app = app
require '~/motion/common.rb'

Thanks to JP, you can also add this to your ~/.bash_profile or ~/.zshrc

export RUBYMOTION_ANDROID_SDK=~/android-rubymotion/sdk
export RUBYMOTION_ANDROID_NDK=~/android-rubymotion/ndk

If you have a better way to do it, post in the comments below.

It was interesting to find out how they confirmed that MH370 crashed over the indian ocean.

The planes navigation system was communicating to a satellite even though the main transponder was turned off and it communicated every hour. The Satcom “which collects information such as location, altitude, heading and speed, and sends it through Inmarsat’s satellites into their network”. The signal didnt contain any gps or location data so the analysts used techniques never used before, using the doppler effect (which describes how a wave changes frequency relative to the movement of an observer) and mathematical analysis so they could work out where the plane last was before it crashed. It was suspected the plane was above 30,000ft before it crashed.

The challenge now will be finding the black box before the battery runs out for the device in the black box that “pings” its location. If they do find it then the challenge of recovering it from such great depths in sea that has strong currents and dangerous weather.



Ruby Constants

I was doing some refactoring recently and made some interesting discoveries about how constants work in ruby.

What tripped me up was how much of a mess this code made:

Can you spot the problems here? The first obvious one is merge with a bang, and the other I will explain below.

What is a constant?

Constants in ruby are anything starting with a capital letter. So class names are constants as well as all capital variables.

Constants aren’t completely similar in other language. For example in Java and PHP you cannot re-assign or change a constant. In ruby you can:

Now you do get a warning, but its not an error and will not stop you from continuing. In the first example, the merge! actually modified the original constant so this was applied too all other classes using this constant.

There is one thing you can do if you want to ensure that the Object that the constant holds will not be modified, and that is by using the method freeze.


But as you can see below, the Constant is still able to be re-assigned (but still gives us the warning).

As pointed out by Andrew, you can freeze the class constant that an object refers to which will stop it from being modified.

Some other useful things about class constants is how easily they can be accessed. Constants defined in a class can even be reached without creating an instance of the class. You can even dynamically call the constant if you have a reference to the Class variable that contains the constant. For example:

Im still not certain on how useful constants are for settings that never change but I prefer using them to class methods that re-define hashes every time they are called or yaml files. They can sometimes make testing easier and other times harder.

Do you use constants much and how do you use them? Reply in the comments below.

A story from Guild Wars 2

I really enjoy computer games, its my main form of entertainment in the evening and a great stress reliever. I get so much enjoyment out of it that I was inspired to write a short story from my perspective and I thought would share it with you. This is from Guild Wars 2 (some references are very game specific).

I said my goodbyes the Militia on TeamSpeak and dropped my WvW Commander Tag, just after having defeated a Sanctum of Rall zerg.

What a good night, I thought.

A few weeks ago I got excited about some changes to WvW that I had missed and wanted to check them out. I had been enjoying the new Living Story content but wanted to do something a little different. I jumped into World vs World and the first thing I noticed was that on the Borderlands the lake is gone! This looked like a big change, but on further inspection its quite simple. Now in the middle of the map is a set of capture points that allow a server to get the upper hand if they capture 3 of the 5 points. I was told on TeamSpeak that this was to replace the old orb system.

I have been venturing onto BlackGate TeamSpeak server recently and its not as scary as I thought. I joined the channel for the borderland map I was on and I was pleasantly surprised by the commander which was on this same map. His name was Cuddlepie and had a good manner, running alongside him we ventured into enemy territory. We faced a big zerg almost twice our size that I thought we woudlnt be able to take on. Cuddlepie kept his cool and issued commands, like “head to the left then split them in half”, “take it to their backlines”. With his focus and strategy we where able to take down the entire zerg. What a rush!

We continued on and took several towers and keeps. I had a really good night. Later in the week I joined again and where greeted by another commander from a guild called KING and he had a different game plan. We defended garrison from several attacks and got lots of badges. There feels like they is always some action and some really good commanders that I feel like our strong ties with BlackGate WvW community are such an untapped resource.

Tonight, I jumped in and we where getting smashed by Jade Quarry. The commander tonight was Stellioz. I noticed the he has a philippines accent (I didnt know for a long while) and got really excited about WvW and showed some great skill in open field battles. The night continued on and I really enjoyed by time. He had to grab some dinner and we where left without a commander. I decided that I would give it a go, even though I didnt feel completely confident that I knew all of the current intel in WvW, I did it anyway as there where 5 Resonance online and in BlackGate TS so I thought “Why not?”. We where outnumbered and we took a few camps. We tried some things like some ninja trebs but the scouts where on to our plan. Later we defended our Tower several times against both Sancum and Jade. We responded to a Treb and took it out and saved our tower! Just as we saved our tower from an invading group we spotted a zerg bigger than ours.

We didnt have many numbers at this time in the night and I wasnt sure we where able to take them on. We tracked them to a chocked point. Then we engaged them once and they rallied behind the tower. Just as things go quiet, Stellioz came back from dinner and jumped in too. We spotted another group, this time bigger than the last! Stellioz said we could take them and offered some comments on how we would engage them.

We where off!

Running right into the thick of the battle, dropping some fire for might and blasting it on our way through. We focused the back lines and taking out the elles and the necros. A few of us dropped and our warriors threw down banners getting our downed up. It finally looked like we would win! We cleaned up the rest some backing and frowing and we took out the zerg.

The end.

The mystical “Tableless” Model for rails

I had a bright idea for an improvement for the app I am currently working on. I have a Rails model that has only 2 rows in the database and the data is never changed, it has quite a lot of relationships and is used quite extensively. My idea was to remove the database out of the equasion and create a Model that would be entirely self dependent. Here I will show you my methods of maddness:

My Startup Weekend in Adelaide

I recently attended startup weekend in Adelaide. I was really excited because it would be a good opportunity to build something and test my new skills I had learn recently programming ruby (and using rails).

The weekend started on Friday night where attendees had the chance to pitch their ideas in a quick 1 minute pitch. There where some exciting ones. The ones that stood out for me was a pitch about a rating system for health care professionals , a iPhone app to find and rate pubic toilets and a coffee rating app.

I decided to join the team doing rating and listing of health care as I though this would be really useful for lot of people if it was successful and seemed like something I could help and build a great MVP.

On the Saturday, after having formed our team on the Friday night, we where all ready to go. We had a really large group which became quite hard to manage at the start, we decided to break the group up into technology (MVP) and business so we would all.

In creating the initial product and setting up a starting point I made a few mistakes with setting up my project. Something that I found really useful and saved me a lot of trouble, was a ruby gem called Composer. It gets a project up and running really quickly by asking you a series of questions of things that you might want to add to your project, like Devise for auth and Twitter bootstrap.

Wanting to get something up and running really quickly, Luke in our group recommended Heroku. I had never used it before but wanted to give it a go. I was really impressed! All you need to go is install the Heroku gem on your computer, run heroku init on the project and then type git push heroku and it is deployed in a matter of minutes! It runs bundle and install all of the gems in the gemfile and then spins up a server.

One of the elements of the weekend that I really enjoyed was the mentors  that came to each group and provided insight into the various aspects of our project and how we could improve. This was really interesting to hear.

I made quite a bit of progress with the app and by the end I was able to make a simple way to lookup a directory of health care professionals. We used the app in our pitch at the end of the weekend. The other pitches where really good to watch and to see what all of the other teams had come up with over the weekend.