AWS DevOps Engineer Professional DOP-C01 – Question453

If Erin has three clusters of server types that are all managed by Ansible and she needs to provision each cluster so that they are configured with their appropriate NTP server addresses. What is the best method Erin should use in Ansible for managing this?

A.
Write a task that scans the network in the target hosts' region for the NTP server, register the resulting address so that the next task can write the NTP configuration.
B. Break down the hosts by region in the Ansible inventory file and assign an inventory group variable the NTP address value for the respective region. The playbook can contain just the single play referencing the NTP variable from the inventory.
C. Create a playbook for each different region and store the NTP address in a variable in the play in the event the NTP server changes.
D. Create three plays, each one has the hosts for their respective regions and set the NTP server address in each task.

Correct Answer: B

Explanation:

Explanation:
While all four answers provided are correct, only B is the best choice. Ansible offers the ability to assign variables to groups of hosts in the inventory file. When the playbook is ran it will use the variables assigned to the group, even all the groups are specified in a single playbook run. The respective variables will be available to the play. This is easiest method to run, maintain and write.
Reference:
http://docs.ansible.com/ansible/intro_inventory.html#group-variables