> On 22. Jan 2021, at 14:28, SZIGETVÁRI János <jszigetv...@gmail.com> wrote: > > Technically you are right, it would be possible to always prepend the extra > command, and this being a POC is also be an argument in support of this > option. (If I end up not finding an easy way of doing this, then I may end up > doing like you suggested.) > However I am interested how this could be done, and it would also be useful > to have a different module name to distinguish which command is running where.
I see your point. I have never developed a module myself, however, I see two issues with your approach: * There is no class to inherit from and just overwrite a method. The command module is a simple and fairly straightforward script [1]. No OOP magic here. * More importantly, code for a module has to be essentially self-contained because it will be copied to the remote host and executed there! You can not make a lot of assumptions about what will be available there. AFAIK you can only use stuff from the module utilities [2] which will then be packaged together with the module code itself and shipped to the remote host. And the Python standard lib, of course. You can *not* access code from other modules! (Somebody please correct me if the above is not exact!) So your best bet is probably to make a copy of command.py and tweak it to satisfy your needs [3]. Good luck -Andi [1]: https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/command.py [2]: https://docs.ansible.com/ansible/latest/dev_guide/developing_module_utilities.html [3]: https://docs.ansible.com/ansible/latest/dev_guide/developing_locally.html -- You received this message because you are subscribed to the Google Groups "Ansible Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-devel+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-devel/474317F0-36A6-4AB0-B96E-006939D26C9E%40gmail.com.