Score:0

How to specify an exclusion pattern in an inventory file

uz flag
jeb

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

Score:1
ca flag

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.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.