[ Prev ] [ Index ] [ Next ]

Patterns

Created Dienstag 04 Februar 2020


Source


A pattern chooses the host(s) or group of hosts (or excludes) on which ansible will act.


Common patterns

All hosts: all (or *)
One host: host1 -> as listed in the inventory
Multiple hosts: host1:host2 (or host1,host2)
One group: webservers
Multiple groups: webservers:dbservers (or webservers,dbservers) -> all hosts in webservers plus all hosts in dbservers
Excluding groups: webservers:!atlanta -> all hosts in webservers except those in atlanta
Intersection of groups: webservers:&staging -> any hosts in webservers that are also in staging


Escape & and ! one command line.


Wildcards

E.g.
192.0.\*
\*.example.com
\*.com


You can mix them with common patterns:
one*.com:dbservers