# dynamic inventory and ungrouped hosts. might be a documentation thing

**URL:** <https://forum.ansible.com/t/dynamic-inventory-and-ungrouped-hosts-might-be-a-documentation-thing/23589>\
**Category:** Ansible Developer\
**Created:** [January 30, 2017, 7:54am UTC](https://forum.ansible.com/t/dynamic-inventory-and-ungrouped-hosts-might-be-a-documentation-thing/23589 "2017-01-30T07:54:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pixel\_fairy](https://avatars.discourse-cdn.com/v4/letter/p/6f9a4e/32.png) [@pixel\_fairy](https://forum.ansible.com/u/pixel_fairy)\
**Post date:** [January 30, 2017, 7:54am UTC](https://forum.ansible.com/t/dynamic-inventory-and-ungrouped-hosts-might-be-a-documentation-thing/23589/1 "2017-01-30T07:54:20Z")

</div>

using ansible 2.2.1.0, a dynamic inventory script will leave out hosts that are not in a group, unless you list them in hosts. should this be fixed in the docs? is there a better way?

`

#!/bin/sh

cat \<\<EOF  
{  
“red”: {  
“hosts”: [  
“alpha”,  
“bravo”  
]  
},  
“\_meta”: {  
“hostvars”: {  
“alpha”: {  
“ansible\_host”: “192.168.0.1”  
},  
“bravo”: {  
“ansible\_host”: “192.168.0.2”  
},  
“charlie”: {  
“ansible\_host”: “192.168.0.3”  
},  
“delta”: {  
“ansible\_host”: “192.168.0.4”  
}  
}  
}  
}  
EOF

`

`$ ansible all --list-hosts hosts (2): alpha bravo`

adding a hosts list fixes it,

`  
#!/bin/sh

cat \<\<EOF  
{  
“hosts”: [  
“alpha”,  
“bravo”,  
“charlie”,  
“delta”  
],  
“red”: {  
“hosts”: [  
“alpha”,  
“bravo”  
]  
},  
“\_meta”: {  
“hostvars”: {  
“alpha”: {  
“ansible\_host”: “192.168.0.1”  
},  
“bravo”: {  
“ansible\_host”: “192.168.0.2”  
},  
“charlie”: {  
“ansible\_host”: “192.168.0.3”  
},  
“delta”: {  
“ansible\_host”: “192.168.0.4”  
}  
}  
}  
}  
EOF  
`

`  
$ ansible all --list-hosts  
hosts (4):  
alpha  
bravo  
charlie  
delta

`
