ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 277 - DOP-C01 discussion

Report
Export

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"'
Answers
A.
ansible-playbook playbook.yml -e `host="foo" pkg="bar"'
B.
ansible-playbook playbook.yml -e `host: "foo", pkg: "bar"'
Answers
B.
ansible-playbook playbook.yml -e `host: "foo", pkg: "bar"'
C.
ansible-playbook playbook.yml -e `host="foo"' -e `pkg="bar"'
Answers
C.
ansible-playbook playbook.yml -e `host="foo"' -e `pkg="bar"'
D.
ansible-playbook playbook.yml --extra-vars "host=foo", "pkg=bar"
Answers
D.
ansible-playbook playbook.yml --extra-vars "host=foo", "pkg=bar"
Suggested answer: A

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-variables-on-the-commandline

asked 16/09/2024
DATA DYNAMICAL SOLUTIONS
35 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first