Kazu's Log

Jul 8, 2016

Ansible or Fabric?

Maybe that’s apples and oranges, but I tried both of them recently and decided to use Ansible to configure my Digital Ocean server.

Ansible has a thick abstraction layer. The configuration which is called “playbook” is in YAML, there are commands like package, file or synchronize. I didn’t get that first. Why didn’t you just use a general-purpose programming language and Unix commands?

So I started from Fabric, which used Python mostly as is. Then I wanted to skip some of Unix commands based on the state of the server, such as “don’t do ‘ln -s’ if the exact symlink is already there”.

That’s where Ansible’s playbook excels. Writing the procedures to reach the desirable state, with possible “skip X if A” checks is difficult and it would be different from what you do in ssh. Just write Unix commands would result either a slow or verbose script.

The playbook and the commands are desiged to write the desirable state itself, not the steps to reach the state. And skipping unnessary parts is Ansbile’s job. The learning curve might be steep, but I now think that is worth to do.