nerdexam
Cisco

200-901 · Question #534

A developer must add an idempotent task to an Ansible playbook that configures a Cisco IOS device. HTTP traffic must be permitted from 192.168.1.1 to 192.168.1.5 host machine. Which code snippet…

The correct answer is C. - ios_config: lines: access-list 120 permit tcp host 192.168.1.1 host 192.168.1.5 eq 80. To idempotently configure a Cisco IOS device using Ansible, the ios_config module should be used with the specific access-list line allowing HTTP traffic on port 80.

Infrastructure and Automation

Question

A developer must add an idempotent task to an Ansible playbook that configures a Cisco IOS device. HTTP traffic must be permitted from 192.168.1.1 to 192.168.1.5 host machine. Which code snippet must be used? A. B. C. D.

Exhibit

200-901 question #534 exhibit

Options

  • A
    • ios_command: commands: - configure terminal - access-list 120 permit tcp host 192.168.1.1 host 192.168.1.5 any eq www
  • B
    • ios_config: lines: access-list 120 permit tcp host 192.168.1.1 host 192.168.1.5 any eq www
  • C
    • ios_config: lines: access-list 120 permit tcp host 192.168.1.1 host 192.168.1.5 eq 80
  • D
    • ios_command: mode: configure terminal args: access-list 120 permit tcp host 192.168.1.1 host 192.168.1.5 any eq 80

How the community answered

(21 responses)
  • A
    10% (2)
  • B
    5% (1)
  • C
    81% (17)
  • D
    5% (1)

Why each option

To idempotently configure a Cisco IOS device using Ansible, the `ios_config` module should be used with the specific access-list line allowing HTTP traffic on port 80.

A- ios_command: commands: - configure terminal - access-list 120 permit tcp host 192.168.1.1 host 192.168.1.5 any eq www

The `ios_command` module executes commands without checking the current state, making it non-idempotent and unsuitable for declarative configuration tasks where idempotence is desired.

B- ios_config: lines: access-list 120 permit tcp host 192.168.1.1 host 192.168.1.5 any eq www

While using `ios_config`, the syntax `eq www` is an alias for port 80, but using `eq 80` is more explicit and generally preferred. Both B and C are very close, but `eq 80` is typically seen as more direct.

C- ios_config: lines: access-list 120 permit tcp host 192.168.1.1 host 192.168.1.5 eq 80Correct

The `ios_config` module is designed for idempotent configuration management on Cisco IOS devices, ensuring changes are applied only if the desired state is not met. The `lines` argument correctly specifies the access-list entry to permit TCP traffic from 192.168.1.1 to 192.168.1.5 on port 80 (HTTP).

D- ios_command: mode: configure terminal args: access-list 120 permit tcp host 192.168.1.1 host 192.168.1.5 any eq 80

The `ios_command` module is not idempotent, and the `args` parameter is used for passing arguments to a command, not for defining configuration lines directly in the way `ios_config` expects.

Concept tested: Ansible ios_config idempotence

Source: https://docs.ansible.com/ansible/latest/collections/cisco/ios/ios_config_module.html

Topics

#Ansible#Network Automation#Cisco IOS Configuration#Access Control Lists

Community Discussion

No community discussion yet for this question.

Full 200-901 Practice