Special host management using patterns
We have already established that you will often want to run either an ad hoc command or a playbook against only a subsection of your inventory. So far, we have been quite precise in doing that, but let’s now expand upon this by looking at how Ansible can work with patterns to figure out which hosts a command (or playbook) should be run against.
As a starting point, let’s again consider an inventory that we defined earlier in this chapter for the purposes of exploring host groups and child groups. For your convenience, the inventory contents are provided again here:
loadbalancer.example.org [frontends] web01.example.org web02.example.org [apps] app01.example.org app02.example.org [databases] db01.example.org db02.example.org [fedora:children] apps databases [ubuntu:children] frontends
To demonstrate host/group selection by pattern, we shall use the --list-hosts
switch with the ansible
command to see which hosts Ansible would...