who to group hosts by fqdn or ip?

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’) }}”

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?

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?

“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.