What ios_l2_interface configures in Ansible
Short answer
A The ios_l2_interface resource sets switchport mode and VLAN, configuring Layer 2 access VLAN and trunk on the interface.
Question
Key Takeaways
The Ansible resource ios_l2_interface is a Layer 2 switchport configurator: it sets switchport mode and VLAN, covering access VLAN assignment and trunk mode with allowed VLANs. Option A wins because routing, QoS and ACL configuration live in separate resources whose command sets ios_l2_interface never emits. Reading the module name's l2 scope against the switchport command vocabulary is what rules out the other three options.
Expert Analysis
ios_l2_interfacesets switchport mode and VLAN.
That single line is the whole discriminator: the resource name itself carries l2, and its body of work is Layer 2 switching configuration — switchport mode access, the access VLAN applied to an interface, and switchport mode trunk with the allowed VLAN list. Option A states exactly this pair of actions ("Configures L2 interface: access VLAN, trunk"), so it matches the resource's documented scope on every count.
Option B, "Configures routing," describes Layer 3 behaviour — an ip address on a routed port, or an SVI carrying an IP — which is precisely what ios_l2_interface does not touch; a switchport in access or trunk mode is not a routed interface, and leaving the resource to set an IP address would fail because the module never emits interface routing or ip address commands. Option C, "Configures QoS," is likewise out of scope: shaping, priority queuing and service-policy output belong to a QoS resource, and nothing in a switchport-mode/VLAN payload intersects with class-maps or policy-maps. Option D, "Configures ACL," names a security control applied to routed traffic; ios_l2_interface produces no access-list or ip access-group statements, so an ACL cannot be configured through it. The three wrong options therefore fail for the same structural reason — each claims a configuration domain that the module's command set simply does not emit.
The mechanism worth carrying away is how resource names encode scope in this automation stack. Modules are generated from the device's YANG models: the ios namespace exposes distinct subtrees for interface switching state, interface routing, QoS and ACL policy, and each Ansible resource binds to one subtree. So the prefix in ios_l2_interface tells you which YANG path the module writes to before you read a single line of it. Worked on this question: ios_l2_interface binds to the switchport/VLAN subtree and therefore configures access VLAN and trunk mode (option A), while a routing resource would bind to the IPv4 address subtree, a QoS resource to the policy subtree, and an ACL resource to the access-list subtree — each of those being options B, C and D respectively.
A second point of precision: switchport mode trunk is not merely "enable trunking." The trunk option also carries the allowed VLAN list and native VLAN, which is why trunking belongs to the same Layer 2 resource rather than being split off. Access VLAN assignment and trunk allowed-VLAN assignment are two faces of the same YANG branch, which is exactly what option A compresses into one statement. An exam candidate who reads l2 and stops there would land on A anyway, but the reasoning above explains why B, C and D are not merely less likely but structurally impossible for this resource: none of them can produce the switchport command set, and none of the switchport commands implements routing, QoS or ACL policy.
In short, the deciding constraint is the resource's command vocabulary. ios_l2_interface emits switchport mode and VLAN commands only, so it configures Layer 2 interfaces — access VLAN and trunk — and cannot configure routing, QoS or ACLs.
Exam Strategy
Use the module name as a scope filter before reading options: an ios_ resource with l2 in it can only emit switchport/VLAN commands, so any option claiming routing, QoS or ACL work is structurally impossible. Cross-check by listing the commands the option would require (ip address, service-policy, access-list) and confirming none appear in the resource's YANG subtree. This name-to-subtree trick transfers to any Ansible network module question.
Related Analysis
Practice All 300-435 Questions
Access 150 questions with complete answers and detailed explanations.
View Full 300-435 Practice Test →