0

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 hostnameis populated by the fact ansible_nodename I do not know how implement that.

how could I modify this

zn553
  • 87
  • 7
  • 1
    I'm not clear what you're asking. You mentioned the `ansible_nodename` fact in a comment, but you don't appear to be referring to it anywhere. Can you update your question to explain in a little more detail what you're trying to accomplish? – larsks May 23 '19 at 18:28
  • I tried editing the questions hopefully is more clear now.. i do not know how to implement it. – zn553 May 24 '19 at 13:54

0 Answers0