by mindslight · 6y ago · 0 comments
Every time I attempt to use Ansible (or its kin) to manage my own network, it feels overly obtuse and ultimately unhelpful. Its gains seem to be rooted in configuring a large number of identical servers, and isn't geared for a handful of hosts with some commonalities and some differences. Writing playbooks feels like a still-imperative wrapper around shell commands, just in a bespoke and verbose YAML syntax.
Instead I am using my own script that runs a tree of files through a template engine, drops them on each host being configured, and then runs triggers based on what has changed. This seems utterly simplistic, lacks polish, eschews common practices, etc. But the overall configuration seems straightforwardly grokkable compared to the heavy tools.
Not saying you couldn't do that with custom scripts, but I found that when I tried writing my own admin scripts I was solving problems that the ansible team has already solved. It's a matter of what you want to spend time on IMO.
Having said that, I am to the point where it would be really nice if my ssh pushes ran in parallel, which is one of those robust niceties you give up by going your own way. So I'll have to revisit Fabric because it would be complementary - thanks for the reminder!
Putting everything in YAML is helpful because no matter what service you are setting up, the format is the same to read and understand. And I hope you are using modules and not shell command directly (except for the small cases it is necessary)
Ansible can be as simple or as complex as you made it. I bet your script isn’t as nice as an Ansible setup, nor as maintainable. Ansible’s templating engine is super flexible.
Ansible uses jinja2, and so do I. I obviously can't form an objective opinion on the "niceness", having developed it. But I'll say that my setup puts which files are on which hosts front and center, whereas it seems like Ansible would want that splayed out into a directory tree of "roles" (of which I'd have about 25). With my setup, I've got that in 200 lines of python including host/group definitions (excluding comments), with the actual config files living in one analogous tree (eg conf/etc/network/interfaces).
Half the reason I threw my comment out there was to see what bounced back, as I am currently working on this system. One of the responses was about error checking, which resonated. So I've since given Ansible another shot, for managing the top-level (calling my templater for each host, apt upgrade, etc). I think I do like it for this, now that it's much closer to its sweet spot of doing similar things to every host.
Overall my goal is to write very few on-host configuration scripts, and prefer overwriting files. For example, most triggers are simply service restarts, which can also be performed by a full reboot.