I am developing an Ansible module that generates a url, fetches (like get_url) the tarball at that url from my internal artifactory and then extracts it. I am wondering if there is a way to include or extend the get_url Ansible core module in my module. I can't have this in multiple steps because the url being used is generated from a git hash and requires a multi-step search.
If there isn't a way, I will probably just copy the whole get_url module and use it in my module, but I would like to avoid that.
I'd like to do something like:
module_json_response = module.get_module('get_url').issue_command('url=http://myartifactory.com/my_artifact.tar.gz dest=/path/to/local/my_artifact.tar.gz');
My understanding of Ansible is that it uploads the module in use and executes it, including another module isn't supported or isn't documented.
Thanks in advance for any help.
To quote Michael DeHaan's post here:
Generally speaking, Ansible allows sharing code through "lib/ansible/module_common.py" to make writing functionality easier.
It does not, however, make it possible for one module to call another, which has not, to date, really been needed -- that's not entirely true, we used to have something like this for file and copy until we got smart and moved the file attribute code into common :)
It seems like since url access is frequent enough we could make a common function in module common for url downloads -- IF we modify the get_url code to also use it so we aren't repeating ourselves.
He later followed up with:
You can access the way template works by writing an action plugin, but it's more involved than writing a simple client module.
+1 to moving get_url code into common, that's come up a few times.