# who to group hosts by fqdn or ip?

**URL:** <https://forum.ansible.com/t/who-to-group-hosts-by-fqdn-or-ip/15071>\
**Category:** Ansible Project\
**Created:** [April 23, 2014, 3:06am UTC](https://forum.ansible.com/t/who-to-group-hosts-by-fqdn-or-ip/15071 "2014-04-23T03:06:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Camp\_Nou](https://avatars.discourse-cdn.com/v4/letter/c/34f0e0/32.png) [@Camp\_Nou](https://forum.ansible.com/u/Camp_Nou)\
**Post date:** [April 23, 2014, 3:06am UTC](https://forum.ansible.com/t/who-to-group-hosts-by-fqdn-or-ip/15071/1 "2014-04-23T03:06:55Z")

</div>

It seems group\_by doesn’t support filters?

‘’’

- hosts: all  
tasks:
- name: group hosts by inventory hostname  
group\_by: key=“{{ inventory\_hostname | regex\_replace(‘.+\.(prod|test|dev)\.example\.org’, ‘\1’) }}”  
‘’’

The task doesn’t work.

It will generate a group with the name “{{ inventory\_hostname-|-regex\_replace(‘.+\.(prod|test|dev)\.example\.org’, ‘\1’) }}”

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [April 23, 2014, 12:09pm UTC](https://forum.ansible.com/t/who-to-group-hosts-by-fqdn-or-ip/15071/2 "2014-04-23T12:09:46Z")

</div>

Sounds like the filter failed to parse your regex, or there was no regex\_replace filter in that version of Ansible.

I agree this should produce an exception in these cases.

What version of Ansible are you on?

---

<div class="post-metadata">

**Author:** ![Nathan\_Robertson](https://avatars.discourse-cdn.com/v4/letter/n/bbe5ce/32.png) [@Nathan\_Robertson](https://forum.ansible.com/u/Nathan_Robertson)\
**Post date:** [July 23, 2014, 5:23pm UTC](https://forum.ansible.com/t/who-to-group-hosts-by-fqdn-or-ip/15071/3 "2014-07-23T17:23:12Z")

</div>

Michael,

I am getting a similar issue on 1.4.3

I think the issue is that this version of Ansible does not support this filter. What version was this filter implemented?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [July 23, 2014, 10:11pm UTC](https://forum.ansible.com/t/who-to-group-hosts-by-fqdn-or-ip/15071/4 "2014-07-23T22:11:16Z")

</div>

“I am getting a similar issue on 1.4.3”

Very ancient at this point.

Please upgrade to 1.6.8 (latest) first before asking a question, can’t spend time on the project list on older releases - sorry.
