Advent 2021: Ansible
This blog is part of the 24 posts long series "Advent 2021":
- Advent 2021: Intro (December 01, 2021)
- Advent 2021: C++ (December 02, 2021)
- Advent 2021: C# (December 03, 2021)
- Advent 2021: Python (December 04, 2021)
- Advent 2021: Go (December 05, 2021)
- Advent 2021: TypeScript (December 06, 2021)
- Advent 2021: CMake (December 07, 2021)
- Advent 2021: Django (December 08, 2021)
- Advent 2021: Angular (December 09, 2021)
- Advent 2021: Flask (December 10, 2021)
- Advent 2021: gRPC (December 11, 2021)
- Advent 2021: GraphQL (December 12, 2021)
- Advent 2021: XML & JSON (December 13, 2021)
- Advent 2021: Matplotlib, Pandas & Numpy (December 14, 2021)
- Advent 2021: Linux (December 15, 2021)
- Advent 2021: Ansible (December 16, 2021)
- Advent 2021: SQLite (December 17, 2021)
- Advent 2021: Catch2 (December 18, 2021)
- Advent 2021: Zstandard (December 19, 2021)
- Advent 2021: ZFS (December 20, 2021)
- Advent 2021: Thunderbird (December 21, 2021)
- Advent 2021: Visual Studio Code (December 22, 2021)
- Advent 2021: Blender (December 23, 2021)
- Advent 2021: Open source (December 24, 2021)
I wrote yesterday about Linux and the broader ecosystem there. Today, I want to look at one of those pieces that I really enjoy: Ansible, an automation tool for Linux. I use Linux a lot – all my servers run Linux, which, by now, is nearly a dozen machines. Setting those up my hand gets incredibly boring quickly and is also error prone. While you can somewhat try to script the setup yourself, an automation tool like Ansible takes a huge amount of pain out of the system by giving you a framework for this particular task.
In Ansible, you describe the desired state and how to get there. Then you run it over a set of servers, and it will figure out what state they’re in and run the appropriate steps. Ansible is great for this as it does not require a server, a daemon, or anything really beyond SSH access to your target machines and a Python interpreter. It’s super simple to set up, and due to an insane amount of community modules you’ll always find a simple way to configure whatever service you need to configure. I’m using it now for all sorts of configuration tasks, starting from really simple things like ensuring folders exist and have the right permissions, to setting up my main web server with half a dozen of Apache site configurations.
For me, Ansible was a great way to simplify my life as an administrator. A server failing is no longer a tragedy, but a nuisance, setting up virtual machines is a task that takes minutes now instead of hours, and I can also track the history of all my configurations through source control. If you’re dealing with Linux servers, and you’re not using this kind of automation yet, give it a try!