[Ansible] Inventory - host pattern
$ cat inventory1
srv1.example.com
srv2.example.com
s1.lab.example.com
s2.lab.example.com
[web]
jupiter.lab.example.com
saturn.example.com
[db]
db1.example.com
db2.example.com
db3.example.com
[lb]
lb1.lab.example.com
lb2.lab.example.com
[boston]
db1.example.com
jupiter.lab.example.com
lb2.lab.example.com
[london]
db2.example.com
db3.example.com
file1.lab.example.com
lb1.lab.example.com
[dev]
web1.lab.example.com
db3.example.com
[stage]
file2.example.com
db2.example.com
[prod]
lb2.lab.example.com
db1.example.com
jupiter.lab.example.com
[function:children]
web
db
lb
city
[city:children]
boston
london
environments
[environments:children]
dev
stage
prod
new
[new]
172.25.252.23
172.25.252.44
172.25.252.32
$ ansible '*.lab.example.com' -i inventory1 --list-hosts
=> *.lab.example.com 으로 끝나는 모든 호스트 나열
$ ansible '*example.com, !*.lab.example.com' -i inventory1 --list-hosts
=> *lab.example.com 을 제외한 *example.com 호스트 나열
$ ansible 'prod, *lab*,172*' -i inventory1 --list-hosts
=> prod 그룹, lab 이 들어가는, 172로 시작하는 호스트 나열
$ ansible 'db,&london' -i inventory1 --list-hosts
=> db그룹과 london 그룹에 모두 속하는 호스트 나열
$ ansible ungroupd -i inventory1 --list-hosts
=> 그룹에 속하지 않은 호스트 나열