# Question: How do I get hostname as well as ansible\_host in ansible module ??

**URL:** <https://forum.ansible.com/t/question-how-do-i-get-hostname-as-well-as-ansible-host-in-ansible-module/32003>\
**Category:** Ansible Project\
**Created:** [January 20, 2020, 9:51am UTC](https://forum.ansible.com/t/question-how-do-i-get-hostname-as-well-as-ansible-host-in-ansible-module/32003 "2020-01-20T09:51:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raja\_Shekar](https://avatars.discourse-cdn.com/v4/letter/r/ea5d25/32.png) [@Raja\_Shekar](https://forum.ansible.com/u/Raja_Shekar)\
**Post date:** [January 20, 2020, 9:51am UTC](https://forum.ansible.com/t/question-how-do-i-get-hostname-as-well-as-ansible-host-in-ansible-module/32003/1 "2020-01-20T09:51:59Z")

</div>

Hi All,

I develop and maintain the Ansible role: Juniper.junos([https://github.com/Juniper/ansible-junos-stdlib](https://github.com/Juniper/ansible-junos-stdlib)). For the context of the issue, please refer to [https://github.com/Juniper/ansible-junos-stdlib/issues/468](https://github.com/Juniper/ansible-junos-stdlib/issues/468).

Consider the following scenario wherein the user has provided both hostname and IP. Currently, the module parameters only include host. Is there any way that I can get the hostname of the target device as well ??

### /etc/ansible/hosts.yml

```auto
[vMX]
my-qfx-a ansible_host=xx.xx.xx.xx

```

### The module receives the following parameters during invocation, which don’t contain the hostname

```auto
{
'comment': None,
'load': None,
'remove_ns': None,
'retrieve': 'committed',
'vars': None,
'attempts': None,
'host': 'xx.xx.xx.xx',
'diff': None,
'port': 22,
'ignore_warning': None,
'confirmed': None,
'console': None,
'namespace': None,
'check': None,
'dest': None,
'logdir': None,
'template': None,
'provider': None,
'dest_dir': 'saved',
'commit_empty_changes': False,
'baud': None,
'rollback': None,
'format': 'set',
'passwd': 'xxxxx',
'cs_user': None,
'ssh_config': None,
'return_output': False,
'user': 'xxxx',
'logfile': 'abcd.log',
'diffs_file': None,
'src': None,
'level': None,
'url': None,
'lines': None,
'check_commit_wait': None,
'cs_passwd': None,
'filter': None,
'mode': None,
'timeout': 30,
'commit': None,
'model': None,
'ssh_private_key_file': None,
'options': {
'database': 'committed',
'format': 'set'
  },
'config_mode': 'exclusive'
}

```

Regards,  
Raja Shekar
