0

Is it possible to define a group with an exclusion pattern, when defining this group in an inventory file?

group1:
  hosts:
    xxx-[1:100]:

group2:
  hosts:
    xxx-2:
    xxx-37:

# This should contain the hosts from group1 without the hosts from group2
group3:
  # Throws an error: "Invalid characters were found in group names but not replaced"
  children: group1,!group2

Like in In ansible, how do I specify an exclusion set of hosts in a playbook?
But I don't want to define the group logic in each playbook, I want to define it only once in the hosts file

jeb
  • 355
  • 3
  • 11

1 Answers1

1

Is it possible to define a group with an exclusion pattern, when defining this group in an inventory file?

As far as I understand How to build your inventory that is something which is not possible, at least not out-of-box with core components. Maybe with Inventory plugin script ...

But I don't want to define the group logic in each playbook

Leaving one with that as option only.

The Patterns: targeting hosts and groups

let you run commands and playbooks against specific hosts and/or groups in your inventory

and are not intended for the inventory itself.

U880D
  • 1,017
  • 2
  • 12
  • 18