AWS DevOps Engineer Professional DOP-C01 – Question474

Which answer is the proper syntax for specifying two target hosts on the command line when running an
Ansible Playbook?

A.
ansible-playbook -h host1.example.com -i all playbook.yml
B. ansible-playbook -i host1.example.com playbook.yml
C. ansible-playbook -h host1.example.com,host2.example.com playbook.yml
D. ansible-playbook -i host1.example.com,host2.example.com playbook.yml

Correct Answer: D

Explanation:

Explanation:
Ansible uses the `-i’ flag for accepting an inventory file or host. To allow Ansible to determine if you are passing a host list versus an inventory file the list must be comma separated. If a single host is specified, a trailing comma must be present.
Reference:
http://docs.ansible.com/ansible/intro_inventory.html#inventory