Handling and verifying hosts file
by sij /
Every time I create a new playbook, I want to verify, that I grouped the hosts correctly. Here I is my "How I do it".
First of all. My hosts files are always in the yaml format, even tough it could be an INI file. I am using this format, as all playbooks use this format as well.
all: hosts: children: web: hosts: webserver1.codesie.ch: db: hosts: dbserver1.codesie.ch:
Show all hosts
ansible all --list-hosts
hosts (2): webserver1.codesie.ch dbserver1.codesie.ch
Show hosts of a group
ansible -l web all --list-hosts
hosts (1): webserver1.codesie.ch