Hello list,
I was trying to make my first steps writing an Ansible module (in Python).
The main documentation is pretty clear, so i moved very smoothly using the AnsibleModule helper class.
So far, i have been using only simple arguments: scalars or JSON-serializable structs (lists, dicts etc.).
Now, i need to declare a file argument (say src
given as a local path) that is present at Ansible’s control
host and must be transferred to the managed host (and then it will acquire a temporary file name).
This is very similar to what the copy
module does: when the module is executed on the managed host
the src
argument is just a remote temporary file path (and i assume transfer has already taken place).
I was looking into copy
module’s source code (to mimic it and declare such an argument), but i was
not able to figure it out. Is there some kind of magic (control-side pre-execute hooks?) behind the behavior of
modules like copy
and template
?
So, my question: does a custom module have the option to transfer a control-side file and handle it (managed-side)
as a normal file path? Or instead, must we break this into 2 tasks (one builtin copy task, one custom task)?
Thank you!