# format of the /etc/ansible/hosts file

**URL:** <https://forum.ansible.com/t/format-of-the-etc-ansible-hosts-file/30134>\
**Category:** Ansible Project\
**Created:** [April 17, 2019, 12:07pm UTC](https://forum.ansible.com/t/format-of-the-etc-ansible-hosts-file/30134 "2019-04-17T12:07:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![erichymowitz](https://avatars.discourse-cdn.com/v4/letter/e/9d8465/32.png) [@erichymowitz](https://forum.ansible.com/u/erichymowitz)\
**Post date:** [April 17, 2019, 12:07pm UTC](https://forum.ansible.com/t/format-of-the-etc-ansible-hosts-file/30134/1 "2019-04-17T12:07:10Z")

</div>

This is probably an FAQ, and I apologize, but I can’t find this explicitly written anywhere.

In my /etc/ansible/hosts file, I have a few hosts that are not in any group, followed by a bunch of groups with hosts

hostA  
hostB

hostC

hostD

[group1]  
host1  
host2  
host3

I want to verify that these three statements are correct:

All “ungrouped” hosts must appear in the file before the first group label.

Once I have defined a group label, all following hosts are in that group, until EOF or the next group label.

Blank lines in between hosts do not end a group section.

Thanks.

–EbH

---

<div class="post-metadata">

**Author:** ![lander.hernandezmart](https://avatars.discourse-cdn.com/v4/letter/l/8dc957/32.png) [@lander.hernandezmart](https://forum.ansible.com/u/lander.hernandezmart)\
**Post date:** [April 17, 2019, 12:10pm UTC](https://forum.ansible.com/t/format-of-the-etc-ansible-hosts-file/30134/2 "2019-04-17T12:10:34Z")

</div>

the suppository is placed on the flat part

---

<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:** [April 17, 2019, 1:47pm UTC](https://forum.ansible.com/t/format-of-the-etc-ansible-hosts-file/30134/3 "2019-04-17T13:47:36Z")

</div>

All three of them are correct.

---

<div class="post-metadata">

**Author:** ![erichymowitz](https://avatars.discourse-cdn.com/v4/letter/e/9d8465/32.png) [@erichymowitz](https://forum.ansible.com/u/erichymowitz)\
**Post date:** [April 17, 2019, 7:07pm UTC](https://forum.ansible.com/t/format-of-the-etc-ansible-hosts-file/30134/4 "2019-04-17T19:07:39Z")

</div>

Thanks.

–EbH

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [April 18, 2019, 3:53pm UTC](https://forum.ansible.com/t/format-of-the-etc-ansible-hosts-file/30134/5 "2019-04-18T15:53:20Z")

</div>

'hosts file format' is not a single thing, we have several ones to  
choose from, by default 'ini-ish', yaml and toml, it is plugin based  
so you can basically use any format you want as long as there is a  
plugin for it.
