1

I have an inventory file that is dynamically generated with stanzas/groups in it. For example:

[ABC_foo_something]
server1
server2

[ABC_foo_somethingelse]
server3
server4

[ABC_bar_otherthing]
server5
server6

How can I specify a pattern for my playbook to run on e.g. all ABC_foo* groups.

---
- name: some playbook
  hosts: ABC_foo*
  tasks: etc..etc..

The problem is that the entire string is not known because they are dynamically created. I only know the first few chunks of the pattern and the rest should be wildcarded somehow.

U880D
  • 8,601
  • 6
  • 24
  • 40
snailrider
  • 63
  • 9

2 Answers2

0

My bad, it actually worked with exactly the same way I posted it. Initially I thought it was not working, but I realized my inventory file wasn't created properly.

snailrider
  • 63
  • 9
  • Right, according [Limitations of patterns](https://docs.ansible.com/ansible/latest/user_guide/intro_patterns.html#limitations-of-patterns) "_Patterns depend on inventory._". – U880D Sep 23 '22 at 15:36
0

It is possible to use Patterns: targeting hosts and groups to

choose which managed nodes or groups you want to execute against.

In example Common patterns with which

You can mix wildcard patterns and groups at the same time

as well more Advanced pattern options.

Further Q&A

U880D
  • 8,601
  • 6
  • 24
  • 40