# gather\_facts:  ansible\_hostname only

**URL:** <https://forum.ansible.com/t/gather-facts-ansible-hostname-only/26542>\
**Category:** Ansible Project\
**Created:** [January 23, 2018, 5:42pm UTC](https://forum.ansible.com/t/gather-facts-ansible-hostname-only/26542 "2018-01-23T17:42:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Harmon](https://avatars.discourse-cdn.com/v4/letter/j/edb3f5/32.png) [@John\_Harmon](https://forum.ansible.com/u/John_Harmon)\
**Post date:** [January 23, 2018, 5:42pm UTC](https://forum.ansible.com/t/gather-facts-ansible-hostname-only/26542/1 "2018-01-23T17:42:52Z")

</div>

Is there a way for me to specify the only fact I care about gathering? I have a server that is giving me grief due to the way its disks are setup (tons of nfs shares, etc)… at least I assume that is why it is giving me grief. I just need to gather the ansible\_hostname fact.

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [January 23, 2018, 5:58pm UTC](https://forum.ansible.com/t/gather-facts-ansible-hostname-only/26542/2 "2018-01-23T17:58:13Z")

</div>

The most minimal you can do, and still get that would be to define:

gather\_subset: platform

It will include ansible\_hostname, plus a few extras.

---

<div class="post-metadata">

**Author:** ![John\_Harmon](https://avatars.discourse-cdn.com/v4/letter/j/edb3f5/32.png) [@John\_Harmon](https://forum.ansible.com/u/John_Harmon)\
**Post date:** [January 23, 2018, 5:58pm UTC](https://forum.ansible.com/t/gather-facts-ansible-hostname-only/26542/3 "2018-01-23T17:58:39Z")

</div>

The following works on the command line, but I can’t seem to find the right syntax to put it into a playbook:

`  
root@ansible:/playbooks # ansible -m setup -a ‘filter=ansible\_hostname’ ansible-oel6  
ansible-oel6 | SUCCESS =\> {  
“ansible\_facts”: {  
“ansible\_hostname”: “ansible-oel6”  
},  
“changed”: false  
}

`

---

<div class="post-metadata">

**Author:** ![John\_Harmon](https://avatars.discourse-cdn.com/v4/letter/j/edb3f5/32.png) [@John\_Harmon](https://forum.ansible.com/u/John_Harmon)\
**Post date:** [January 23, 2018, 6:09pm UTC](https://forum.ansible.com/t/gather-facts-ansible-hostname-only/26542/4 "2018-01-23T18:09:06Z")

</div>

Thanks Matt. It seems platform and !all,min equate to the same thing. I tried the following in my playbook and it works:

`  
pre\_tasks:

- setup:  
gather\_subset: min  
filter: ansible\_hostname

`

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [January 23, 2018, 6:19pm UTC](https://forum.ansible.com/t/gather-facts-ansible-hostname-only/26542/5 "2018-01-23T18:19:55Z")

</div>

gather\_subset is also allowed on the play[1] level.

- hosts: all  
&nbsp;&nbsp;gather\_subset: min

[1] [https://docs.ansible.com/ansible/latest/playbooks\_keywords.html#play](https://docs.ansible.com/ansible/latest/playbooks_keywords.html#play)
