Hey Guys!
Thanks again for taking the time to react to my ramblings.
I’m currently working on other things, so I’m looking at this topic from a slightly different perspective. I meanwhile gave up on the concrete plugins I wanted to write because the impact of using dependencies was imho not worth the price and the same goes for the effort to write all functionality from scratch.
One thing that I dearly missed on the way from a complete rookie a somewhat fluent playwright was - as mentioned on github - the lack of guidance for all things outside of playbooks. This particular topic, module vs. action plugin was my most recent issue, but I think it’s just one incarnation of a somewhat larger problem I had:
Ansible is extremely awesome while you are writing playbooks and find suitable modules. I rarely had more fun getting things done than in this context. However, when you have to leave this scope, things get really bad. One thing that pops up is that automation very often is doing the same thing slightly differently over and over again. So reusing solutions is necessary. Ansible has no good tool to allow for reuse, that is as easy to use as playbooks. Roles are the closest you get to that, but that’s not what they are designed for. The lack of a parameter interface for roles makes them unusable for that purpose. That leaves other Ansible constructs to choose from. There are two candidates (for different tasks): Jinja macros as a quick and dirty means to create complex queries and modules. There are three reasons that kill Jinja as viable option: Diagnostics (no way to locate the source of errors), paths (no way to import “…/macros.j2” or “/macros.j2” at least I didn’t find a way), quirky syntax for complex queries. Not that I want to program in Jinja anyway.
Modules: The price for making a playbook functionality reusable by using a role is initially 80 result units per time compared to 100 for playbook hacking. The 20 lost units are spend solving issues with parameters. Over time, the 80-20 becomes 20-80. The price for making such a functionality a plugin is initially 1-99 and over time maybe 40-60. These are emotional estimates, not real numbers.
The problems in my view are:
- The plugin interface grew over time and has not been consistently designed. Hacks became quasi-standards and they can no longer be changed. Things can only get worse from here on out and they are already bad.
- The amount of scaffolding a clean implementation of a module needs is utterly disproportional compared f.e. to what you would need to do when creating a Jinja macro or a role abused as module. So much so that it’s very attractive to do it anyway, no matter how bad that is and no matter that you know it will bite you back.
- The dependency issue combined with the practice (here of 3rd party module authors) to use modules when you should use actions and many other circumstances that limit choices only leaves a very narrow path for some things that can be implemented easily, while most other things are so complex that I could implement them faster in plain ANSI C from scratch.
- The fact that you can’t debug modules live is a severe limitation. It’s not even possible (to my knowledge) to interactively step through actions at the interface between controller and target.
- I have many many other similar issues, but don’t have the time right now to complete the list, so I’ll leave it at this
What I’m doing right now is utterly ridiculous. To avoid all these issues, I’m using Emacs-Org-Mode with its literate programming features to generate Ansible Playbooks, Shell- and Python scripts. I’m using Ansible Playbooks as automation assembly language. I know that this is idiotic, but it is about 2-5 times more time efficient than anything else I did in the context of Ansible. The only reason why I even try to do that is because I get excellent documentation from this (this was how I got the idea) and because a lot of functionality is already implemented in Ansible and I have no better way to get things done in time.
With this new experience, I start to believe that my original issue is more than just a documentation issue. I think the real problem is that Ansible is pure awesomeness as long as you write playbooks and at the same time a nightmare when you develop modules. And you have to eventually develop modules.
Please don’t misunderstand this as an attempt to complain or criticize your work. It’s frustration because I would love to work with Ansible, but it’s really getting too painful.
It’s fun to fix most issues with a 35 year old Elisp-Editor. But I don’t think that this is a viable approach. Nevertheless it works surprisingly well.