til
til copied to clipboard
Ansible: Patterns: targeting hosts and groups
Description | Pattern(s) | Targets |
---|---|---|
All hosts | all (or *) | |
One host | host1 | |
Multiple hosts | host1:host2 (or host1,host2) | |
One group | webservers | |
Multiple groups | 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 |
You can use either a comma (,) or a colon (:) to separate a list of hosts. The comma is preferred when dealing with ranges and IPv6 addresses.
Ref: https://docs.ansible.com/ansible/latest/user_guide/intro_patterns.html#intro-patterns