350-901 · Question #51
Refer to the exhibit. As part of the Ansible playbook workflow, several new interfaces are being configured using the netconf_config module. The task references the interface variables that are…
The correct answer is A. host_vars directory. In Ansible, variables that are unique per device (host-specific) are stored in the host_vars directory, keyed by the device hostname.
Question
- name: Configure Interfaces
with_items: "{{interfaces}}"
netconf_config:
xml_from_file: true
xml:
<config>
<interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces">
<interface>
<name>{{item.interface_type}}{{item.interface_id}}</name>
<description>{{item.description}}</description>
<type xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:ethernetCsmacd</type>
<enabled>true</enabled>
<ipv4 xmlns="urn:ietf:params:xml:ns:yang:ietf-ip">
<address>
<ip>{{item.ip_address}}</ip>
<mask>{{item.subnet_mask}}</mask>
</address>
</ipv4>
</interface>
</interfaces>
</config>
In which directory is the YAML file with these variables found?Options
- Ahost_vars directory
- Bhome directory
- Cgroup_vars directory
- Dcurrent working directory
How the community answered
(33 responses)- A88% (29)
- B6% (2)
- C3% (1)
- D3% (1)
Why each option
In Ansible, variables that are unique per device (host-specific) are stored in the host_vars directory, keyed by the device hostname.
The host_vars directory in an Ansible project stores variable files named after each individual host, making it the correct location for per-device interface variables such as IP addresses, interface IDs, and descriptions referenced by the playbook's with_items loop.
The home directory is not a recognized Ansible inventory structure location for host-specific variables.
The group_vars directory stores variables shared across a group of hosts, not variables that are unique to a single device.
The current working directory has no special significance in Ansible for storing host-specific variable files.
Concept tested: Ansible host_vars directory for per-device variables
Source: https://docs.ansible.com/ansible/latest/inventory_guide/intro_inventory.html#organizing-host-and-group-variables
Topics
Community Discussion
No community discussion yet for this question.