Thursday | 21 NOV 2024
[ previous ]
[ next ]

Ansible Thoughts

Title:
Date: 2022-07-02
Tags:  

Big fan of ansible now that I have finished up my first playbook. I'm lucky that I only need to deal with brand new servers and usually only one at a time so I can learn ansible through a very simple task.

Now that I've used ansible, I can see how it came to be and the niche it fills. It feels very much like something I would have written and I'm bit jealous I didn't!

The core idea is that you want to execute idempotent actions on a server. For example, to create a directory, the first thing would be to check if the directory exists and then create it if need be. You can also simply using mkdir with the p flag and that will also be idempotent.

This idea of writing some python code to handle one specific function on the server is what drives ansible. I'm guessing the plugin system is well structured such that if you use the file module, there is one chunk of code that does everything simply.

This means you can focus on just describing the state and internally ansible will make sure things work.

I haven't seen any ini style playbooks yet but I can see why yaml would be better than json here. Json would probably be more cumbersome and yaml has it's own beauty. Using tabs and dashes makes sense for these things and the playbook reads relatively well. Even without ansible it is something close to what I write when I set up a server anyway. It very much feels like an outline.

I had a fun time setting it up and someone had said you can pick up ansible in an afternoon and that is very true. Though I think it should be couched in the fact that you should have set up servers before and know what you are doing. A complete beginner would have trouble but if you already do sysadmin work then ansible is a very gentle entrance into devops stuff.

Documentation is also really great for ansible and just reading what the various things do is enough to figure out which functions I need. There wasn't much reason to go to stackoverflow or blog posts.