Ok, here's the plan, since so many people seem to want this, and I *kind of* want this (common code), but have mostly been concerned about breaking people's modules in live situations and giving Python too many exemptions.
I'll come up with a list of functions and convert a module, and include something like a modules/stub, and once that is there we can
work on applying it to other modules for those that are interested, and then we can start cleaning stuff up. Basically this means a bit more utility functions not less, and yeah, I have preferences that I want to make sure are in there,
and code review is a lousy way for me to get someone else to do that for me (wouldn't be fair, -- move this over to the left, no no, more to the right, no to the left…). Once that's out, we can tweak them as needed.
I should have something this week.
I will also experiment with how I feel about ansible replacing a common block of code dynamically on transfer. I dislike this exemption to python/core modules behaving specially from a theoretical perspective, but would like to prevent
future confusion, so it might be an acceptable compromise provided hacking/test-module can still do the substitutions. Build time would confuse people, but if this just transparently worked it might be ok.
Yes, it makes the ansible modules kind of an internal API, so there will have to be a reasonably rigorous level of "thou shalt not change the return signature of this function, nor it's calling conventions, except to add keyword arguments
that are optional". We'll have to make that clear with a pretty evident skull and crossbones in the module.
Beyond all that, changing the modules is going to require we test them pretty thoroughly before release. So, if we do this, this probably slides our release a couple of weeks to make sure all the corners are well explored. By the very nature
of the modules, they require live testing, so not all of them are things we can unit test to 100% coverage on all platforms very easily. But I'm ok with that, and I think it will be worth it.
Basically a module if it wants the standard python code block will include like this:
{{ template_ansible_python_block_here }}
And it will be runtime, not build time.
--Michael