nerdexam
Cisco

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.

Infrastructure and Automation

Question

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 unique per device.
- 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)
  • A
    88% (29)
  • B
    6% (2)
  • C
    3% (1)
  • D
    3% (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.

Ahost_vars directoryCorrect

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.

Bhome directory

The home directory is not a recognized Ansible inventory structure location for host-specific variables.

Cgroup_vars directory

The group_vars directory stores variables shared across a group of hosts, not variables that are unique to a single device.

Dcurrent working directory

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

#Ansible#Variable Management#host_vars#Network Configuration

Community Discussion

No community discussion yet for this question.

Full 350-901 Practice