import exceptions
import subprocess
from ansible.module_utils.basic import *
def main():
module = AnsibleModule(argument_spec = dict(data=dict(required=False, default=None),),supports_check_mode = True)
dt = {"System_Details":{'Kernel_version':ansible_hostname}}
module.exit_json(ansible_facts=dt)
main()
Above is my custom module, where i am trying to access the ansible facts.
I am getting the below error:
fatal: [172.19.3.60]: FAILED! => {"changed": false, "failed": true, "module_stderr": "", "module_stdout": "Traceback (most recent call last):\r\n File \"/root/.ansible/tmp/ansible-tmp-1463490863.86-275822236207074/get_system_specific_details\", line 2014, in <module>\r\n main()\r\n File \"/root/.ansible/tmp/ansible-tmp-1463490863.86-275822236207074/get_system_specific_details\", line 2011, in main\r\n dt = {\"System_Details\":{'Kernel_version':ansible_hostname}}\r\nNameError: global name 'ansible_hostname' is not defined\r\n", "msg": "MODULE FAILURE", "parsed": false}
Can you please help me out??
Thanks in advance,
Mona G
=========================================================================================