AWS DevOps Engineer Professional DOP-C01 – Question459

When specifying multiple variable names and values for a playbook on the command line, which of the following is the correct syntax?

A.
ansible-playbook playbook.yml -e `host="foo" pkg="bar"'
B. ansible-playbook playbook.yml -e `host: "foo", pkg: "bar"'
C. ansible-playbook playbook.yml -e `host="foo"' -e `pkg="bar"'
D. ansible-playbook playbook.yml –extra-vars "host=foo", "pkg=bar"

Correct Answer: A

Explanation:

Explanation:
Variables are passed in a single command line parameter, `-e’ or `–extra-vars’. They are sent as a single string to the playbook and are space delimited. Because of the space delimeter, variable values must be encapsulated in quotes. Additionally, proper JSON or YAML can be passed, such as: `-e `{“key”: “name”, “array”: [“value1”, “value2”]}’.
Reference:
http://docs.ansible.com/ansible/playbooks_variables.html#passing-va…