An Ansible variable file contains the following content:
myapp:
option1: one
Which of the following strings can be used to reference the defined variable? (Choose two correct answers).
An Ansible variable file contains the following content:
myapp:
option1: one
Which of the following strings can be used to reference the defined variable? (Choose two correct answers).
To reference a variable within a dictionary in Ansible, you can use either the bracket notation or the dot notation. In this case, you have a dictionary 'myapp' with a key 'option1'. Therefore, you can reference it using 'myapp["option1"]' or 'myapp.option1'. Both 'myapp(option1);', 'option1@myapp', and 'myapp{{option1}}' are not valid ways to reference dictionary variables in Ansible.
The correct answer is C and D see: https://docs.ansible.com/ansible/2.5/user_guide/playbooks_variables.html#what-makes-a-valid-variable-name "... YAML also supports dictionaries which map keys to values. For instance: foo: field1: one field2: two You can then reference a specific field in the dictionary using either bracket notation or dot notation: foo['field1'] foo.field1 "
This answer is wrong: The correct answer is C and D
Ansible 2.5 documentation: YAML also supports dictionaries which map keys to values. For instance: foo: field1: one field2: two You can then reference a specific field in the dictionary using either bracket notation or dot notation: foo['field1'] foo.field1 Ansible 5 documentation: Simple variables: remote_install_path: /opt/my_app_config ... ansible.builtin.template: src: foo.cfg.j2 dest: '{{ remote_install_path }}/foo.cfg' Referencing list variables: region: "{{ region[0] }}" Dictionary variables: foo['field1'] foo.field1