Courseiva
mediumMultiple Choice

350-401 Practice Question: Given the following Ansible playbook snippet: ---…

Given the following Ansible playbook snippet: --- - name: Configure VLAN hosts: switches gather_facts: no tasks: - name: Create VLAN 100 ios_vlan: vlan_id: 100 name: Engineering state: present Which statement is true about this playbook?

⚠ Common exam trap

Cisco often tests the distinction between `state: present` (create/update) and `state: absent` (delete), and the trap here is assuming `state: present` only checks or reports status rather than actively configuring the device.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

It creates VLAN 100 with name Engineering if it does not exist.

The `ios_vlan` module with `state: present` ensures the VLAN exists with the specified parameters. Since `gather_facts: no` is set, the playbook does not gather device facts but still performs the configuration task. The correct answer is A because the module will create VLAN 100 with the name 'Engineering' if it does not already exist on the switch.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✓

    It creates VLAN 100 with name Engineering if it does not exist.

    Why this is correct

    The ios_vlan module with state: present performs an idempotent operation: if VLAN 100 does not exist in the device's VLAN database, it creates it and assigns the name 'Engineering'. If the VLAN already exists but has a different name, the module updates the name to match the declared state. Because the operation is declarative, Ansible compares the current configuration to the desired configuration and applies only necessary changes.

  • ✗

    It only checks if VLAN 100 exists and reports its status.

    Why it's wrong here

    This option misreads state: present as a read-only check. In Ansible, state: present is a declarative enforcement directive, not a status query. The module will actively create VLAN 100 if it is missing, and it will also adjust the VLAN's name if it differs from 'Engineering'. Merely reporting status would require a different task, such as using ios_command with 'show vlan' or registering the module's output—not the behavior of ios_vlan with state: present.

  • ✗

    It deletes VLAN 100 if it exists.

    Why it's wrong here

    Deletion is the opposite of what state: present does. Ensure-presence semantics mean Ansible will create or update the resource to match the desired state, never remove it. To delete VLAN 100, the task would need to specify state: absent, which instructs the module to remove the VLAN if it exists. Since this task uses state: present, the VLAN is guaranteed to exist after execution, not be torn down.

  • ✗

    It fails because 'name' is not a valid parameter for ios_vlan.

    Why it's wrong here

    The name parameter is fully supported by the ios_vlan module as the way to set a textual description or label for the VLAN. The module's argument spec includes name for exactly this purpose, and it is commonly used alongside vlan_id to define the VLAN's identity. A failure due to an invalid parameter would occur only if a non-existent attribute like 'vlan_name' or 'description' were used, but 'name' is valid and the playbook would run successfully.

Visual reference

Switch VLAN 10 Sales (192.168.10.0/24) PC-A PC-B VLAN 20 HR (192.168.20.0/24) PC-C PC-D Router VLANs isolate traffic — inter-VLAN routing requires a Layer 3 device

About these practice questions

One of 1,923 original 350-401 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This 350-401 practice question is part of Courseiva's free Cisco certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 350-401 exam.