There is also this related question "Access predefined ansible modules in custom module" but unfortunately without an helpful answer.
In general, I would like to create a Custom Module which uses some Core Modules.
If I e.g. want to use the Core Module file
, I could of course look at the main
function and extract the parts needed by importing the functions required.
So to create / remove a file this would require to use something like
from ansible.modules.file import check_owner_exists, check_group_exists, keep_backward_compatibility_on_timestamps, ensure_file_attributes, ensure_absent
Then copy the required code and use it accordingly.
This seems like a huge workaround for something as simple as importing a core module in a custom module.
Are there any better ways to call the file
module in a custom module?