Home » Amazon » AWS DevOps Engineer Professional v.2 » Which is the proper syntax for referencing a variable’s value in an Ansible task?
Which is the proper syntax for referencing a variable’s value in an Ansible task?
A. ${variable_name}
B. { variable_name }
C. “{{ variable_name }}”
D.@variable_name
Correct Answer: C
Explanation/Reference:
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