i have been trying to use what is here in order to pass the hostname to a module
use ansible_facts in module code
i have the code below which normally will create a fact which i can after use with the template or copy module to copy a file remotely.
#!/usr/bin/python
import custommodule
# ...
hostname = {{ ansible_nodename }} # hostname should come from ansible_nodename fact.
custom_content = custommodule.render(hostname)
facts = dict()
facts['custom_content'] = custom_content
args = {
'changed': False,
'ansible_facts': {'custom_facts': facts},
}
module.exit_json(**args)
the question is how to make sure that the variable hostname
is populated by the fact ansible_nodename
I do not know how implement that.
how could I modify this