Hi all,
I am currently developing an Action-module which should do the following:
I have a playbook like this:
- hosts: target-host
tasks: - my_module:
src_host: source-host
regex: some_regex
It should be checked if a file which meets the regex can be found on the source-host. If so, it should be copied to the target-host via the controller-node. I can’t copy the file directly because of security-restrictions.
Currently I solved this by just using paramiko which works fine but isn’t a clean solution.
Questions/What I want to do instead:
-
I would like to access the inventory inside of my Action-Module to get ansible_user, ansible_password and ansible_port of the source-host and target-host. How can I achieve this? I tried to use the InventoryManager without success. Currently i provide all these values as parameters.
-
A far better solution would be, to use _execute_module and execute the find-module on the source-host and then copy the file via the copy-module to the controller-node and the target-host. But it seems there is no delegate-option for execute_module so (by looking at the play from above) it will always be executed on the target-host
Any help or pointing me into the right direction would be very much apricated. Couldn’t find any suitable solution so far even after hours.
Thanks and best regads,
Felix