ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 196 - DOP-C01 discussion

Report
Export

Which is the proper syntax for referencing a variable's value in an Ansible task?

A.
${variable_name}
Answers
A.
${variable_name}
B.
{ variable_name }
Answers
B.
{ variable_name }
C.
"{{ variable_name }}"
Answers
C.
"{{ variable_name }}"
D.
@variable_name
Answers
D.
@variable_name
Suggested answer: C

Explanation:

We use the variable's name to reference the variable which we encapsulate in curly brackets `{{ }}'; however, the YAML syntax dictates that a string beginning with a curly bracket denotes a dictionary value. To get around this, it is proper to wrap the variable declaration in quotes.

Reference: http://docs.ansible.com/ansible/playbooks_variables.html#hey-wait-a-yaml-gotcha

asked 16/09/2024
Laura Reyero
38 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first