Courseiva
mediumMultiple Choice

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

Given the following Ansible playbook snippet: --- - name: Configure interface hosts: routers gather_facts: no tasks: - name: Set IP address ios_config: lines: - ip address 192.168.1.1 255.255.255.0 - no shutdown parents: interface GigabitEthernet0/1 What is the effect of this playbook?

⚠ Common exam trap

Test-takers frequently think `parents` is only for ACL or routing contexts, or that `lines` and `parents` are mutually exclusive, when in fact `parents` is the standard way to nest commands under a parent configuration block like an interface.

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 configures IP address 192.168.1.1/24 on interface GigabitEthernet0/1 and enables it.

The `ios_config` module uses the `parents` parameter to navigate into interface configuration mode before applying the `lines` commands. The `ip address 192.168.1.1 255.255.255.0` command configures the IP address with a /24 subnet mask, and `no shutdown` administratively enables the interface. This is the standard Cisco IOS behavior for interface configuration.

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 configures IP address 192.168.1.1/24 on interface GigabitEthernet0/1 and enables it.

    Why this is correct

    This is the correct behavior. The 'parents: interface GigabitEthernet0/1' parameter makes the Ansible ios_config module first enter interface configuration mode; then the commands in 'lines' are applied as subcommands under that interface. The line 'ip address 192.168.1.1 255.255.255.0' assigns the IPv4 address, and 'no shutdown' changes the interface administrative state from admin-down to up, enabling the interface. The module mimics a human CLI session, so both commands are committed to the running configuration exactly as if typed manually.

  • ✗

    It configures the IP address globally, not under the interface.

    Why it's wrong here

    This is incorrect because the 'parents' parameter in the ios_config module explicitly designates the configuration mode that the module should enter before executing the commands in 'lines'. Here, 'parents: interface GigabitEthernet0/1' means the module first enters interface configuration mode, so the IP address command is issued within that context, not in global configuration mode. If the 'parents' parameter were omitted, then the commands would indeed be applied globally, but the presence of 'parents' forces the interface-level context. Thus, this option misinterprets the role of the 'parents' directive.

  • ✗

    It only configures the IP address; no shutdown is ignored because it is not a valid command.

    Why it's wrong here

    This is incorrect because 'no shutdown' is a valid and widely used command in Cisco IOS interface configuration mode. It is not ignored by the ios_config module; the module sends each line in the 'lines' list verbatim to the device after entering the parent context. The interface's default administrative state is typically 'shutdown', so issuing 'no shutdown' is necessary to enable it. The module does not filter or discard valid interface subcommands, so the command is applied as intended.

  • ✗

    It fails because 'parents' cannot be used with 'lines' in ios_config.

    Why it's wrong here

    This is incorrect because 'parents' and 'lines' are complementary parameters of the ios_config module, not mutually exclusive. The 'parents' parameter is specifically designed to specify the parent configuration block (such as an interface or a VRF) under which the commands in 'lines' should be executed. Without 'parents', the module would apply 'lines' in global configuration mode, which would not be valid for interface-specific commands. Therefore, the combination of 'parents' and 'lines' is essential for configuring subcomponents, and this option falsely claims the module would fail.

Visual reference

192.168.1.0 /24 256 addresses (254 usable) 192.168.1.0 /25 Subnet A 128 addr (126 usable) 192.168.1.128 /25 Subnet B 128 addr (126 usable) Borrowing 1 bit from host portion creates 2 subnets (/25)

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.