summaryrefslogtreecommitdiffstats
path: root/ansible_collections/cisco/ios/tests/integration/targets
diff options
context:
space:
mode:
Diffstat (limited to 'ansible_collections/cisco/ios/tests/integration/targets')
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/defaults/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tasks/cli.yaml21
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tasks/main.yaml5
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/_parsed.cfg8
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/_populate_config.yaml28
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/_remove_config.yaml8
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/deleted.yaml34
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/empty_config.yaml58
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/gathered.yaml20
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/merged.yaml55
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/overridden.yaml38
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/parsed.yaml15
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/rendered.yaml43
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/replaced.yaml38
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/rtt.yaml80
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/vars/main.yaml93
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_acls/defaults/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_acls/meta/main.yaml2
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tasks/cli.yaml21
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tasks/main.yaml5
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/_parsed.cfg10
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/_populate_config.yaml10
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/_remove_config.yaml8
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/deleted.yaml88
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/empty_config.yaml58
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/gathered.yaml21
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/merged.yaml159
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/overridden.yaml93
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/parsed.yaml15
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/rendered.yaml57
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/replaced.yaml91
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/rtt.yaml201
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_acls/vars/main.yaml286
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_banner/defaults/main.yaml2
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_banner/meta/main.yml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_banner/tasks/cli.yaml18
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_banner/tasks/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_banner/tests/cli/basic-login.yaml73
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_banner/tests/cli/basic-motd.yaml32
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_banner/tests/cli/basic-no-login.yaml31
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_banner/tests/cli/multiple-login-exec.yaml39
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_bgp/defaults/main.yaml2
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_bgp/meta/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_bgp/tasks/cli.yaml17
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_bgp/tasks/main.yaml5
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_bgp/tests/cli/basic.yaml490
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/defaults/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/meta/main.yaml2
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tasks/cli.yaml21
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tasks/main.yaml5
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/_initial_vrf_setup.yaml13
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/_ospf_proc_setup.yaml8
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/_parsed.cfg15
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/_populate_config.yaml120
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/_remove_config.yaml23
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/deleted.yaml56
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/empty_config.yaml58
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/gathered.yaml20
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/merged.yaml110
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/overridden.yaml94
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/parsed.yaml14
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/rendered.yaml81
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/replaced.yaml118
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/vars/main.yaml314
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/defaults/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/meta/main.yaml2
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tasks/cli.yaml21
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tasks/main.yaml5
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/_parsed.cfg13
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/_populate_config.yaml44
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/_remove_config.yaml4
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/deleted.yaml35
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/empty_config.yaml47
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/gathered.yaml22
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/merged.yaml79
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/parsed.yaml14
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/purged.yaml29
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/rendered.yaml54
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/replaced.yaml54
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/rtt.yaml65
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/vars/main.yaml220
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_cliconf/defaults/main.yml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_cliconf/meta/main.yml0
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_cliconf/tasks/cli.yaml22
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_cliconf/tasks/main.yaml5
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_cliconf/tests/common/_cleanup.yaml12
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_cliconf/tests/common/_enable_archiving.yaml7
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_cliconf/tests/common/_test_config.yaml7
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_cliconf/tests/common/commit_conf.yaml130
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_cliconf/vars/main.yaml21
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_command/defaults/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_command/meta/main.yml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_command/tasks/cli.yaml18
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_command/tasks/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_command/tests/cli/bad_operator.yaml19
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_command/tests/cli/cli_command.yaml28
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_command/tests/cli/contains.yaml19
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_command/tests/cli/error_regex.yaml65
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_command/tests/cli/invalid.yaml26
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_command/tests/cli/output.yaml28
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_command/tests/cli/timeout.yaml18
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_config/defaults/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_config/meta/main.yml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_config/tasks/cli.yaml19
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_config/tasks/cli_config.yaml19
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_config/tasks/main.yaml14
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_config/tasks/redirection.yaml19
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/base_running_config9
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/config.j23
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/configblock.j25
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/configexact1.j26
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/configexact2.j25
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/configstrict1.j25
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/intended_running_config8
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/macro.j28
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/setupblock.j25
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/setupexact.j27
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/setupstrict.j27
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/defaults/config.j23
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/backup.yaml68
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/defaults.yaml67
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/diff.yaml33
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/macro.yaml62
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/save.yaml49
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/src_basic.yaml62
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/src_invalid.yaml16
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/src_match_none.yaml33
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/sublevel.yaml43
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/sublevel_block.yaml65
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/sublevel_exact.yaml61
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/sublevel_strict.yaml57
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/sublevel_strict_mul_parents.yaml72
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/toplevel.yaml37
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/toplevel_after.yaml44
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/toplevel_before.yaml44
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/toplevel_nonidempotent.yaml39
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli_config/cli_backup.yaml59
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli_config/cli_basic.yaml39
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli_config/cli_block_replace.yaml32
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli_config/cli_exact_match.yaml33
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli_config/cli_strict_match.yaml24
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/redirection/shortname.yaml27
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_facts/defaults/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_facts/meta/main.yml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_facts/tasks/cli.yaml18
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_facts/tasks/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_facts/tests/cli/all_facts.yaml63
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_facts/tests/cli/default_facts.yaml21
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_facts/tests/cli/invalid_subset.yaml32
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_facts/tests/cli/not_hardware.yaml21
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/defaults/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/meta/main.yaml2
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tasks/cli.yaml21
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tasks/main.yaml5
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tests/cli/_parsed.cfg1
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tests/cli/_populate_config.yaml6
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tests/cli/_remove_config.yaml5
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tests/cli/deleted.yaml27
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tests/cli/empty_config.yaml58
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tests/cli/gathered.yaml20
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tests/cli/merged.yaml35
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tests/cli/parsed.yaml14
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tests/cli/rendered.yaml16
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/vars/main.yaml24
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/defaults/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/meta/main.yaml2
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tasks/cli.yaml21
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tasks/main.yaml5
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/_parsed.cfg11
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/_populate_config.yaml8
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/_remove_config.yaml18
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/deleted.yaml33
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/empty_config.yaml58
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/gathered.yaml21
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/merged.yaml44
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/overridden.yaml57
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/parsed.yaml15
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/rendered.yaml25
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/replaced.yaml43
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/vars/main.yaml215
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/defaults/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/meta/main.yaml2
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tasks/cli.yaml25
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tasks/main.yaml5
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/_parsed.cfg8
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/_populate_config.yaml9
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/_remove_config.yaml11
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/_remove_vlan_config.yaml5
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/deleted.yaml41
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/empty_config.yaml58
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/gathered.yaml23
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/merged.yaml87
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/overridden.yaml47
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/parsed.yaml16
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/rendered.yaml26
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/replaced.yaml52
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/rtt.yaml64
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/vars/main.yaml213
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/defaults/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/meta/main.yaml2
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tasks/cli.yaml21
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tasks/main.yaml5
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/_parsed.cfg7
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/_populate_config.yaml8
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/_remove_config.yaml8
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/deleted.yaml41
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/empty_config.yaml58
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/gathered.yaml20
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/merged.yaml51
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/overridden.yaml50
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/parsed.yaml15
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/rendered.yaml36
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/replaced.yaml51
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/rtt.yaml60
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/vars/main.yaml239
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/aliases1
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/defaults/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/meta/main.yaml2
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tasks/cli.yaml25
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tasks/main.yaml5
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tests/cli/_parsed.cfg1
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tests/cli/_populate_config.yaml7
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tests/cli/_remove_config.yaml7
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tests/cli/deleted.yaml39
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tests/cli/empty_config.yaml49
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tests/cli/gathered.yaml21
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tests/cli/merged.yaml40
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tests/cli/parsed.yaml17
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tests/cli/rendered.yaml19
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tests/cli/replaced.yaml42
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/vars/main.yaml38
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/defaults/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tasks/cli.yaml25
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tasks/main.yaml5
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/_add_port_channels.yml7
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/_parsed.cfg7
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/_populate_config.yaml9
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/_remove_config.yaml19
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/deleted.yaml39
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/empty_config.yaml60
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/gathered.yaml21
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/merged.yaml47
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/overridden.yaml45
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/parsed.yaml17
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/rendered.yaml24
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/replaced.yaml45
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/rtt.yaml57
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/vars/main.yaml181
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/defaults/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/meta/main.yaml2
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tasks/cli.yaml25
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tasks/main.yaml5
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/_add_port_channels.yml7
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/_parsed.cfg4
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/_populate_config.yaml9
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/_populate_port_channel.yaml7
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/_remove_config.yaml7
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/deleted.yaml34
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/empty_config.yaml61
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/gathered.yaml23
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/merged.yaml42
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/overridden.yaml38
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/parsed.yaml17
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/rendered.yaml25
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/replaced.yaml38
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/rtt.yaml60
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/vars/main.yaml147
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_linkagg/defaults/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_linkagg/meta/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_linkagg/tasks/cli.yaml18
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_linkagg/tasks/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_linkagg/tests/cli/basic.yaml157
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lldp/defaults/main.yaml2
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lldp/meta/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lldp/tasks/cli.yaml18
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lldp/tasks/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lldp/tests/cli/basic.yaml46
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/aliases1
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/defaults/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/meta/main.yaml2
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tasks/cli.yaml21
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tasks/main.yaml5
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tests/cli/_parsed.cfg4
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tests/cli/_populate_config.yaml6
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tests/cli/_remove_config.yaml6
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tests/cli/deleted.yaml38
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tests/cli/empty_config.yaml47
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tests/cli/gathered.yaml19
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tests/cli/merged.yaml41
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tests/cli/parsed.yaml15
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tests/cli/rendered.yaml20
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tests/cli/replaced.yaml41
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/vars/main.yaml51
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/defaults/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tasks/cli.yaml21
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tasks/main.yaml5
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/_enable_lldp.yaml6
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/_parsed.cfg17
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/_populate_config.yaml8
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/_remove_config.yaml8
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/deleted.yaml40
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/empty_config.yaml58
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/gathered.yaml22
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/merged.yaml48
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/overridden.yaml47
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/parsed.yaml15
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/rendered.yaml24
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/replaced.yaml47
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/rtt.yaml62
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/vars/main.yaml188
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_logging/defaults/main.yaml2
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_logging/meta/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_logging/tasks/cli.yaml18
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_logging/tasks/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_logging/tests/cli/basic.yaml134
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/defaults/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/meta/main.yaml2
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tasks/cli.yaml21
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tasks/main.yaml5
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/_parsed.cfg1
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/_populate_config.yaml36
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/_remove_config.yaml4
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/deleted.yaml20
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/empty_config.yaml58
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/gathered.yaml20
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/merged.yaml61
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/overridden.yaml49
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/parsed.yaml14
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/rendered.yaml75
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/replaced.yaml48
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/vars/main.yaml171
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ntp/defaults/main.yaml2
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ntp/meta/main.yml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ntp/tasks/cli.yaml18
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ntp/tasks/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ntp/tests/cli/ntp_configuration.yaml87
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/defaults/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/meta/main.yaml2
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tasks/cli.yaml21
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tasks/main.yaml5
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/_parsed.cfg10
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/_populate_config.yaml17
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/_remove_config.yaml5
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/deleted.yaml34
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/empty_config.yaml58
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/gathered.yaml20
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/merged.yaml37
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/overridden.yaml44
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/parsed.yaml14
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/rendered.yaml28
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/rtt.yaml46
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/vars/main.yaml120
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/defaults/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/meta/main.yaml2
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tasks/cli.yaml21
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tasks/main.yaml5
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/_initial_ipv6_setup.yaml6
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/_parsed.cfg22
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/_populate_config.yaml33
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/_remove_config.yaml20
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/deleted.yaml51
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/empty_config.yaml58
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/gathered.yaml23
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/merged.yaml69
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/overridden.yaml58
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/parsed.yaml14
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/rendered.yaml46
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/replaced.yaml45
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/rtt.yaml96
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/vars/main.yaml327
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/defaults/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/meta/main.yaml2
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tasks/cli.yaml21
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tasks/main.yaml5
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/_initial_vrf_setup.yaml6
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/_parsed.cfg19
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/_populate_config.yaml55
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/_remove_config.yaml10
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/deleted.yaml74
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/empty_config.yaml58
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/gathered.yaml23
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/merged.yaml88
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/overridden.yaml72
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/parsed.yaml14
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/rendered.yaml65
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/replaced.yaml72
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/rtt.yaml130
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/vars/main.yaml250
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/defaults/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/meta/main.yaml2
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tasks/cli.yaml21
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tasks/main.yaml5
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/_initial_vrf_setup.yaml11
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/_parsed.cfg15
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/_populate_config.yaml42
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/_remove_config.yaml16
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/deleted.yaml62
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/empty_config.yaml59
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/gathered.yaml22
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/merged.yaml70
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/overridden.yaml52
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/parsed.yaml15
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/rendered.yaml52
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/replaced.yaml52
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/rtt.yaml113
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/vars/main.yaml104
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ping/defaults/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ping/meta/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ping/tasks/cli.yaml18
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ping/tasks/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_ping/tests/cli/ping.yaml51
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/defaults/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/meta/main.yaml2
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tasks/cli.yaml21
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tasks/main.yaml5
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/_parsed.cfg12
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/_populate_config.yaml55
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/_remove_config.yaml4
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/deleted.yaml78
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/empty_config.yaml58
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/gathered.yaml21
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/merged.yaml86
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/overridden.yaml64
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/parsed.yaml14
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/rendered.yaml65
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/replaced.yaml68
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/vars/main.yaml247
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/defaults/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/meta/main.yaml2
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tasks/cli.yaml21
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tasks/main.yaml5
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/_parsed.cfg34
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/_populate_config.yaml107
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/_remove_config.yaml4
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/deleted.yaml50
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/empty_config.yaml58
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/gathered.yaml21
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/merged.yaml141
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/overridden.yaml138
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/parsed.yaml14
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/rendered.yaml117
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/replaced.yaml134
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/vars/main.yaml592
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_smoke/defaults/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_smoke/meta/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_smoke/tasks/cli.yaml18
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_smoke/tasks/main.yaml5
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_smoke/templates/defaults/config.j23
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_smoke/tests/cli/caching.yaml92
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_smoke/tests/cli/common_config.yaml207
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_smoke/tests/cli/misc_tests.yaml42
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/defaults/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/meta/main.yaml2
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tasks/cli.yaml21
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tasks/main.yaml5
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tests/cli/_parsed.cfg1
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tests/cli/_populate_config.yaml22
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tests/cli/_remove_config.yaml5
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tests/cli/deleted.yaml34
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tests/cli/empty_config.yaml58
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tests/cli/gathered.yaml20
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tests/cli/merged.yaml41
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tests/cli/overridden.yaml45
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tests/cli/parsed.yaml14
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tests/cli/rendered.yaml32
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/vars/main.yaml132
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/defaults/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/meta/main.yaml2
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tasks/cli.yaml21
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tasks/main.yaml5
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/_add_extra_ipv6_data.yaml6
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/_initial_setup_config.yaml9
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/_populate_config.yaml9
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/_remove_config.yaml9
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/_remove_extra_ipv6_data.yaml6
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/deleted.yaml72
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/empty_config.yaml58
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/gathered.yaml21
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/merged.yaml82
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/overridden.yaml65
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/rendered.yaml63
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/replaced.yaml67
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/rtt.yaml79
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/vars/main.yaml89
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_system/defaults/main.yaml2
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_system/meta/main.yml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_system/tasks/cli.yaml18
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_system/tasks/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_system/tests/cli/set_domain_list.yaml111
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_system/tests/cli/set_domain_name.yaml32
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_system/tests/cli/set_hostname.yaml32
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_system/tests/cli/set_lookup_source.yaml58
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_system/tests/cli/set_name_servers.yaml57
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_user/defaults/main.yaml2
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_user/files/test_rsa27
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_user/files/test_rsa.pub1
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_user/meta/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_user/tasks/cli.yaml18
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_user/tasks/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_user/tests/cli/auth.yaml100
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_user/tests/cli/basic.yaml145
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/defaults/main.yaml3
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/meta/main.yaml2
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tasks/cli.yaml25
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tasks/main.yaml5
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/_parsed.cfg21
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/_populate_config.yaml7
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/_remove_config.yaml7
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/deleted.yaml40
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/empty_config.yaml60
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/gathered.yaml23
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/merged.yaml62
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/overridden.yaml48
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/parsed.yaml17
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/rendered.yaml31
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/replaced.yaml53
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/rtt.yaml72
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/vars/main.yaml470
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/prepare_ios_tests/meta/main.yaml2
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/prepare_ios_tests/tasks/main.yml63
-rw-r--r--ansible_collections/cisco/ios/tests/integration/targets/prepare_ios_tests/templates/config.j23
521 files changed, 20188 insertions, 0 deletions
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/defaults/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/defaults/main.yaml
new file mode 100644
index 000000000..164afead2
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tasks/cli.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tasks/cli.yaml
new file mode 100644
index 000000000..6f505600c
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tasks/cli.yaml
@@ -0,0 +1,21 @@
+---
+- name: Collect all CLI test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+ delegate_to: localhost
+
+- name: Run test case (connection=ansible.netcommon.network_cli)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.network_cli
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tasks/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tasks/main.yaml
new file mode 100644
index 000000000..05a1b220c
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tasks/main.yaml
@@ -0,0 +1,5 @@
+---
+- name: Main task for acl_interface
+ ansible.builtin.include_tasks: cli.yaml
+ tags:
+ - network_cli
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/_parsed.cfg b/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/_parsed.cfg
new file mode 100644
index 000000000..199d2f69a
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/_parsed.cfg
@@ -0,0 +1,8 @@
+interface GigabitEthernet2
+ ip access-group 110 in
+ ip access-group 123 out
+ ipv6 traffic-filter temp_v6 in
+ ipv6 traffic-filter test_v6 out
+interface GigabitEthernet3
+ ip access-group 110 in
+ ip access-group 123 out
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/_populate_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/_populate_config.yaml
new file mode 100644
index 000000000..ee5bcf1ea
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/_populate_config.yaml
@@ -0,0 +1,28 @@
+---
+- name: Merge the provided configuration with the existing running configuration
+ register: result
+ cisco.ios.ios_acl_interfaces:
+ config:
+ - access_groups:
+ - acls:
+ - direction: in
+ name: 110
+ - direction: out
+ name: 123
+ afi: ipv4
+ - acls:
+ - direction: in
+ name: temp_v6
+ - direction: out
+ name: test_v6
+ afi: ipv6
+ name: GigabitEthernet2
+ - access_groups:
+ - acls:
+ - direction: in
+ name: 110
+ - direction: out
+ name: 123
+ afi: ipv4
+ name: GigabitEthernet3
+ state: merged
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/_remove_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/_remove_config.yaml
new file mode 100644
index 000000000..0f23a20d9
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/_remove_config.yaml
@@ -0,0 +1,8 @@
+---
+- name: Remove configuration
+ vars:
+ lines:
+ "interface GigabitEthernet 2\nno ip access-group 110 in\nno ip access-group 100 out\nno ip access-group 123 out\nno ipv6 traffic-filter temp_v6 in\n\
+ no ipv6 traffic-filter test_v6 out\ninterface GigabitEthernet 3\nno ip access-group 110 in\nno ip access-group 123 out\n"
+ ansible.netcommon.cli_config:
+ config: "{{ lines }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/deleted.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/deleted.yaml
new file mode 100644
index 000000000..24a79db49
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/deleted.yaml
@@ -0,0 +1,34 @@
+---
+- ansible.builtin.debug:
+ msg: Start ios_acl_interfaces deleted integration tests ansible_connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Delete module attributes of given interface.
+ register: result
+ cisco.ios.ios_acl_interfaces:
+ config:
+ - name: GigabitEthernet2
+ state: deleted
+
+ - ansible.builtin.assert:
+ that:
+ - result.commands|length == 5
+ - result.changed == true
+ - result.commands|symmetric_difference(deleted.commands) == []
+
+ - name: Delete module attributes of given interface (idempotent)
+ register: result
+ cisco.ios.ios_acl_interfaces:
+ config:
+ - name: GigabitEthernet2
+ state: deleted
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/empty_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/empty_config.yaml
new file mode 100644
index 000000000..3ae0577c0
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/empty_config.yaml
@@ -0,0 +1,58 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_acl_interfaces empty_config.yaml integration tests on connection={{ ansible_connection }}
+
+- name: Merged with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_acl_interfaces:
+ config:
+ state: merged
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state merged'
+
+- name: Replaced with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_acl_interfaces:
+ config:
+ state: replaced
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state replaced'
+
+- name: Overridden with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_acl_interfaces:
+ config:
+ state: overridden
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state overridden'
+
+- name: Rendered with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_acl_interfaces:
+ config:
+ state: rendered
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state rendered'
+
+- name: Parsed with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_acl_interfaces:
+ running_config:
+ state: parsed
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of running_config parameter must not be empty for state parsed'
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/gathered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/gathered.yaml
new file mode 100644
index 000000000..ce732370d
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/gathered.yaml
@@ -0,0 +1,20 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_acl_interfaces gathered integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Gather the provided configuration with the existing running configuration
+ register: result
+ cisco.ios.ios_acl_interfaces:
+ config:
+ state: gathered
+
+ - name: Assert
+ ansible.builtin.assert:
+ that:
+ - gathered['config'] | symmetric_difference(result.gathered) == []
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/merged.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/merged.yaml
new file mode 100644
index 000000000..7fe96b6ef
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/merged.yaml
@@ -0,0 +1,55 @@
+---
+- ansible.builtin.debug:
+ msg: Start ios_acl_interfaces merged integration tests ansible_connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- block:
+ - name: Merge the provided configuration with the existing running configuration
+ register: result
+ cisco.ios.ios_acl_interfaces: &id001
+ config:
+ - name: GigabitEthernet2
+ access_groups:
+ - afi: ipv4
+ acls:
+ - name: 110
+ direction: in
+
+ - name: 123
+ direction: out
+
+ - afi: ipv6
+ acls:
+ - name: temp_v6
+ direction: in
+
+ - name: test_v6
+ direction: out
+
+ - name: GigabitEthernet3
+ access_groups:
+ - afi: ipv4
+ acls:
+ - name: 110
+ direction: in
+
+ - name: 123
+ direction: out
+ state: merged
+
+ - ansible.builtin.assert:
+ that:
+ - result.commands|length == 8
+ - result.changed == true
+ - result.commands|symmetric_difference(merged.commands) == []
+
+ - name: Merge the provided configuration with the existing running configuration (idempotent)
+ register: result
+ cisco.ios.ios_acl_interfaces: *id001
+ - ansible.builtin.assert:
+ that:
+ - result.commands|length == 0
+ - result.changed == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/overridden.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/overridden.yaml
new file mode 100644
index 000000000..1c7eff858
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/overridden.yaml
@@ -0,0 +1,38 @@
+---
+- ansible.builtin.debug:
+ msg: Start ios_acl_interfaces overridden integration tests ansible_connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Override device configuration of all acl_interfaces with provided configuration
+ become: true
+ register: result
+ cisco.ios.ios_acl_interfaces: &id001
+ config:
+ - name: GigabitEthernet2
+ access_groups:
+ - afi: ipv4
+ acls:
+ - name: 100
+ direction: out
+
+ - name: 110
+ direction: in
+ state: overridden
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - result.commands|symmetric_difference(overridden.commands) == []
+
+ - name: Override device configuration of all acl_interfaces with provided configuration (idempotent)
+ become: true
+ register: result
+ cisco.ios.ios_acl_interfaces: *id001
+ - ansible.builtin.assert:
+ that:
+ - result.commands|length == 0
+ - result.changed == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/parsed.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/parsed.yaml
new file mode 100644
index 000000000..e3a88361c
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/parsed.yaml
@@ -0,0 +1,15 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_acl_interfaces parsed integration tests on connection={{ ansible_connection }}
+
+- name: Parse the commands for provided configuration
+ become: true
+ register: result
+ cisco.ios.ios_acl_interfaces:
+ running_config: "{{ lookup('file', '_parsed.cfg') }}"
+ state: parsed
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - parsed['config']|symmetric_difference(result.parsed) == []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/rendered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/rendered.yaml
new file mode 100644
index 000000000..4a4ec83b4
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/rendered.yaml
@@ -0,0 +1,43 @@
+---
+- ansible.builtin.debug:
+ msg: Start ios_acl_interfaces rendered integration tests ansible_connection={{ ansible_connection }}
+
+- block:
+ - name: Render the commands for provided configuration
+ become: true
+ register: result
+ cisco.ios.ios_acl_interfaces:
+ config:
+ - name: GigabitEthernet2
+ access_groups:
+ - afi: ipv4
+ acls:
+ - name: 110
+ direction: in
+
+ - name: 123
+ direction: out
+
+ - afi: ipv6
+ acls:
+ - name: test_v6
+ direction: out
+
+ - name: temp_v6
+ direction: in
+
+ - name: GigabitEthernet3
+ access_groups:
+ - afi: ipv4
+ acls:
+ - name: 110
+ direction: in
+
+ - name: 123
+ direction: out
+ state: rendered
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - result.rendered|symmetric_difference(merged.commands) == []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/replaced.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/replaced.yaml
new file mode 100644
index 000000000..391f68436
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/replaced.yaml
@@ -0,0 +1,38 @@
+---
+- ansible.builtin.debug:
+ msg: Start ios_acl_interfaces replced integration tests ansible_connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Replaces device configuration of listed acl_interfaces with provided configuration
+ become: true
+ register: result
+ cisco.ios.ios_acl_interfaces: &id001
+ config:
+ - name: GigabitEthernet2
+ access_groups:
+ - afi: ipv4
+ acls:
+ - name: 100
+ direction: out
+
+ - name: 110
+ direction: in
+ state: replaced
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - result.commands|symmetric_difference(replaced.commands) == []
+
+ - name: Replaces device configuration of listed acl_interfaces with provided configuration (idempotent)
+ become: true
+ register: result
+ cisco.ios.ios_acl_interfaces: *id001
+ - ansible.builtin.assert:
+ that:
+ - result.commands|length == 0
+ - result.changed == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/rtt.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/rtt.yaml
new file mode 100644
index 000000000..7e3e6205a
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/tests/cli/rtt.yaml
@@ -0,0 +1,80 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_acl_interfaces round trip integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- block:
+ - name: Apply the provided configuration (base config)
+ register: base_config
+ cisco.ios.ios_acl_interfaces:
+ config:
+ - name: GigabitEthernet2
+ access_groups:
+ - afi: ipv4
+ acls:
+ - name: 110
+ direction: in
+
+ - name: 123
+ direction: out
+
+ - afi: ipv6
+ acls:
+ - name: temp_v6
+ direction: in
+
+ - name: test_v6
+ direction: out
+
+ - name: GigabitEthernet3
+ access_groups:
+ - afi: ipv4
+ acls:
+ - name: 110
+ direction: in
+
+ - name: 123
+ direction: out
+ state: merged
+
+ - name: Gather ACL interfaces facts
+ cisco.ios.ios_facts:
+ gather_subset:
+ - "!all"
+ - "!min"
+ gather_network_resources:
+ - acl_interfaces
+
+ - name: Apply the provided configuration (config to be reverted)
+ register: result
+ cisco.ios.ios_acl_interfaces:
+ config:
+ - name: GigabitEthernet2
+ access_groups:
+ - afi: ipv4
+ acls:
+ - name: 100
+ direction: out
+
+ - name: 110
+ direction: in
+ state: overridden
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - result.commands|symmetric_difference(overridden.commands) == []
+
+ - name: Revert back to base configuration using facts round trip
+ register: revert
+ cisco.ios.ios_acl_interfaces:
+ config: "{{ ansible_facts['network_resources']['acl_interfaces'] }}"
+ state: overridden
+
+ - ansible.builtin.assert:
+ that:
+ - revert.changed == true
+ - revert.commands|symmetric_difference(rtt.commands) == []
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/vars/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/vars/main.yaml
new file mode 100644
index 000000000..7b9e3b417
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_acl_interfaces/vars/main.yaml
@@ -0,0 +1,93 @@
+---
+interfaces:
+ int1: GigabitEthernet2
+ int2: GigabitEthernet3
+merged:
+ commands:
+ - interface GigabitEthernet2
+ - ip access-group 110 in
+ - ip access-group 123 out
+ - ipv6 traffic-filter temp_v6 in
+ - ipv6 traffic-filter test_v6 out
+ - interface GigabitEthernet3
+ - ip access-group 110 in
+ - ip access-group 123 out
+replaced:
+ commands:
+ - interface GigabitEthernet2
+ - no ipv6 traffic-filter temp_v6 in
+ - no ipv6 traffic-filter test_v6 out
+ - ip access-group 100 out
+overridden:
+ commands:
+ - interface GigabitEthernet2
+ - no ipv6 traffic-filter test_v6 out
+ - no ipv6 traffic-filter temp_v6 in
+ - ip access-group 100 out
+ - interface GigabitEthernet3
+ - no ip access-group 110 in
+ - no ip access-group 123 out
+deleted:
+ commands:
+ - interface GigabitEthernet2
+ - no ip access-group 110 in
+ - no ip access-group 123 out
+ - no ipv6 traffic-filter temp_v6 in
+ - no ipv6 traffic-filter test_v6 out
+gathered:
+ config:
+ - access_groups:
+ - acls:
+ - direction: in
+ name: 110
+ - direction: out
+ name: 123
+ afi: ipv4
+ - acls:
+ - direction: in
+ name: temp_v6
+ - direction: out
+ name: test_v6
+ afi: ipv6
+ name: GigabitEthernet2
+ - access_groups:
+ - acls:
+ - direction: in
+ name: 110
+ - direction: out
+ name: 123
+ afi: ipv4
+ name: GigabitEthernet3
+parsed:
+ config:
+ - access_groups:
+ - acls:
+ - direction: in
+ name: 110
+ - direction: out
+ name: 123
+ afi: ipv4
+ - acls:
+ - direction: in
+ name: temp_v6
+ - direction: out
+ name: test_v6
+ afi: ipv6
+ name: GigabitEthernet2
+ - access_groups:
+ - acls:
+ - direction: in
+ name: 110
+ - direction: out
+ name: 123
+ afi: ipv4
+ name: GigabitEthernet3
+rtt:
+ commands:
+ - interface GigabitEthernet2
+ - ip access-group 123 out
+ - ipv6 traffic-filter temp_v6 in
+ - ipv6 traffic-filter test_v6 out
+ - interface GigabitEthernet3
+ - ip access-group 110 in
+ - ip access-group 123 out
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/defaults/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/defaults/main.yaml
new file mode 100644
index 000000000..164afead2
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/meta/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/meta/main.yaml
new file mode 100644
index 000000000..23d65c7ef
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/meta/main.yaml
@@ -0,0 +1,2 @@
+---
+dependencies: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tasks/cli.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tasks/cli.yaml
new file mode 100644
index 000000000..6f505600c
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tasks/cli.yaml
@@ -0,0 +1,21 @@
+---
+- name: Collect all CLI test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+ delegate_to: localhost
+
+- name: Run test case (connection=ansible.netcommon.network_cli)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.network_cli
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tasks/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tasks/main.yaml
new file mode 100644
index 000000000..a38b1212b
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tasks/main.yaml
@@ -0,0 +1,5 @@
+---
+- name: Main task for acls
+ ansible.builtin.include_tasks: cli.yaml
+ tags:
+ - network_cli
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/_parsed.cfg b/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/_parsed.cfg
new file mode 100644
index 000000000..166af7ee7
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/_parsed.cfg
@@ -0,0 +1,10 @@
+Extended IP access list 110
+ 10 deny icmp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 echo dscp ef ttl eq 10
+Extended IP access list 123
+ 10 deny tcp 198.51.100.0 0.0.0.255 198.51.101.0 0.0.0.255 eq telnet ack tos 12
+ 20 deny tcp 192.0.3.0 0.0.0.255 192.0.4.0 0.0.0.255 eq www ack dscp ef ttl lt 20
+Extended IP access list test_acl
+ 10 deny tcp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 eq www fin option traceroute ttl eq 10
+IPv6 access list R1_TRAFFIC
+ deny tcp any eq www any eq telnet ack dscp af11 sequence 10
+access-list 110 remark test a remark.
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/_populate_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/_populate_config.yaml
new file mode 100644
index 000000000..7fd5aa1e3
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/_populate_config.yaml
@@ -0,0 +1,10 @@
+---
+- name: Populate configuration
+ vars:
+ lines:
+ "ip access-list extended test_acl\ndeny tcp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 eq www fin option traceroute ttl eq 10\nip access-list extended 110\n\
+ deny icmp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 echo dscp ef ttl eq 10\nip access-list extended 123\ndeny tcp 198.51.100.0 0.0.0.255 198.51.101.0 0.0.0.255\
+ \ eq telnet ack tos 12\ndeny tcp 192.0.3.0 0.0.0.255 192.0.4.0 0.0.0.255 eq www ack dscp ef ttl lt 20\nipv6 access-list R1_TRAFFIC\ndeny tcp any eq www any\
+ \ eq telnet ack dscp af11\n"
+ ansible.netcommon.cli_config:
+ config: "{{ lines }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/_remove_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/_remove_config.yaml
new file mode 100644
index 000000000..9f2c40a68
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/_remove_config.yaml
@@ -0,0 +1,8 @@
+---
+- name: Delete ACL attributes based on AFI
+ register: result
+ cisco.ios.ios_acls: &id002
+ config:
+ - afi: ipv4
+ - afi: ipv6
+ state: deleted
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/deleted.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/deleted.yaml
new file mode 100644
index 000000000..2f0a249a9
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/deleted.yaml
@@ -0,0 +1,88 @@
+---
+- ansible.builtin.debug:
+ msg: Start Deleted integration state for ios_acls ansible_connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Delete attributes of provided configured acls
+ register: result
+ cisco.ios.ios_acls: &id001
+ config:
+ - afi: ipv4
+ acls:
+ - name: test_acl
+ - name: 110
+ - afi: ipv6
+ acls:
+ - name: R1_TRAFFIC
+ state: deleted
+
+ - ansible.builtin.assert:
+ that:
+ - result.commands|length == 3
+ - result.changed == true
+ - result.commands|symmetric_difference(deleted.commands) == []
+
+ - name: Delete configured acls (idempotent)
+ register: result
+ cisco.ios.ios_acls: *id001
+ - name: Assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result.commands|length == 0
+ - result.changed == false
+
+ - ansible.builtin.include_tasks: _remove_config.yaml
+
+ - ansible.builtin.include_tasks: _populate_config.yaml
+
+ - name: Delete ACL attributes based on AFI
+ register: result
+ cisco.ios.ios_acls: &id002
+ config:
+ - afi: ipv4
+ state: deleted
+
+ - ansible.builtin.assert:
+ that:
+ - result.commands|length == 3
+ - result.changed == true
+ - result.commands|symmetric_difference(deleted_afi.commands) == []
+
+ - name: Delete ACL attributes based on AFI (idempotent)
+ register: result
+ cisco.ios.ios_acls: *id002
+ - name: Assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result.commands|length == 0
+ - result.changed == false
+
+ - ansible.builtin.include_tasks: _remove_config.yaml
+
+ - ansible.builtin.include_tasks: _populate_config.yaml
+
+ - name: Delete all configured acls
+ register: result
+ cisco.ios.ios_acls: &id003
+ state: deleted
+
+ - ansible.builtin.assert:
+ that:
+ - result.commands|length == 4
+ - result.changed == true
+ - result.commands|symmetric_difference(deleted_all.commands) == []
+
+ - name: Delete all configured acls (idempotent)
+ register: result
+ cisco.ios.ios_acls: *id003
+ - name: Assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result.commands|length == 0
+ - result.changed == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/empty_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/empty_config.yaml
new file mode 100644
index 000000000..80583501f
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/empty_config.yaml
@@ -0,0 +1,58 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_acls empty_config.yaml integration tests on connection={{ ansible_connection }}
+
+- name: Merged with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_acls:
+ config:
+ state: merged
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state merged'
+
+- name: Replaced with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_acls:
+ config:
+ state: replaced
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state replaced'
+
+- name: Overridden with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_acls:
+ config:
+ state: overridden
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state overridden'
+
+- name: Rendered with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_acls:
+ config:
+ state: rendered
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state rendered'
+
+- name: Parsed with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_acls:
+ running_config:
+ state: parsed
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of running_config parameter must not be empty for state parsed'
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/gathered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/gathered.yaml
new file mode 100644
index 000000000..aae260ebb
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/gathered.yaml
@@ -0,0 +1,21 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_acls gathered integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Gather the provided configuration with the existing running configuration
+ register: result
+ cisco.ios.ios_acls:
+ config:
+ state: gathered
+
+ - ansible.builtin.assert:
+ that:
+ - gathered['config'] | symmetric_difference(result.gathered) == []
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/merged.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/merged.yaml
new file mode 100644
index 000000000..50ee2fd14
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/merged.yaml
@@ -0,0 +1,159 @@
+---
+- ansible.builtin.debug:
+ msg: START Merged ios_acls state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- block:
+ - name: Merge initial configuration with device configuration
+ cisco.ios.ios_acls:
+ config:
+ - afi: ipv4
+ acls:
+ - name: test_acl
+ acl_type: extended
+ aces:
+ - grant: deny
+ sequence: 10
+ protocol: tcp
+ protocol_options:
+ tcp:
+ fin: true
+ source:
+ address: 192.0.4.0
+ wildcard_bits: 0.0.0.255
+ destination:
+ address: 192.0.5.0
+ wildcard_bits: 0.0.0.255
+ port_protocol:
+ eq: www
+ option:
+ traceroute: true
+ ttl:
+ eq: 10
+ state: merged
+
+ - name: Merge new configuration with existing device configuration
+ register: result
+ cisco.ios.ios_acls: &id001
+ config:
+ - afi: ipv4
+ acls:
+ - name: std_acl
+ acl_type: standard
+ aces:
+ - grant: deny
+ sequence: 10
+ source:
+ address: 192.0.2.0
+ wildcard_bits: 0.0.0.255
+ - name: test_acl
+ acl_type: extended
+ aces:
+ - grant: deny
+ sequence: 10
+ protocol: tcp
+ protocol_options:
+ tcp:
+ fin: true
+ source:
+ address: 192.0.4.0
+ wildcard_bits: 0.0.0.255
+ destination:
+ address: 192.0.5.0
+ wildcard_bits: 0.0.0.255
+ port_protocol:
+ eq: www
+ option:
+ traceroute: true
+ ttl:
+ eq: 10
+ - name: 110
+ aces:
+ - grant: deny
+ sequence: 10
+ protocol: icmp
+ protocol_options:
+ icmp:
+ echo: true
+ source:
+ address: 192.0.2.0
+ wildcard_bits: 0.0.0.255
+ destination:
+ address: 192.0.3.0
+ wildcard_bits: 0.0.0.255
+ dscp: ef
+ ttl:
+ eq: 10
+ - name: 123
+ aces:
+ - grant: deny
+ sequence: 10
+ protocol: tcp
+ protocol_options:
+ tcp:
+ ack: true
+ source:
+ address: 198.51.100.0
+ wildcard_bits: 0.0.0.255
+ destination:
+ address: 198.51.101.0
+ wildcard_bits: 0.0.0.255
+ port_protocol:
+ eq: telnet
+ tos:
+ service_value: 12
+ - grant: deny
+ sequence: 20
+ protocol: tcp
+ protocol_options:
+ tcp:
+ ack: true
+ source:
+ address: 192.0.3.0
+ wildcard_bits: 0.0.0.255
+ destination:
+ address: 192.0.4.0
+ wildcard_bits: 0.0.0.255
+ port_protocol:
+ eq: www
+ dscp: ef
+ ttl:
+ lt: 20
+ - afi: ipv6
+ acls:
+ - name: R1_TRAFFIC
+ aces:
+ - grant: deny
+ sequence: 10
+ protocol: tcp
+ protocol_options:
+ tcp:
+ ack: true
+ source:
+ any: true
+ port_protocol:
+ eq: www
+ destination:
+ any: true
+ port_protocol:
+ eq: telnet
+ dscp: af11
+ state: merged
+
+ - ansible.builtin.assert:
+ that:
+ - result.commands|length == 9
+ - result.changed == true
+ - result.commands|symmetric_difference(merged.commands) == []
+
+ - name: Merge provided configuration with device configuration (idempotent)
+ register: result
+ cisco.ios.ios_acls: *id001
+ - name: Assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result.commands|length == 0
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/overridden.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/overridden.yaml
new file mode 100644
index 000000000..0ff62f32b
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/overridden.yaml
@@ -0,0 +1,93 @@
+---
+- ansible.builtin.debug:
+ msg: START Overridden ios_acls state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Override device configuration of all interfaces with provided configuration
+ register: result
+ cisco.ios.ios_acls: &id001
+ config:
+ - afi: ipv4
+ acls:
+ - name: 110
+ aces:
+ - grant: deny
+ protocol: tcp
+ protocol_options:
+ tcp:
+ ack: true
+ sequence: 10
+ source:
+ address: 198.51.100.0
+ wildcard_bits: 0.0.0.255
+ port_protocol:
+ eq: telnet
+ destination:
+ address: 198.51.110.0
+ wildcard_bits: 0.0.0.255
+ port_protocol:
+ eq: www
+ dscp: ef
+ ttl:
+ eq: 10
+ - name: 123
+ aces:
+ - grant: deny
+ sequence: 10
+ protocol: tcp
+ protocol_options:
+ tcp:
+ ack: true
+ source:
+ address: 198.51.100.0
+ wildcard_bits: 0.0.0.255
+ destination:
+ address: 198.51.101.0
+ wildcard_bits: 0.0.0.255
+ port_protocol:
+ eq: telnet
+ tos:
+ service_value: 12
+ - name: 150
+ aces:
+ - grant: deny
+ sequence: 10
+ protocol: tcp
+ protocol_options:
+ tcp:
+ syn: true
+ source:
+ address: 198.51.100.0
+ wildcard_bits: 0.0.0.255
+ port_protocol:
+ eq: telnet
+ destination:
+ address: 198.51.110.0
+ wildcard_bits: 0.0.0.255
+ port_protocol:
+ eq: telnet
+ dscp: ef
+ ttl:
+ eq: 10
+ state: overridden
+
+ - ansible.builtin.assert:
+ that:
+ - result.commands|length == 9
+ - result.changed == true
+ - result.commands|symmetric_difference(overridden.commands) == []
+
+ - name: Override device configuration of all interfaces with provided configuration (idempotent)
+ register: result
+ cisco.ios.ios_acls: *id001
+ - name: Assert that task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result.commands|length == 0
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/parsed.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/parsed.yaml
new file mode 100644
index 000000000..fbdaac290
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/parsed.yaml
@@ -0,0 +1,15 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_acls parsed integration tests on connection={{ ansible_connection }}
+
+- name: Parse the commands for provided configuration
+ become: true
+ register: result
+ cisco.ios.ios_acls:
+ running_config: "{{ lookup('file', '_parsed.cfg') }}"
+ state: parsed
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - parsed['config']|symmetric_difference(result.parsed) == []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/rendered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/rendered.yaml
new file mode 100644
index 000000000..f1243a7af
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/rendered.yaml
@@ -0,0 +1,57 @@
+---
+- ansible.builtin.debug:
+ msg: Start ios_acls rendered integration tests ansible_connection={{ ansible_connection }}
+
+- block:
+ - name: Rendered the provided configuration with the existing running configuration
+ register: result
+ cisco.ios.ios_acls:
+ config:
+ - afi: ipv4
+ acls:
+ - name: 110
+ aces:
+ - grant: deny
+ sequence: 10
+ protocol: tcp
+ protocol_options:
+ tcp:
+ syn: true
+ source:
+ address: 192.0.2.0
+ wildcard_bits: 0.0.0.255
+ destination:
+ address: 192.0.3.0
+ wildcard_bits: 0.0.0.255
+ port_protocol:
+ eq: www
+ dscp: ef
+ ttl:
+ eq: 10
+
+ - name: 150
+ aces:
+ - grant: deny
+ protocol: tcp
+ protocol_options:
+ tcp:
+ syn: true
+ source:
+ address: 198.51.100.0
+ wildcard_bits: 0.0.0.255
+ port_protocol:
+ eq: telnet
+ destination:
+ address: 198.51.110.0
+ wildcard_bits: 0.0.0.255
+ port_protocol:
+ eq: telnet
+ dscp: ef
+ ttl:
+ eq: 10
+ state: rendered
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - result.rendered|symmetric_difference(rendered.commands) == []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/replaced.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/replaced.yaml
new file mode 100644
index 000000000..f4faca3ba
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/replaced.yaml
@@ -0,0 +1,91 @@
+---
+- ansible.builtin.debug:
+ msg: START Replaced ios_acls state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Replaces device configuration of listed interfaces with provided configuration
+ register: result
+ cisco.ios.ios_acls: &id001
+ config:
+ - afi: ipv4
+ acls:
+ - name: 110
+ aces:
+ - grant: deny
+ protocol: tcp
+ protocol_options:
+ tcp:
+ syn: true
+ sequence: 10
+ source:
+ address: 192.0.2.0
+ wildcard_bits: 0.0.0.255
+ destination:
+ address: 192.0.3.0
+ wildcard_bits: 0.0.0.255
+ port_protocol:
+ eq: www
+ dscp: ef
+ ttl:
+ eq: 10
+ - name: 123
+ aces:
+ - grant: deny
+ sequence: 10
+ protocol: tcp
+ protocol_options:
+ tcp:
+ ack: true
+ source:
+ address: 198.51.100.0
+ wildcard_bits: 0.0.0.255
+ destination:
+ address: 198.51.101.0
+ wildcard_bits: 0.0.0.255
+ port_protocol:
+ eq: telnet
+ tos:
+ service_value: 12
+ - name: 150
+ aces:
+ - grant: deny
+ sequence: 20
+ protocol: tcp
+ protocol_options:
+ tcp:
+ syn: true
+ source:
+ address: 198.51.100.0
+ wildcard_bits: 0.0.0.255
+ port_protocol:
+ eq: telnet
+ destination:
+ address: 198.51.110.0
+ wildcard_bits: 0.0.0.255
+ port_protocol:
+ eq: telnet
+ dscp: ef
+ ttl:
+ eq: 10
+ state: replaced
+
+ - ansible.builtin.assert:
+ that:
+ - result.commands|length == 7
+ - result.changed == true
+ - result.commands|symmetric_difference(replaced.commands) == []
+
+ - name: Replaces device configuration of listed interfaces with provided configuration (idempotent)
+ register: result
+ cisco.ios.ios_acls: *id001
+ - name: Assert that task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result.commands|length == 0
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/rtt.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/rtt.yaml
new file mode 100644
index 000000000..1778cdbbd
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/rtt.yaml
@@ -0,0 +1,201 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_acls round trip integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Apply the provided configuration (base config)
+ register: base_config
+ cisco.ios.ios_acls:
+ config:
+ - afi: ipv4
+ acls:
+ - name: test_acl
+ acl_type: extended
+ aces:
+ - grant: deny
+ protocol: tcp
+ protocol_options:
+ tcp:
+ fin: true
+ source:
+ address: 192.0.2.0
+ wildcard_bits: 0.0.0.255
+ destination:
+ address: 192.0.3.0
+ wildcard_bits: 0.0.0.255
+ port_protocol:
+ eq: www
+ option:
+ traceroute: true
+ ttl:
+ eq: 10
+
+ - name: 110
+ aces:
+ - grant: deny
+ protocol: icmp
+ protocol_options:
+ icmp:
+ echo: true
+ source:
+ address: 192.0.2.0
+ wildcard_bits: 0.0.0.255
+ destination:
+ address: 192.0.3.0
+ wildcard_bits: 0.0.0.255
+ dscp: ef
+ ttl:
+ eq: 10
+
+ - name: 123
+ aces:
+ - grant: deny
+ protocol: tcp
+ protocol_options:
+ tcp:
+ ack: true
+ source:
+ address: 198.51.100.0
+ wildcard_bits: 0.0.0.255
+ destination:
+ address: 198.51.101.0
+ wildcard_bits: 0.0.0.255
+ port_protocol:
+ eq: telnet
+ tos:
+ service_value: 12
+
+ - grant: deny
+ protocol: tcp
+ protocol_options:
+ tcp:
+ ack: true
+ source:
+ address: 192.0.3.0
+ wildcard_bits: 0.0.0.255
+ destination:
+ address: 192.0.4.0
+ wildcard_bits: 0.0.0.255
+ port_protocol:
+ eq: www
+ dscp: ef
+ ttl:
+ lt: 20
+
+ - afi: ipv6
+ acls:
+ - name: R1_TRAFFIC
+ aces:
+ - grant: deny
+ protocol: tcp
+ protocol_options:
+ tcp:
+ ack: true
+ source:
+ any: true
+ port_protocol:
+ eq: www
+ destination:
+ any: true
+ port_protocol:
+ eq: telnet
+ dscp: af11
+ state: merged
+
+ - name: Gather acls facts
+ cisco.ios.ios_facts:
+ gather_subset:
+ - "!all"
+ - "!min"
+ gather_network_resources:
+ - acls
+
+ - name: Apply the configuration which need to be reverted
+ register: result
+ cisco.ios.ios_acls:
+ config:
+ - afi: ipv4
+ acls:
+ - name: 110
+ aces:
+ - grant: deny
+ protocol: tcp
+ protocol_options:
+ tcp:
+ ack: true
+ sequence: 10
+ source:
+ address: 198.51.100.0
+ wildcard_bits: 0.0.0.255
+ port_protocol:
+ eq: telnet
+ destination:
+ address: 198.51.110.0
+ wildcard_bits: 0.0.0.255
+ port_protocol:
+ eq: www
+ dscp: ef
+ ttl:
+ eq: 10
+ - name: 123
+ aces:
+ - grant: deny
+ protocol: tcp
+ protocol_options:
+ tcp:
+ ack: true
+ source:
+ address: 198.51.100.0
+ wildcard_bits: 0.0.0.255
+ destination:
+ address: 198.51.101.0
+ wildcard_bits: 0.0.0.255
+ port_protocol:
+ eq: telnet
+ tos:
+ service_value: 12
+ - name: 150
+ aces:
+ - grant: deny
+ protocol: tcp
+ protocol_options:
+ tcp:
+ syn: true
+ source:
+ address: 198.51.100.0
+ wildcard_bits: 0.0.0.255
+ port_protocol:
+ eq: telnet
+ destination:
+ address: 198.51.110.0
+ wildcard_bits: 0.0.0.255
+ port_protocol:
+ eq: telnet
+ dscp: ef
+ ttl:
+ eq: 10
+ state: overridden
+
+ - ansible.builtin.assert:
+ that:
+ - result.commands|length == 11
+ - result.changed == true
+ - result.commands|symmetric_difference(rtt_overriden.commands) == []
+
+ - name: Revert back to base configuration using facts round trip
+ register: revert
+ cisco.ios.ios_acls:
+ config: "{{ ansible_facts['network_resources']['acls'] }}"
+ state: overridden
+
+ - ansible.builtin.assert:
+ that:
+ - revert.commands|length == 10
+ - revert.changed == true
+ - revert.commands|symmetric_difference(rtt.commands) == []
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/vars/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/vars/main.yaml
new file mode 100644
index 000000000..799b166a3
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/vars/main.yaml
@@ -0,0 +1,286 @@
+---
+deleted:
+ commands:
+ - no ip access-list extended test_acl
+ - no ip access-list extended 110
+ - no ipv6 access-list R1_TRAFFIC
+deleted_afi:
+ commands:
+ - no ip access-list extended 110
+ - no ip access-list extended 123
+ - no ip access-list extended test_acl
+deleted_all:
+ commands:
+ - no ip access-list extended test_acl
+ - no ip access-list extended 110
+ - no ip access-list extended 123
+ - no ipv6 access-list R1_TRAFFIC
+merged:
+ commands:
+ - ip access-list standard std_acl
+ - 10 deny 192.0.2.0 0.0.0.255
+ - ip access-list extended 110
+ - 10 deny icmp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 echo dscp ef ttl eq 10
+ - ip access-list extended 123
+ - 10 deny tcp 198.51.100.0 0.0.0.255 198.51.101.0 0.0.0.255 eq telnet ack tos 12
+ - 20 deny tcp 192.0.3.0 0.0.0.255 192.0.4.0 0.0.0.255 eq www ack dscp ef ttl lt 20
+ - ipv6 access-list R1_TRAFFIC
+ - deny tcp any eq www any eq telnet ack dscp af11 sequence 10
+replaced:
+ commands:
+ - ip access-list extended 110
+ - no 10 deny icmp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 echo dscp ef ttl eq 10
+ - 10 deny tcp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 eq www syn dscp ef ttl eq 10
+ - ip access-list extended 123
+ - no 20 deny tcp 192.0.3.0 0.0.0.255 192.0.4.0 0.0.0.255 eq www ack dscp ef ttl lt 20
+ - ip access-list extended 150
+ - 20 deny tcp 198.51.100.0 0.0.0.255 eq telnet 198.51.110.0 0.0.0.255 eq telnet
+ syn dscp ef ttl eq 10
+overridden:
+ commands:
+ - no ipv6 access-list R1_TRAFFIC
+ - no ip access-list extended test_acl
+ - ip access-list extended 110
+ - no 10 deny icmp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 echo dscp ef ttl eq 10
+ - 10 deny tcp 198.51.100.0 0.0.0.255 eq telnet 198.51.110.0 0.0.0.255 eq www ack
+ dscp ef ttl eq 10
+ - ip access-list extended 123
+ - no 20 deny tcp 192.0.3.0 0.0.0.255 192.0.4.0 0.0.0.255 eq www ack dscp ef ttl lt 20
+ - ip access-list extended 150
+ - 10 deny tcp 198.51.100.0 0.0.0.255 eq telnet 198.51.110.0 0.0.0.255 eq telnet syn
+ dscp ef ttl eq 10
+
+gathered:
+ config:
+ - acls:
+ - aces:
+ - destination:
+ address: 192.0.3.0
+ wildcard_bits: 0.0.0.255
+ dscp: ef
+ grant: deny
+ protocol: icmp
+ protocol_options:
+ icmp:
+ echo: true
+ sequence: 10
+ source:
+ address: 192.0.2.0
+ wildcard_bits: 0.0.0.255
+ ttl:
+ eq: 10
+ acl_type: extended
+ name: "110"
+ - aces:
+ - destination:
+ address: 198.51.101.0
+ port_protocol:
+ eq: telnet
+ wildcard_bits: 0.0.0.255
+ grant: deny
+ protocol: tcp
+ protocol_options:
+ tcp:
+ ack: true
+ sequence: 10
+ source:
+ address: 198.51.100.0
+ wildcard_bits: 0.0.0.255
+ tos:
+ service_value: 12
+ - destination:
+ address: 192.0.4.0
+ port_protocol:
+ eq: www
+ wildcard_bits: 0.0.0.255
+ dscp: ef
+ grant: deny
+ protocol: tcp
+ protocol_options:
+ tcp:
+ ack: true
+ sequence: 20
+ source:
+ address: 192.0.3.0
+ wildcard_bits: 0.0.0.255
+ ttl:
+ lt: 20
+ acl_type: extended
+ name: "123"
+ - aces:
+ - destination:
+ address: 192.0.3.0
+ port_protocol:
+ eq: www
+ wildcard_bits: 0.0.0.255
+ grant: deny
+ option:
+ traceroute: true
+ protocol: tcp
+ protocol_options:
+ tcp:
+ fin: true
+ sequence: 10
+ source:
+ address: 192.0.2.0
+ wildcard_bits: 0.0.0.255
+ ttl:
+ eq: 10
+ acl_type: extended
+ name: test_acl
+ afi: ipv4
+ - acls:
+ - aces:
+ - destination:
+ any: true
+ port_protocol:
+ eq: telnet
+ dscp: af11
+ grant: deny
+ protocol: tcp
+ protocol_options:
+ tcp:
+ ack: true
+ sequence: 10
+ source:
+ any: true
+ port_protocol:
+ eq: www
+ name: R1_TRAFFIC
+ afi: ipv6
+
+parsed:
+ config:
+ - acls:
+ - aces:
+ - destination:
+ address: 192.0.3.0
+ wildcard_bits: 0.0.0.255
+ dscp: ef
+ grant: deny
+ protocol: icmp
+ protocol_options:
+ icmp:
+ echo: true
+ sequence: 10
+ source:
+ address: 192.0.2.0
+ wildcard_bits: 0.0.0.255
+ ttl:
+ eq: 10
+ - remarks:
+ - "test a remark."
+ acl_type: extended
+ name: "110"
+ - aces:
+ - destination:
+ address: 198.51.101.0
+ port_protocol:
+ eq: telnet
+ wildcard_bits: 0.0.0.255
+ grant: deny
+ protocol: tcp
+ protocol_options:
+ tcp:
+ ack: true
+ sequence: 10
+ source:
+ address: 198.51.100.0
+ wildcard_bits: 0.0.0.255
+ tos:
+ service_value: 12
+ - destination:
+ address: 192.0.4.0
+ port_protocol:
+ eq: www
+ wildcard_bits: 0.0.0.255
+ dscp: ef
+ grant: deny
+ protocol: tcp
+ protocol_options:
+ tcp:
+ ack: true
+ sequence: 20
+ source:
+ address: 192.0.3.0
+ wildcard_bits: 0.0.0.255
+ ttl:
+ lt: 20
+ acl_type: extended
+ name: "123"
+ - aces:
+ - destination:
+ address: 192.0.3.0
+ port_protocol:
+ eq: www
+ wildcard_bits: 0.0.0.255
+ grant: deny
+ option:
+ traceroute: true
+ protocol: tcp
+ protocol_options:
+ tcp:
+ fin: true
+ sequence: 10
+ source:
+ address: 192.0.2.0
+ wildcard_bits: 0.0.0.255
+ ttl:
+ eq: 10
+ acl_type: extended
+ name: test_acl
+ afi: ipv4
+ - acls:
+ - aces:
+ - destination:
+ any: true
+ port_protocol:
+ eq: telnet
+ dscp: af11
+ grant: deny
+ protocol: tcp
+ protocol_options:
+ tcp:
+ ack: true
+ sequence: 10
+ source:
+ any: true
+ port_protocol:
+ eq: www
+ name: R1_TRAFFIC
+ afi: ipv6
+
+rendered:
+ commands:
+ - ip access-list extended 110
+ - 10 deny tcp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 eq www syn dscp ef ttl eq
+ 10
+ - ip access-list extended 150
+ - deny tcp 198.51.100.0 0.0.0.255 eq telnet 198.51.110.0 0.0.0.255 eq telnet syn
+ dscp ef ttl eq 10
+
+rtt_overriden:
+ commands:
+ - no ipv6 access-list R1_TRAFFIC
+ - no ip access-list extended test_acl
+ - ip access-list extended 110
+ - no 10 deny icmp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 echo dscp ef ttl eq 10
+ - 10 deny tcp 198.51.100.0 0.0.0.255 eq telnet 198.51.110.0 0.0.0.255 eq www ack dscp ef ttl eq 10
+ - ip access-list extended 123
+ - no 10 deny tcp 198.51.100.0 0.0.0.255 198.51.101.0 0.0.0.255 eq telnet ack tos 12
+ - no 20 deny tcp 192.0.3.0 0.0.0.255 192.0.4.0 0.0.0.255 eq www ack dscp ef ttl lt 20
+ - deny tcp 198.51.100.0 0.0.0.255 198.51.101.0 0.0.0.255 eq telnet ack tos 12
+ - ip access-list extended 150
+ - deny tcp 198.51.100.0 0.0.0.255 eq telnet 198.51.110.0 0.0.0.255 eq telnet syn dscp ef ttl eq 10
+rtt:
+ commands:
+ - ip access-list extended 110
+ - no 10 deny tcp 198.51.100.0 0.0.0.255 eq telnet 198.51.110.0 0.0.0.255 eq www ack dscp ef ttl eq 10
+ - 10 deny icmp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 echo dscp ef ttl eq 10
+ - ip access-list extended 123
+ - 20 deny tcp 192.0.3.0 0.0.0.255 192.0.4.0 0.0.0.255 eq www ack dscp ef ttl lt 20
+ - ip access-list extended test_acl
+ - 10 deny tcp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 eq www fin option traceroute ttl eq 10
+ - no ip access-list extended 150
+ - ipv6 access-list R1_TRAFFIC
+ - deny tcp any eq www any eq telnet ack dscp af11 sequence 10
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_banner/defaults/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_banner/defaults/main.yaml
new file mode 100644
index 000000000..5f709c5aa
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_banner/defaults/main.yaml
@@ -0,0 +1,2 @@
+---
+testcase: "*"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_banner/meta/main.yml b/ansible_collections/cisco/ios/tests/integration/targets/ios_banner/meta/main.yml
new file mode 100644
index 000000000..ab3ad91bc
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_banner/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - prepare_ios_tests
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_banner/tasks/cli.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_banner/tasks/cli.yaml
new file mode 100644
index 000000000..cd8c04990
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_banner/tasks/cli.yaml
@@ -0,0 +1,18 @@
+---
+- name: Collect all CLI test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: Run test cases (connection=ansible.netcommon.network_cli)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+ tags: network_cli
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_banner/tasks/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_banner/tasks/main.yaml
new file mode 100644
index 000000000..5251acf55
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_banner/tasks/main.yaml
@@ -0,0 +1,3 @@
+---
+- name: Main task for banner module
+ ansible.builtin.include_tasks: cli.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_banner/tests/cli/basic-login.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_banner/tests/cli/basic-login.yaml
new file mode 100644
index 000000000..20f5758e4
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_banner/tests/cli/basic-login.yaml
@@ -0,0 +1,73 @@
+---
+- name: Setup - remove login
+ cisco.ios.ios_banner:
+ banner: login
+ state: absent
+
+- name: Set login
+ register: result
+ cisco.ios.ios_banner:
+ banner: login
+ text: "this is my login banner\nthat has a multiline\nstring\n"
+ state: present
+
+- ansible.builtin.debug:
+ msg: "{{ result }}"
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - "'banner login @\nthis is my login banner\nthat has a multiline\nstring\n@' in result.commands"
+
+- name: Set login again (idempotent)
+ register: result
+ cisco.ios.ios_banner:
+ banner: login
+ text: "this is my login banner\nthat has a multiline\nstring"
+ state: present
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - result.commands | length == 0
+
+- name: Set login delimiter
+ register: result
+ cisco.ios.ios_banner:
+ multiline_delimiter: "x"
+ banner: login
+ text: "this is my login banner\nthat has a multiline\nstring\nand a non-default multiline_delimiter"
+ state: present
+
+- ansible.builtin.debug:
+ msg: "{{ result }}"
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == True
+ - "'banner login x\nthis is my login banner\nthat has a multiline\nstring\nand a non-default multiline_delimiter\nx' in result.commands"
+
+- name: Set new login banner that has multiline delimination characters present - preparation for the next test
+ register: result
+ cisco.ios.ios_banner:
+ banner: login
+ multiline_delimiter: "^CCC"
+ text: "this is my login banner\nthat has a multiline\nstring\nand a multiple C chars in the multiline_delimiter\n"
+ state: present
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - "'banner login ^CCC\nthis is my login banner\nthat has a multiline\nstring\nand a multiple C chars in the multiline_delimiter\n^CCC' in result.commands"
+
+- name: Set new banner over device banner configuration with multiline delimination chars present - testing dynamic and resilent banner regex search
+ register: result
+ cisco.ios.ios_banner:
+ banner: login
+ text: "this is my login banner\nthat has a multiline\nstring\n"
+ state: present
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - "'banner login @\nthis is my login banner\nthat has a multiline\nstring\n@' in result.commands"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_banner/tests/cli/basic-motd.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_banner/tests/cli/basic-motd.yaml
new file mode 100644
index 000000000..9472d3fe1
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_banner/tests/cli/basic-motd.yaml
@@ -0,0 +1,32 @@
+---
+- name: Setup - remove MOTD
+ cisco.ios.ios_banner:
+ banner: motd
+ state: absent
+
+- name: Set MOTD
+ register: result
+ cisco.ios.ios_banner:
+ banner: motd
+ text: "this is my motd banner\nthat has a multiline\nstring\n"
+ state: present
+
+- ansible.builtin.debug:
+ msg: "{{ result }}"
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - "'banner motd @\nthis is my motd banner\nthat has a multiline\nstring\n@' in result.commands"
+
+- name: Set MOTD again (idempotent)
+ register: result
+ cisco.ios.ios_banner:
+ banner: motd
+ text: "this is my motd banner\nthat has a multiline\nstring"
+ state: present
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - result.commands | length == 0
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_banner/tests/cli/basic-no-login.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_banner/tests/cli/basic-no-login.yaml
new file mode 100644
index 000000000..e01bdd870
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_banner/tests/cli/basic-no-login.yaml
@@ -0,0 +1,31 @@
+---
+- name: Setup
+ cisco.ios.ios_banner:
+ banner: login
+ text: "Junk login banner\nover multiple lines\n"
+ state: present
+
+- name: Remove login
+ register: result
+ cisco.ios.ios_banner:
+ banner: login
+ state: absent
+
+- ansible.builtin.debug:
+ msg: "{{ result }}"
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - "'no banner login' in result.commands"
+
+- name: Remove login (idempotent)
+ register: result
+ cisco.ios.ios_banner:
+ banner: login
+ state: absent
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - result.commands | length == 0
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_banner/tests/cli/multiple-login-exec.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_banner/tests/cli/multiple-login-exec.yaml
new file mode 100644
index 000000000..77a3b1f09
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_banner/tests/cli/multiple-login-exec.yaml
@@ -0,0 +1,39 @@
+---
+- name: Setup - set login and exec
+ loop:
+ - login
+ - exec
+ cisco.ios.ios_banner:
+ banner: "{{ item }}"
+ text: "this is my login banner\nthat as a multiline\nstring\n"
+ state: present
+
+- name: Set login
+ register: result
+ cisco.ios.ios_banner:
+ banner: login
+ text: "this is my login banner\nthat as a multiline\nstring"
+ state: present
+
+- ansible.builtin.debug:
+ msg: "{{ result }}"
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - result.commands | length == 0
+
+- name: Set exec
+ register: result
+ cisco.ios.ios_banner:
+ banner: exec
+ text: "this is my login banner\nthat as a multiline\nstring"
+ state: present
+
+- ansible.builtin.debug:
+ msg: "{{ result }}"
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - result.commands | length == 0
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp/defaults/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp/defaults/main.yaml
new file mode 100644
index 000000000..5f709c5aa
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp/defaults/main.yaml
@@ -0,0 +1,2 @@
+---
+testcase: "*"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp/meta/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp/meta/main.yaml
new file mode 100644
index 000000000..ab3ad91bc
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp/meta/main.yaml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - prepare_ios_tests
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp/tasks/cli.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp/tasks/cli.yaml
new file mode 100644
index 000000000..2b6056023
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp/tasks/cli.yaml
@@ -0,0 +1,17 @@
+---
+- name: Collect all CLI test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: Run test cases (connection=ansible.netcommon.network_cli)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp/tasks/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp/tasks/main.yaml
new file mode 100644
index 000000000..2269ecb54
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp/tasks/main.yaml
@@ -0,0 +1,5 @@
+---
+- name: Main task for bgp module
+ ansible.builtin.include_tasks: cli.yaml
+ tags:
+ - network_cli
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp/tests/cli/basic.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp/tests/cli/basic.yaml
new file mode 100644
index 000000000..752f9ff4f
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp/tests/cli/basic.yaml
@@ -0,0 +1,490 @@
+---
+- ansible.builtin.debug: msg="START ios cli/ios_bgp.yaml on connection={{ ansible_connection }}"
+
+- name: Clear existing BGP configuration
+ ignore_errors: true
+ cisco.ios.ios_bgp:
+ operation: delete
+
+- block:
+ - name: Add fake configuration with 'bgp' string
+ cisco.ios.ios_config:
+ match: none
+ replace: block
+ lines:
+ - no ip access-list extended BGP_ACL
+ - ip access-list extended BGP_ACL
+ - permit tcp any any eq bgp
+
+ - name: Try delete fake BGP configuration
+ register: result
+ cisco.ios.ios_bgp:
+ operation: delete
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+ - name: Clean fake configuration with 'bgp' string
+ cisco.ios.ios_config:
+ match: none
+ replace: block
+ lines:
+ - no ip access-list extended BGP_ACL
+
+ - name: Add fake bgp-like configuration
+ cisco.ios.ios_config:
+ match: none
+ replace: block
+ lines:
+ - no ip access-list extended BGP_ACL_2
+ - ip access-list extended BGP_ACL_2
+ - remark router bgp 64496
+ - remark neighbor 192.0.2.10 remote-as 64496
+ - remark neighbor 192.0.2.10 shutdown
+ - remark address-family ipv4
+ - remark neighbor 192.0.2.10 activate
+ - remark exit-address-family
+ - permit tcp any any eq bgp
+
+ - name: Try delete fake bgp-like configuration
+ register: result
+ cisco.ios.ios_bgp:
+ operation: delete
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+ - name: Clean fake bgp-like configuration
+ cisco.ios.ios_config:
+ match: none
+ replace: block
+ lines:
+ - no ip access-list extended BGP_ACL_2
+
+ - name: Configure BGP with as 64496 and a router-id
+ register: result
+ cisco.ios.ios_bgp: &id001
+ operation: merge
+ config:
+ bgp_as: 64496
+ router_id: 192.0.2.2
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - "'router bgp 64496' in result.commands"
+ - "'bgp router-id 192.0.2.2' in result.commands"
+
+ - name: Configure BGP with as 64496 and a router-id (idempotent)
+ register: result
+ cisco.ios.ios_bgp: *id001
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+ - name: Configure BGP neighbors
+ register: result
+ cisco.ios.ios_bgp: &id002
+ operation: merge
+ config:
+ bgp_as: 64496
+ neighbors:
+ - neighbor: 192.0.2.10
+ remote_as: 64496
+ password: ansible
+ description: IBGP_NBR_1
+ ebgp_multihop: 100
+ timers:
+ keepalive: 300
+ holdtime: 360
+ min_neighbor_holdtime: 360
+
+ - neighbor: 192.0.2.15
+ remote_as: 64496
+ description: IBGP_NBR_2
+ ebgp_multihop: 150
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - "'router bgp 64496' in result.commands"
+ - "'neighbor 192.0.2.10 remote-as 64496' in result.commands"
+ - "'neighbor 192.0.2.10 description IBGP_NBR_1' in result.commands"
+ - "'neighbor 192.0.2.10 ebgp-multihop 100' in result.commands"
+ - "'neighbor 192.0.2.10 timers 300 360 360' in result.commands"
+ - "'neighbor 192.0.2.15 remote-as 64496' in result.commands"
+ - "'neighbor 192.0.2.15 description IBGP_NBR_2' in result.commands"
+ - "'neighbor 192.0.2.15 ebgp-multihop 150' in result.commands"
+
+ - name: Configure BGP neighbors (idempotent)
+ register: result
+ cisco.ios.ios_bgp: *id002
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+ - name: Configure BGP neighbors with operation replace
+ register: result
+ cisco.ios.ios_bgp: &id003
+ operation: replace
+ config:
+ bgp_as: 64496
+ neighbors:
+ - neighbor: 192.0.2.15
+ remote_as: 64496
+ description: IBGP_NBR_2
+ ebgp_multihop: 150
+
+ - neighbor: 203.0.113.10
+ remote_as: 64511
+ description: EBGP_NBR_1
+ local_as: 64497
+
+ - neighbor: 10.10.20.20
+ remote_as: 65012
+ description: BGP_NBR_2
+ ebgp_multihop: 100
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - "'neighbor 203.0.113.10 remote-as 64511' in result.commands"
+ - "'neighbor 203.0.113.10 description EBGP_NBR_1' in result.commands"
+ - "'neighbor 203.0.113.10 local-as 64497' in result.commands"
+ - "'neighbor 10.10.20.20 remote-as 65012' in result.commands"
+ - "'neighbor 10.10.20.20 description BGP_NBR_2' in result.commands"
+ - "'no neighbor 192.0.2.10' in result.commands"
+
+ - name: Configure BGP neighbors with operation replace (idempotent)
+ register: result
+ cisco.ios.ios_bgp: *id003
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+ - name: Configure root-level networks for BGP
+ register: result
+ cisco.ios.ios_bgp: &id004
+ operation: merge
+ config:
+ bgp_as: 64496
+ networks:
+ - prefix: 203.0.113.0
+ masklen: 27
+ route_map: RMAP_1
+
+ - prefix: 203.0.113.32
+ masklen: 27
+ route_map: RMAP_2
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == True
+ - "'router bgp 64496' in result.commands"
+ - "'network 203.0.113.0 mask 255.255.255.224 route-map RMAP_1' in result.commands"
+ - "'network 203.0.113.32 mask 255.255.255.224 route-map RMAP_2' in result.commands"
+
+ - name: Configure root-level networks for BGP (idempotent)
+ register: result
+ cisco.ios.ios_bgp: *id004
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+ - name: Configure root-level networks for BGP with operation replace
+ register: result
+ cisco.ios.ios_bgp: &id005
+ operation: replace
+ config:
+ bgp_as: 64496
+ networks:
+ - prefix: 203.0.113.0
+ masklen: 27
+ route_map: RMAP_1
+
+ - prefix: 198.51.100.16
+ masklen: 28
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == True
+ - "'router bgp 64496' in result.commands"
+ - "'network 198.51.100.16 mask 255.255.255.240' in result.commands"
+ - "'no network 203.0.113.32 mask 255.255.255.224 route-map RMAP_2' in result.commands"
+
+ - name: Configure root-level networks for BGP with operation replace (idempotent)
+ register: result
+ cisco.ios.ios_bgp: *id005
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+ - name: Configure BGP neighbors under address family mode
+ register: result
+ cisco.ios.ios_bgp: &id006
+ operation: merge
+ config:
+ bgp_as: 64496
+ address_family:
+ - afi: ipv4
+ safi: unicast
+ neighbors:
+ - neighbor: 203.0.113.10
+ activate: true
+ maximum_prefix: 250
+ advertisement_interval: 120
+
+ - neighbor: 192.0.2.15
+ activate: true
+ route_reflector_client: true
+
+ - neighbor: 10.10.20.20
+ activate: true
+ prefix_list_in: incoming-prefixes
+ prefix_list_out: outgoing-prefixes
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - "'router bgp 64496' in result.commands"
+ - "'address-family ipv4' in result.commands"
+ - "'neighbor 203.0.113.10 activate' in result.commands"
+ - "'neighbor 203.0.113.10 maximum-prefix 250' in result.commands"
+ - "'neighbor 203.0.113.10 advertisement-interval 120' in result.commands"
+ - "'neighbor 192.0.2.15 activate' in result.commands"
+ - "'neighbor 192.0.2.15 route-reflector-client' in result.commands"
+ - "'neighbor 10.10.20.20 activate' in result.commands"
+ - "'neighbor 10.10.20.20 prefix-list incoming-prefixes in' in result.commands"
+ - "'neighbor 10.10.20.20 prefix-list outgoing-prefixes out' in result.commands"
+
+ - name: Configure BGP neighbors under address family mode (idempotent)
+ register: result
+ cisco.ios.ios_bgp: *id006
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+ - name: Configure networks under address family
+ register: result
+ cisco.ios.ios_bgp: &id007
+ operation: merge
+ config:
+ bgp_as: 64496
+ address_family:
+ - afi: ipv4
+ safi: multicast
+ networks:
+ - prefix: 198.51.100.48
+ masklen: 28
+ route_map: RMAP_1
+
+ - prefix: 192.0.2.64
+ masklen: 27
+
+ - prefix: 203.0.113.160
+ masklen: 27
+ route_map: RMAP_2
+
+ - afi: ipv4
+ safi: unicast
+ networks:
+ - prefix: 198.51.100.64
+ masklen: 28
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - "'router bgp 64496' in result.commands"
+ - "'address-family ipv4 multicast' in result.commands"
+ - "'network 198.51.100.48 mask 255.255.255.240 route-map RMAP_1' in result.commands"
+ - "'network 192.0.2.64 mask 255.255.255.224' in result.commands"
+ - "'network 203.0.113.160 mask 255.255.255.224 route-map RMAP_2' in result.commands"
+ - "'exit-address-family' in result.commands"
+ - "'address-family ipv4' in result.commands"
+ - "'network 198.51.100.64 mask 255.255.255.240' in result.commands"
+ - "'exit-address-family' in result.commands"
+
+ - name: Configure networks under address family (idempotent)
+ register: result
+ cisco.ios.ios_bgp: *id007
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+ - name: Configure networks under address family with operation replace
+ register: result
+ cisco.ios.ios_bgp: &id008
+ operation: replace
+ config:
+ bgp_as: 64496
+ address_family:
+ - afi: ipv4
+ safi: multicast
+ networks:
+ - prefix: 198.51.100.80
+ masklen: 28
+
+ - prefix: 192.0.2.64
+ masklen: 27
+
+ - prefix: 203.0.113.192
+ masklen: 27
+
+ - afi: ipv4
+ safi: unicast
+ networks:
+ - prefix: 198.51.100.64
+ masklen: 28
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - '"router bgp 64496" in result.commands'
+ - '"address-family ipv4 multicast" in result.commands'
+ - '"network 198.51.100.80 mask 255.255.255.240" in result.commands'
+ - '"network 203.0.113.192 mask 255.255.255.224" in result.commands'
+ - '"no network 198.51.100.48 mask 255.255.255.240 route-map RMAP_1" in result.commands'
+ - '"no network 203.0.113.160 mask 255.255.255.224 route-map RMAP_2" in result.commands'
+ - '"exit-address-family" in result.commands'
+
+ - name: Configure networks under address family with operation replace (idempotent)
+ register: result
+ cisco.ios.ios_bgp: *id008
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+ - name: Configure redistribute information under address family mode
+ register: result
+ cisco.ios.ios_bgp: &id009
+ operation: merge
+ config:
+ bgp_as: 64496
+ address_family:
+ - afi: ipv4
+ safi: multicast
+ redistribute:
+ - protocol: ospf
+ id: 112
+ metric: 64
+
+ - protocol: eigrp
+ id: 233
+ metric: 256
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - "'router bgp 64496' in result.commands"
+ - "'address-family ipv4 multicast' in result.commands"
+ - "'redistribute ospf 112 metric 64' in result.commands"
+ - "'redistribute eigrp 233 metric 256' in result.commands"
+ - "'exit-address-family' in result.commands"
+
+ - name: Configure redistribute information under address family mode (idempotent)
+ register: result
+ cisco.ios.ios_bgp: *id009
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+ - name: Get the IOS version
+ cisco.ios.ios_facts:
+ gather_subset: all
+
+ - name: Configure redistribute information under address family mode with operation replace
+ register: result
+ cisco.ios.ios_bgp: &id010
+ operation: replace
+ config:
+ bgp_as: 64496
+ address_family:
+ - afi: ipv4
+ safi: multicast
+ redistribute:
+ - protocol: ospf
+ id: 112
+ metric: 64
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - "'router bgp 64496' in result.commands"
+ - "'address-family ipv4 multicast' in result.commands"
+ - "'no redistribute eigrp 233' in result.commands"
+ - "'exit-address-family' in result.commands"
+
+ - name: Configure redistribute information under address family mode with operation replace (idempotent)
+ register: result
+ when: ansible_net_version != "15.6(2)T"
+ cisco.ios.ios_bgp: *id010
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+ when: ansible_net_version != "15.6(2)T"
+
+ - name: Override all the existing BGP configuration
+ register: result
+ cisco.ios.ios_bgp:
+ operation: override
+ config:
+ bgp_as: 64497
+ router_id: 192.0.2.10
+ log_neighbor_changes: true
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - "'no router bgp 64496' in result.commands"
+ - "'router bgp 64497' in result.commands"
+ - "'bgp router-id 192.0.2.10' in result.commands"
+ - "'bgp log-neighbor-changes' in result.commands"
+
+ - name: Configure BGP neighbors with classful boundary
+ register: result
+ cisco.ios.ios_bgp: &id011
+ config:
+ bgp_as: 64497
+ log_neighbor_changes: true
+ networks:
+ - prefix: 198.51.100.0
+ masklen: 23
+
+ - prefix: 201.0.113.32
+ masklen: 24
+ operation: merge
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - "'router bgp 64497' in result.commands"
+ - "'network 198.51.100.0 mask 255.255.254.0' in result.commands"
+ - "'network 201.0.113.32' in result.commands"
+
+ - name: Configure BGP neighbors with classful boundary (idempotent)
+ register: result
+ cisco.ios.ios_bgp: *id011
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+ always:
+ - name: Teardown
+ register: result
+ cisco.ios.ios_bgp: &id012
+ operation: delete
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - "'no router bgp 64497' in result.commands"
+
+ - name: Teardown again (idempotent)
+ register: result
+ cisco.ios.ios_bgp: *id012
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+- ansible.builtin.debug: msg="END ios cli/ios_bgp.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/defaults/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/defaults/main.yaml
new file mode 100644
index 000000000..164afead2
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/meta/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/meta/main.yaml
new file mode 100644
index 000000000..23d65c7ef
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/meta/main.yaml
@@ -0,0 +1,2 @@
+---
+dependencies: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tasks/cli.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tasks/cli.yaml
new file mode 100644
index 000000000..6f505600c
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tasks/cli.yaml
@@ -0,0 +1,21 @@
+---
+- name: Collect all CLI test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+ delegate_to: localhost
+
+- name: Run test case (connection=ansible.netcommon.network_cli)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.network_cli
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tasks/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tasks/main.yaml
new file mode 100644
index 000000000..8b66c1ad5
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tasks/main.yaml
@@ -0,0 +1,5 @@
+---
+- name: Main task for bgp_address_family module
+ ansible.builtin.include_tasks: cli.yaml
+ tags:
+ - network_cli
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/_initial_vrf_setup.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/_initial_vrf_setup.yaml
new file mode 100644
index 000000000..1499ed729
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/_initial_vrf_setup.yaml
@@ -0,0 +1,13 @@
+---
+- name: Enable ipv6 routing configuration
+ vars:
+ lines: "ipv6 unicast-routing\n"
+ ansible.netcommon.cli_config:
+ config: "{{ lines }}"
+# - name: Create and setup VRF configuration # commented as c8000v throws topology error
+# register: result
+# cisco.ios.ios_config:
+# commands:
+# - rd 45000:2
+# - address-family ipv4
+# parents: vrf definition blue
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/_ospf_proc_setup.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/_ospf_proc_setup.yaml
new file mode 100644
index 000000000..fb563d583
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/_ospf_proc_setup.yaml
@@ -0,0 +1,8 @@
+---
+- name: Create OSPF processes for redistribution
+ cisco.ios.ios_ospfv2:
+ config:
+ processes:
+ - process_id: 123
+ - process_id: 124
+ state: merged
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/_parsed.cfg b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/_parsed.cfg
new file mode 100644
index 000000000..32acebc55
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/_parsed.cfg
@@ -0,0 +1,15 @@
+router bgp 65536
+ bgp router-id 198.51.110.175
+ bgp log-neighbor-changes
+ neighbor 198.51.110.212 remote-as 65536
+ neighbor 198.51.110.206 remote-as 65536
+ !
+ address-family ipv4
+ network 192.0.2.0
+ network 192.0.3.0
+ network 192.0.4.0
+ neighbor 198.51.110.212 activate
+ neighbor 198.51.110.212 soft-reconfiguration inbound
+ neighbor 198.51.110.206 activate
+ neighbor 198.51.110.206 soft-reconfiguration inbound
+ exit-address-family
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/_populate_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/_populate_config.yaml
new file mode 100644
index 000000000..4ac501796
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/_populate_config.yaml
@@ -0,0 +1,120 @@
+---
+- ansible.builtin.include_tasks: _initial_vrf_setup.yaml
+- ansible.builtin.include_tasks: _ospf_proc_setup.yaml
+- name: Populate BGP address family configuration
+ cisco.ios.ios_bgp_address_family:
+ config:
+ as_number: 65000
+ address_family:
+ - afi: ipv4
+ safi: multicast
+ # vrf: blue # commented as c8000v throws topology error
+ aggregate_address:
+ - address: 192.0.2.1
+ netmask: 255.255.255.255
+ as_confed_set: true
+ bgp:
+ aggregate_timer: 10
+ dampening:
+ penalty_half_time: 1
+ reuse_route_val: 1
+ suppress_route_val: 1
+ max_suppress: 1
+ slow_peer:
+ - detection:
+ threshold: 150
+ neighbor:
+ - address: 198.51.100.1
+ aigp:
+ send:
+ cost_community:
+ id: 100
+ poi:
+ igp_cost: true
+ transitive: true
+ slow_peer:
+ - detection:
+ threshold: 150
+ remote_as: 10
+ route_maps:
+ - name: test-route
+ out: true
+ network:
+ - address: 198.51.110.10
+ mask: 255.255.255.255
+ backdoor: true
+ - afi: ipv4
+ safi: mdt
+ bgp:
+ dmzlink_bw: true
+ dampening:
+ penalty_half_time: 1
+ reuse_route_val: 10
+ suppress_route_val: 100
+ max_suppress: 5
+ soft_reconfig_backup: true
+ - afi: ipv4
+ safi: multicast
+ aggregate_address:
+ - address: 192.0.3.1
+ netmask: 255.255.255.255
+ as_confed_set: true
+ default_metric: 12
+ distance:
+ external: 10
+ internal: 10
+ local: 100
+ network:
+ - address: 198.51.111.11
+ mask: 255.255.255.255
+ route_map: test
+ table_map:
+ name: test_tableMap
+ filter: true
+ - afi: ipv6
+ redistribute:
+ - ospf:
+ process_id: 124
+ match:
+ internal: true
+ externals:
+ type_1: true
+ type_2: true
+ nssa_externals:
+ type_1: true
+ type_2: true
+ metric: 10
+ route_map: bar
+ include_connected: true
+ - afi: ipv4
+ redistribute:
+ - connected:
+ metric: 10
+ - ospf:
+ process_id: 124
+ - ospf:
+ process_id: 123
+ match:
+ internal: true
+ externals:
+ type_1: true
+ type_2: true
+ nssa_externals:
+ type_1: true
+ type_2: true
+ metric: 10
+ route_map: bar
+ - ospfv3:
+ process_id: 123
+ match:
+ internal: true
+ externals:
+ type_1: true
+ type_2: true
+ nssa_externals:
+ type_1: true
+ type_2: true
+ metric: 10
+ route_map: bar
+
+ state: merged
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/_remove_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/_remove_config.yaml
new file mode 100644
index 000000000..36c3e745d
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/_remove_config.yaml
@@ -0,0 +1,23 @@
+---
+- name: Delete and clean ipv6 routings configuration
+ vars:
+ lines: "no ipv6 unicast-routing\n"
+ ansible.netcommon.cli_config:
+ config: "{{ lines }}"
+
+# - name: Delete and clean VRF rd configuration first # commented as c8000v throws topology error
+# register: result
+# cisco.ios.ios_config:
+# commands:
+# - no rd 45000:2
+# parents: vrf definition blue
+
+# - name: Delete and clean VRF configuration
+# vars:
+# lines: "no vrf definition blue\n"
+# ansible.netcommon.cli_config:
+# config: "{{ lines }}"
+
+- name: Remove BGP global configuration
+ cisco.ios.ios_bgp_global:
+ state: purged
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/deleted.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/deleted.yaml
new file mode 100644
index 000000000..80914f1a9
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/deleted.yaml
@@ -0,0 +1,56 @@
+---
+- ansible.builtin.debug:
+ msg: Start Deleted integration state for ios_bgp_address_family ansible_connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Delete provided BGP address family
+ register: result
+ cisco.ios.ios_bgp_address_family: &id001
+ config:
+ as_number: 65000
+ address_family:
+ - afi: ipv4
+ safi: multicast
+ - afi: ipv4
+ safi: mdt
+ - afi: ipv4
+ - afi: ipv6
+
+ state: deleted
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ deleted['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Delete provided BGP address family (idempotent)
+ register: result
+ cisco.ios.ios_bgp_address_family: *id001
+ - name: Assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+ - name: Delete all provided BGP address family
+ register: result
+ cisco.ios.ios_bgp_address_family: &id002
+ state: deleted
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ [] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Delete all provided BGP address family (idempotent)
+ register: result
+ cisco.ios.ios_bgp_address_family: *id002
+
+ - name: Assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result.changed == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/empty_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/empty_config.yaml
new file mode 100644
index 000000000..fc1898da5
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/empty_config.yaml
@@ -0,0 +1,58 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_bgp_address_family empty_config.yaml integration tests on connection={{ ansible_connection }}
+
+- name: Merged with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_bgp_address_family:
+ config:
+ state: merged
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state merged'
+
+- name: Replaced with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_bgp_address_family:
+ config:
+ state: replaced
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state replaced'
+
+- name: Overridden with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_bgp_address_family:
+ config:
+ state: overridden
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state overridden'
+
+- name: Rendered with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_bgp_address_family:
+ config:
+ state: rendered
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state rendered'
+
+- name: Parsed with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_bgp_address_family:
+ running_config:
+ state: parsed
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of running_config parameter must not be empty for state parsed'
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/gathered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/gathered.yaml
new file mode 100644
index 000000000..af9c435b2
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/gathered.yaml
@@ -0,0 +1,20 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_bgp_address_family gathered integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Gather the provided configuration with the existing running configuration
+ register: result
+ cisco.ios.ios_bgp_address_family:
+ config:
+ state: gathered
+
+ - name: Assert
+ ansible.builtin.assert:
+ that:
+ - result.changed == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/merged.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/merged.yaml
new file mode 100644
index 000000000..c09e95661
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/merged.yaml
@@ -0,0 +1,110 @@
+---
+- ansible.builtin.debug:
+ msg: START Merged ios_bgp_address_family state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _initial_vrf_setup.yaml
+- ansible.builtin.include_tasks: _ospf_proc_setup.yaml
+
+- block:
+ - name: Merge provided configuration with device configuration
+ register: result
+ cisco.ios.ios_bgp_address_family: &id001
+ config:
+ address_family:
+ - afi: ipv4
+ redistribute:
+ - connected:
+ metric: 10
+ - ospf:
+ process_id: 124
+ - ospf:
+ process_id: 123
+ match:
+ internal: true
+ externals:
+ type_1: true
+ type_2: true
+ nssa_externals:
+ type_1: true
+ type_2: true
+ metric: 10
+ route_map: bar
+ - ospfv3:
+ process_id: 123
+ match:
+ internal: true
+ externals:
+ type_1: true
+ type_2: true
+ nssa_externals:
+ type_1: true
+ type_2: true
+ metric: 10
+ route_map: bar
+ - afi: ipv4
+ aggregate_addresses:
+ - address: 192.0.3.1
+ as_confed_set: true
+ netmask: 255.255.255.255
+ default_metric: 12
+ distance:
+ external: 10
+ internal: 10
+ local: 100
+ networks:
+ - address: 198.51.111.11
+ mask: 255.255.255.255
+ route_map: test
+ safi: multicast
+ table_map:
+ filter: true
+ name: test_tableMap
+ - afi: ipv4
+ bgp:
+ dampening:
+ max_suppress: 5
+ penalty_half_time: 1
+ reuse_route_val: 10
+ suppress_route_val: 100
+ dmzlink_bw: true
+ soft_reconfig_backup: true
+ safi: mdt
+ - afi: ipv6
+ redistribute:
+ - ospf:
+ process_id: 124
+ match:
+ internal: true
+ externals:
+ type_1: true
+ type_2: true
+ nssa_externals:
+ type_1: true
+ type_2: true
+ metric: 10
+ route_map: bar
+ include_connected: true
+ as_number: "65000"
+ state: merged
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - merged['before'] == {}
+
+ # - name: Assert that after dict is correctly generated
+ # ansible.builtin.assert:
+ # that:
+ # - merged['after'] == result['after']
+
+ - name: Merge provided configuration with device configuration (idempotent)
+ register: result
+ cisco.ios.ios_bgp_address_family: *id001
+
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/overridden.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/overridden.yaml
new file mode 100644
index 000000000..420878b91
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/overridden.yaml
@@ -0,0 +1,94 @@
+---
+- ansible.builtin.debug:
+ msg: START Overridden ios_bgp_address_family state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Override provided BGP address family configuration
+ register: result
+ cisco.ios.ios_bgp_address_family: &id001
+ config:
+ as_number: 65000
+ address_family:
+ - afi: ipv4
+ redistribute:
+ - ospf:
+ process_id: 123
+ match:
+ externals:
+ type_1: true
+ nssa_externals:
+ type_2: true
+ metric: 15
+ route_map: foo
+ - ospfv3:
+ process_id: 123
+ match:
+ internal: true
+ externals:
+ type_2: true
+ nssa_externals:
+ type_1: true
+ metric: 15
+ route_map: foo
+ - afi: ipv4
+ safi: multicast
+ # vrf: blue
+ aggregate_address:
+ - address: 192.0.2.1
+ netmask: 255.255.255.255
+ as_confed_set: true
+ bgp:
+ aggregate_timer: 10
+ dampening:
+ penalty_half_time: 10
+ reuse_route_val: 10
+ suppress_route_val: 100
+ max_suppress: 50
+ slow_peer:
+ - detection:
+ threshold: 150
+ network:
+ - address: 198.51.110.10
+ mask: 255.255.255.255
+ backdoor: true
+ - afi: ipv6
+ safi: multicast
+ bgp:
+ aggregate_timer: 10
+ dampening:
+ penalty_half_time: 10
+ reuse_route_val: 10
+ suppress_route_val: 10
+ max_suppress: 10
+ slow_peer:
+ - detection:
+ threshold: 200
+ network:
+ - address: 2001:DB8:0:3::/64
+ route_map: test_ipv6
+ state: overridden
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ overridden['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ # - name: Assert that after dict is correctly generated
+ # ansible.builtin.assert:
+ # that:
+ # - overridden['after'] == result['after']
+
+ - name: Override provided BGP address family configuration (idempotent)
+ register: result
+ cisco.ios.ios_bgp_address_family: *id001
+
+ - name: Assert that task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/parsed.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/parsed.yaml
new file mode 100644
index 000000000..ca0597d57
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/parsed.yaml
@@ -0,0 +1,14 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_bgp_address_family parsed integration tests on connection={{ ansible_connection }}
+
+- name: Parse the commands for provided configuration
+ register: result
+ cisco.ios.ios_bgp_address_family:
+ running_config: "{{ lookup('file', '_parsed.cfg') }}"
+ state: parsed
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - parsed['config'] == result['parsed']
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/rendered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/rendered.yaml
new file mode 100644
index 000000000..77a5cd204
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/rendered.yaml
@@ -0,0 +1,81 @@
+---
+- ansible.builtin.debug:
+ msg: Start ios_bgp_address_family rendered integration tests ansible_connection={{ ansible_connection }}
+
+- block:
+ - name: Render the commands for provided configuration
+ register: result
+ cisco.ios.ios_bgp_address_family:
+ config:
+ as_number: 65000
+ address_family:
+ - afi: ipv4
+ safi: multicast
+ # vrf: blue
+ aggregate_address:
+ - address: 192.0.2.1
+ netmask: 255.255.255.255
+ as_confed_set: true
+ bgp:
+ aggregate_timer: 10
+ dampening:
+ penalty_half_time: 1
+ reuse_route_val: 1
+ suppress_route_val: 1
+ max_suppress: 1
+ slow_peer:
+ - detection:
+ threshold: 150
+ neighbor:
+ - address: 198.51.100.1
+ aigp:
+ send:
+ cost_community:
+ id: 100
+ poi:
+ igp_cost: true
+ transitive: true
+ slow_peer:
+ - detection:
+ threshold: 150
+ remote_as: 10
+ route_maps:
+ - name: test-route
+ out: true
+ network:
+ - address: 198.51.110.10
+ mask: 255.255.255.255
+ backdoor: true
+ - afi: ipv4
+ safi: mdt
+ bgp:
+ dmzlink_bw: true
+ dampening:
+ penalty_half_time: 1
+ reuse_route_val: 10
+ suppress_route_val: 100
+ max_suppress: 5
+ soft_reconfig_backup: true
+ - afi: ipv4
+ safi: multicast
+ aggregate_address:
+ - address: 192.0.3.1
+ netmask: 255.255.255.255
+ as_confed_set: true
+ default_metric: 12
+ distance:
+ external: 10
+ internal: 10
+ local: 100
+ network:
+ - address: 198.51.111.11
+ mask: 255.255.255.255
+ route_map: test
+ table_map:
+ name: test_tableMap
+ filter: true
+ state: rendered
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/replaced.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/replaced.yaml
new file mode 100644
index 000000000..31c8b0ada
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/replaced.yaml
@@ -0,0 +1,118 @@
+---
+- ansible.builtin.debug:
+ msg: START Replaced ios_bgp_address_family state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Replaced provided BGP address family configuration
+ register: result
+ cisco.ios.ios_bgp_address_family: &id001
+ config:
+ as_number: 65000
+ address_family:
+ - afi: ipv4
+ redistribute:
+ - ospf:
+ process_id: 123
+ match:
+ externals:
+ type_1: true
+ nssa_externals:
+ type_2: true
+ metric: 15
+ route_map: foo
+ - ospfv3:
+ process_id: 123
+ match:
+ internal: true
+ externals:
+ type_2: true
+ nssa_externals:
+ type_1: true
+ metric: 15
+ route_map: foo
+ - afi: ipv4
+ safi: multicast
+ # vrf: blue
+ aggregate_address:
+ - address: 192.0.2.1
+ netmask: 255.255.255.255
+ as_confed_set: true
+ bgp:
+ aggregate_timer: 10
+ dampening:
+ penalty_half_time: 1
+ reuse_route_val: 1
+ suppress_route_val: 1
+ max_suppress: 1
+ slow_peer:
+ - detection:
+ threshold: 150
+ neighbor:
+ - address: 198.51.110.1
+ activate: true
+ aigp:
+ send:
+ cost_community:
+ id: 200
+ poi:
+ igp_cost: true
+ transitive: true
+ slow_peer:
+ - detection:
+ threshold: 150
+ remote_as: 10
+ route_maps:
+ - name: test-replaced-route
+ out: true
+ network:
+ - address: 198.51.110.10
+ mask: 255.255.255.255
+ backdoor: true
+ - afi: ipv4
+ safi: multicast
+ bgp:
+ aggregate_timer: 10
+ dampening:
+ penalty_half_time: 10
+ reuse_route_val: 10
+ suppress_route_val: 10
+ max_suppress: 10
+ slow_peer:
+ - detection:
+ threshold: 200
+ network:
+ - address: 192.0.2.1
+ mask: 255.255.255.255
+ route_map: test
+ state: replaced
+
+ - name: debug merged commands
+ debug:
+ msg: "{{ replaced['after'] }}"
+
+ - name: debug result commands
+ debug:
+ msg: "{{ result['after'] }}"
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ replaced['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ # - name: Assert that after dict is correctly generated
+ # ansible.builtin.assert:
+ # that:
+ # - replaced['after'] == result['after']
+
+ - name: Replaced provided BGP address family configuration (idempotent)
+ register: result
+ cisco.ios.ios_bgp_address_family: *id001
+
+ - name: Assert that task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/vars/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/vars/main.yaml
new file mode 100644
index 000000000..293bbe67a
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/vars/main.yaml
@@ -0,0 +1,314 @@
+---
+merged:
+ before: {}
+
+ commands:
+ - router bgp 65000
+ - address-family ipv4 multicast
+ - default-metric 12
+ - distance bgp 10 10 100
+ - table-map test_tableMap filter
+ - network 198.51.111.11 mask 255.255.255.255 route-map test
+ - aggregate-address 192.0.3.1 255.255.255.255 as-confed-set
+ - address-family ipv4 mdt
+ - bgp dmzlink-bw
+ - bgp soft-reconfig-backup
+ - bgp dampening 1 10 100 5
+ - address-family ipv6
+ - redistribute ospf 124 metric 10 match internal external 1 external 2 nssa-external 1 nssa-external 2 route-map bar include-connected
+ - address-family ipv4
+ - redistribute connected metric 10
+ - redistribute ospf 123 metric 10 match internal external 1 external 2 nssa-external 1 nssa-external 2 route-map bar
+ - redistribute ospf 124
+ - redistribute ospfv3 123 metric 10 match internal external 1 external 2 nssa-external 1 nssa-external 2 route-map bar
+
+ after:
+ address_family:
+ - afi: ipv4
+ redistribute:
+ - connected:
+ metric: 10
+ set: true
+ - ospf:
+ process_id: 124
+ - ospf:
+ match:
+ externals:
+ type_1: true
+ type_2: true
+ internal: true
+ nssa_externals:
+ type_1: true
+ type_2: true
+ metric: 10
+ process_id: 123
+ route_map: bar
+ - ospfv3:
+ match:
+ externals:
+ type_1: true
+ type_2: true
+ internal: true
+ nssa_externals:
+ type_1: true
+ type_2: true
+ metric: 10
+ process_id: 123
+ route_map: bar
+ - afi: ipv4
+ aggregate_addresses:
+ - address: 192.0.3.1
+ as_confed_set: true
+ netmask: 255.255.255.255
+ default_metric: 12
+ distance:
+ external: 10
+ internal: 10
+ local: 100
+ networks:
+ - address: 198.51.111.11
+ mask: 255.255.255.255
+ route_map: test
+ safi: multicast
+ table_map:
+ filter: true
+ name: test_tableMap
+ - afi: ipv4
+ bgp:
+ dampening:
+ max_suppress: 5
+ penalty_half_time: 1
+ reuse_route_val: 10
+ suppress_route_val: 100
+ dmzlink_bw: true
+ soft_reconfig_backup: true
+ safi: mdt
+ - afi: ipv6
+ redistribute:
+ - ospf:
+ include_connected: true
+ match:
+ externals:
+ type_1: true
+ type_2: true
+ internal: true
+ nssa_externals:
+ type_1: true
+ type_2: true
+ metric: 10
+ process_id: 124
+ route_map: bar
+ as_number: "65000"
+
+overridden:
+ commands:
+ - router bgp 65000
+ - address-family ipv4 mdt
+ - no bgp dmzlink-bw
+ - no bgp soft-reconfig-backup
+ - no bgp dampening 1 10 100 5
+ - address-family ipv6
+ - no redistribute ospf 124
+ - address-family ipv4
+ - no redistribute connected
+ - no redistribute ospf 123
+ - redistribute ospf 123 metric 15 match external 1 nssa-external 2 route-map foo
+ - no redistribute ospf 124
+ - no redistribute ospfv3 123
+ - redistribute ospfv3 123 metric 15 match internal external 2 nssa-external 1 route-map foo
+ - address-family ipv4 multicast
+ - no default-metric 12
+ - no distance bgp 10 10 100
+ - no table-map test_tableMap filter
+ - bgp aggregate-timer 10
+ - bgp dampening 10 10 100 50
+ - bgp slow-peer detection threshold 150
+ - network 198.51.110.10 mask 255.255.255.255 backdoor
+ - no network 198.51.111.11 mask 255.255.255.255 route-map test
+ - aggregate-address 192.0.2.1 255.255.255.255 as-confed-set
+ - no aggregate-address 192.0.3.1 255.255.255.255 as-confed-set
+ - address-family ipv6 multicast
+ - bgp aggregate-timer 10
+ - bgp dampening 10 10 10 10
+ - bgp slow-peer detection threshold 200
+ - network 2001:DB8:0:3::/64 route-map test_ipv6
+
+ after:
+ address_family:
+ - afi: ipv4
+ redistribute:
+ - ospf:
+ process_id: 123
+ match:
+ externals:
+ type_1: true
+ nssa_externals:
+ type_2: true
+ metric: 15
+ route_map: foo
+ - ospfv3:
+ process_id: 123
+ match:
+ internal: true
+ externals:
+ type_2: true
+ nssa_externals:
+ type_1: true
+ metric: 15
+ route_map: foo
+ - afi: "ipv4"
+ aggregate_addresses:
+ - address: "192.0.2.1"
+ as_confed_set: true
+ netmask: "255.255.255.255"
+ bgp:
+ aggregate_timer: 10
+ dampening:
+ max_suppress: 50
+ penalty_half_time: 10
+ reuse_route_val: 10
+ suppress_route_val: 100
+ slow_peer_options:
+ detection:
+ threshold: 150
+ networks:
+ - address: "198.51.110.10"
+ backdoor: true
+ mask: "255.255.255.255"
+ safi: "multicast"
+ # vrf: "blue"
+ - afi: "ipv4"
+ safi: "mdt"
+ - afi: "ipv6"
+ - afi: "ipv6"
+ bgp:
+ aggregate_timer: 10
+ dampening:
+ max_suppress: 10
+ penalty_half_time: 10
+ reuse_route_val: 10
+ suppress_route_val: 10
+ slow_peer_options:
+ detection:
+ threshold: 200
+ networks:
+ - address: 2001:DB8:0:3::/64
+ route_map: test_ipv6
+ safi: "multicast"
+ as_number: "65000"
+
+replaced:
+ commands:
+ - router bgp 65000
+ - address-family ipv4
+ - no redistribute connected
+ - no redistribute ospf 123
+ - redistribute ospf 123 metric 15 match external 1 nssa-external 2 route-map foo
+ - no redistribute ospf 124
+ - no redistribute ospfv3 123
+ - redistribute ospfv3 123 metric 15 match internal external 2 nssa-external 1 route-map foo
+ - address-family ipv4 multicast
+ - no default-metric 12
+ - no distance bgp 10 10 100
+ - no table-map test_tableMap filter
+ - bgp aggregate-timer 10
+ - bgp dampening 10 10 10 10
+ - bgp slow-peer detection threshold 200
+ - network 192.0.2.1 mask 255.255.255.255 route-map test
+ - no network 198.51.111.11 mask 255.255.255.255 route-map test
+ - no aggregate-address 192.0.3.1 255.255.255.255 as-confed-set
+
+ after:
+ address_family:
+ - afi: ipv4
+ redistribute:
+ - ospf:
+ process_id: 123
+ match:
+ externals:
+ type_1: true
+ nssa_externals:
+ type_2: true
+ metric: 15
+ route_map: foo
+ - ospfv3:
+ process_id: 123
+ match:
+ internal: true
+ externals:
+ type_2: true
+ nssa_externals:
+ type_1: true
+ metric: 15
+ route_map: foo
+ - afi: ipv4
+ bgp:
+ aggregate_timer: 10
+ dampening:
+ max_suppress: 10
+ penalty_half_time: 10
+ reuse_route_val: 10
+ suppress_route_val: 10
+ slow_peer_options:
+ detection:
+ threshold: 200
+ networks:
+ - address: 192.0.2.1
+ mask: 255.255.255.255
+ route_map: test
+ safi: multicast
+ - afi: ipv4
+ bgp:
+ dampening:
+ max_suppress: 5
+ penalty_half_time: 1
+ reuse_route_val: 10
+ suppress_route_val: 100
+ dmzlink_bw: true
+ soft_reconfig_backup: true
+ safi: mdt
+ - afi: ipv6
+ redistribute:
+ - ospf:
+ process_id: 124
+ match:
+ internal: true
+ externals:
+ type_1: true
+ type_2: true
+ nssa_externals:
+ type_1: true
+ type_2: true
+ metric: 10
+ route_map: bar
+ include_connected: true
+ as_number: "65000"
+
+deleted:
+ commands:
+ - router bgp 65000
+ - no address-family ipv4 multicast
+ - no address-family ipv4 mdt
+ - no address-family ipv4
+ - no address-family ipv6
+
+deleted_all:
+ after:
+ as_number: "65000"
+
+parsed:
+ config:
+ address_family:
+ - afi: ipv4
+ neighbors:
+ - activate: true
+ neighbor_address: 198.51.110.212
+ soft_reconfiguration: true
+ - activate: true
+ neighbor_address: 198.51.110.206
+ soft_reconfiguration: true
+ networks:
+ - address: 192.0.2.0
+ - address: 192.0.3.0
+ - address: 192.0.4.0
+ as_number: "65536"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/defaults/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/defaults/main.yaml
new file mode 100644
index 000000000..164afead2
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/meta/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/meta/main.yaml
new file mode 100644
index 000000000..23d65c7ef
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/meta/main.yaml
@@ -0,0 +1,2 @@
+---
+dependencies: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tasks/cli.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tasks/cli.yaml
new file mode 100644
index 000000000..6f505600c
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tasks/cli.yaml
@@ -0,0 +1,21 @@
+---
+- name: Collect all CLI test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+ delegate_to: localhost
+
+- name: Run test case (connection=ansible.netcommon.network_cli)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.network_cli
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tasks/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tasks/main.yaml
new file mode 100644
index 000000000..13216d8e4
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tasks/main.yaml
@@ -0,0 +1,5 @@
+---
+- name: Main task for bgp_global module
+ ansible.builtin.include_tasks: cli.yaml
+ tags:
+ - network_cli
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/_parsed.cfg b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/_parsed.cfg
new file mode 100644
index 000000000..ffabff352
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/_parsed.cfg
@@ -0,0 +1,13 @@
+router bgp 65000
+ bgp nopeerup-delay post-boot 10
+ bgp graceful-shutdown all neighbors 50 local-preference 100 community 100
+ bgp bestpath compare-routerid
+ bgp dampening 1 1 1 1
+ bgp advertise-best-external
+ bgp log-neighbor-changes
+ timers bgp 100 200 150
+ redistribute connected metric 10
+ neighbor 198.0.2.1 remote-as 100
+ neighbor 198.0.2.1 description merge neighbor
+ neighbor 198.0.2.1 aigp send cost-community 100 poi igp-cost transitive
+ neighbor 198.0.2.1 route-map test-route out
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/_populate_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/_populate_config.yaml
new file mode 100644
index 000000000..7c216edb0
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/_populate_config.yaml
@@ -0,0 +1,44 @@
+---
+- name: Populate BGP global configuration
+ cisco.ios.ios_bgp_global:
+ config:
+ as_number: 65000
+ bgp:
+ advertise_best_external: true
+ log_neighbor_changes: true
+ bestpath_options:
+ compare_routerid: true
+ dampening:
+ penalty_half_time: 1
+ reuse_route_val: 1
+ suppress_route_val: 1
+ max_suppress: 1
+ graceful_shutdown:
+ neighbors:
+ time: 50
+ community: 100
+ local_preference: 100
+ nopeerup_delay:
+ - post_boot: 10
+ neighbor:
+ - address: 192.0.2.1
+ description: merge neighbor
+ remote_as: 100
+ aigp:
+ send:
+ cost_community:
+ id: 100
+ poi:
+ igp_cost: true
+ transitive: true
+ route_map:
+ name: test-route
+ out: true
+ redistribute:
+ - connected:
+ metric: 10
+ timers:
+ keepalive: 100
+ holdtime: 200
+ min_holdtime: 150
+ state: merged
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/_remove_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/_remove_config.yaml
new file mode 100644
index 000000000..d4053c8a1
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/_remove_config.yaml
@@ -0,0 +1,4 @@
+---
+- name: Remove BGP global configuration
+ cisco.ios.ios_bgp_global:
+ state: purged
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/deleted.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/deleted.yaml
new file mode 100644
index 000000000..bd992e88a
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/deleted.yaml
@@ -0,0 +1,35 @@
+---
+- ansible.builtin.debug:
+ msg: Start Deleted integration state for ios_bgp_global ansible_connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Delete provided BGP global
+ register: result
+ cisco.ios.ios_bgp_global: &id001
+ config:
+ as_number: 65000
+ state: deleted
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ deleted['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that after dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - deleted['after'] == result['after']
+
+ - name: Delete provided BGP global (idempotent)
+ register: result
+ cisco.ios.ios_bgp_global: *id001
+ - name: Assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/empty_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/empty_config.yaml
new file mode 100644
index 000000000..01b4cd528
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/empty_config.yaml
@@ -0,0 +1,47 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_bgp_global empty_config.yaml integration tests on connection={{ ansible_connection }}
+
+- name: Merged with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_bgp_global:
+ config:
+ state: merged
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state merged'
+
+- name: Replaced with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_bgp_global:
+ config:
+ state: replaced
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state replaced'
+
+- name: Rendered with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_bgp_global:
+ config:
+ state: rendered
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state rendered'
+
+- name: Parsed with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_bgp_global:
+ running_config:
+ state: parsed
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of running_config parameter must not be empty for state parsed'
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/gathered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/gathered.yaml
new file mode 100644
index 000000000..cc40b78de
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/gathered.yaml
@@ -0,0 +1,22 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_bgp_global gathered integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Gather the provided configuration with the existing running configuration
+ register: result
+ cisco.ios.ios_bgp_global:
+ config:
+ state: gathered
+
+ - name: Assert
+ ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - gathered['after'] == result['gathered']
+
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/merged.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/merged.yaml
new file mode 100644
index 000000000..1404b4e91
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/merged.yaml
@@ -0,0 +1,79 @@
+---
+- ansible.builtin.debug:
+ msg: START Merged ios_bgp_global state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- block:
+ - name: Merge provided configuration with device configuration
+ register: result
+ cisco.ios.ios_bgp_global: &id001
+ config:
+ as_number: 65000
+ bgp:
+ advertise_best_external: true
+ bestpath:
+ - compare_routerid: true
+ dampening:
+ penalty_half_time: 1
+ reuse_route_val: 1
+ suppress_route_val: 1
+ max_suppress: 1
+ graceful_shutdown:
+ neighbors:
+ time: 50
+ community: 100
+ local_preference: 100
+ log_neighbor_changes: true
+ nopeerup_delay:
+ - post_boot: 10
+ neighbor:
+ - address: 198.0.2.1
+ description: merge neighbor
+ remote_as: 100
+ shutdown:
+ set: false
+ aigp:
+ send:
+ cost_community:
+ id: 100
+ poi:
+ igp_cost: true
+ transitive: true
+ route_map:
+ name: test-route
+ out: true
+ redistribute:
+ - connected:
+ metric: 10
+ set: true
+ timers:
+ keepalive: 100
+ holdtime: 200
+ min_holdtime: 150
+ state: merged
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - merged['before'] == {}
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - merged['after'] == result['after']
+
+ - name: Merge provided configuration with device configuration (idempotent)
+ register: result
+ cisco.ios.ios_bgp_global: *id001
+ - name: Assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/parsed.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/parsed.yaml
new file mode 100644
index 000000000..bb6f6210f
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/parsed.yaml
@@ -0,0 +1,14 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_bgp_global parsed integration tests on connection={{ ansible_connection }}
+
+- name: Parse the commands for provided configuration
+ register: result
+ cisco.ios.ios_bgp_global:
+ running_config: "{{ lookup('file', '_parsed.cfg') }}"
+ state: parsed
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - parsed['after'] == result['parsed']
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/purged.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/purged.yaml
new file mode 100644
index 000000000..95f7177f8
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/purged.yaml
@@ -0,0 +1,29 @@
+---
+- ansible.builtin.debug:
+ msg: Start Deleted integration state for ios_bgp_global ansible_connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Purge provided BGP global
+ register: result
+ cisco.ios.ios_bgp_global: &id001
+ state: purged
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "'no router bgp 65000' in result.commands"
+ - result.commands|length == 1
+
+ - name: Purge provided BGP global (idempotent)
+ register: result
+ cisco.ios.ios_bgp_global: *id001
+ - name: Assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/rendered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/rendered.yaml
new file mode 100644
index 000000000..eace1e838
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/rendered.yaml
@@ -0,0 +1,54 @@
+---
+- ansible.builtin.debug:
+ msg: Start ios_bgp_global rendered integration tests ansible_connection={{ ansible_connection }}
+
+- block:
+ - name: Render the commands for provided configuration
+ register: result
+ cisco.ios.ios_bgp_global:
+ config:
+ as_number: 65000
+ bgp:
+ advertise_best_external: true
+ bestpath:
+ - compare_routerid: true
+ dampening:
+ penalty_half_time: 1
+ reuse_route_val: 1
+ suppress_route_val: 1
+ max_suppress: 1
+ graceful_shutdown:
+ neighbors:
+ time: 50
+ community: 100
+ local_preference: 100
+ log_neighbor_changes: true
+ nopeerup_delay_options:
+ post_boot: 10
+ neighbor:
+ - address: 192.0.2.1
+ description: merge neighbor
+ remote_as: 100
+ aigp:
+ send:
+ cost_community:
+ id: 100
+ poi:
+ igp_cost: true
+ transitive: true
+ route_map:
+ name: test-route
+ out: true
+ redistribute:
+ - connected:
+ metric: 10
+ timers:
+ keepalive: 100
+ holdtime: 200
+ min_holdtime: 150
+ state: rendered
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - result.rendered|symmetric_difference(rendered.commands) == []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/replaced.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/replaced.yaml
new file mode 100644
index 000000000..0fddfe10e
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/replaced.yaml
@@ -0,0 +1,54 @@
+---
+- ansible.builtin.debug:
+ msg: START Replaced ios_bgp_global state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Replaced provided BGP global configuration
+ register: result
+ cisco.ios.ios_bgp_global: &id001
+ config:
+ as_number: 65000
+ bgp:
+ advertise_best_external: true
+ bestpath_options:
+ med:
+ confed: true
+ log_neighbor_changes: true
+ nopeerup_delay_options:
+ post_boot: 10
+ cold_boot: 20
+ neighbor:
+ - address: 192.0.2.2
+ description: replace neighbor
+ remote_as: 100
+ slow_peer:
+ detection:
+ disable: true
+ redistribute:
+ - connected:
+ metric: 10
+ set: true
+ state: replaced
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ replaced['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - replaced['after'] == result['after']
+
+ - name: Replaced provided BGP global configuration (idempotent)
+ register: result
+ cisco.ios.ios_bgp_global: *id001
+ - name: Assert that task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/rtt.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/rtt.yaml
new file mode 100644
index 000000000..e35cf7914
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/tests/cli/rtt.yaml
@@ -0,0 +1,65 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_bgp_global round trip integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- block:
+ - name: Ios_bgp_global RTT - play (base config)
+ register: result
+ cisco.ios.ios_bgp_global:
+ config:
+ as_number: 65000
+ bgp:
+ advertise_best_external: true
+ bestpath_options:
+ med:
+ confed: true
+ log_neighbor_changes: true
+ nopeerup_delay_options:
+ post_boot: 10
+ cold_boot: 20
+ neighbor:
+ - address: 192.0.2.2
+ description: replace neighbor
+ remote_as: 100
+ slow_peer:
+ detection:
+ disable: true
+ networks:
+ - address: 192.0.2.3
+ redistribute:
+ - connected:
+ metric: 10
+ set: true
+ state: merged
+
+ - name: Ios_bgp_global RTT - gather bgp_global facts
+ cisco.ios.ios_facts:
+ gather_subset:
+ - "!all"
+ - "!min"
+ gather_network_resources:
+ - bgp_global
+
+ - name: Ios_bgp_global RTT - apply the provided configuration (config to be reverted)
+ cisco.ios.ios_bgp_global:
+ config:
+ as_number: 65000
+ networks:
+ - address: 192.0.4.2
+ state: merged
+
+ - name: Ios_bgp_global RTT - revert back to base configuration using facts round trip
+ register: revert
+ cisco.ios.ios_bgp_global:
+ config: "{{ ansible_facts['network_resources']['bgp_global'] }}"
+ state: replaced
+
+ - ansible.builtin.assert:
+ that:
+ - revert.changed == true
+ - revert['commands'] == rtt['commands']
+
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/vars/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/vars/main.yaml
new file mode 100644
index 000000000..07638f98e
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_global/vars/main.yaml
@@ -0,0 +1,220 @@
+---
+merged:
+ before: {}
+
+ commands:
+ - router bgp 65000
+ - timers bgp 100 200 150
+ - bgp advertise-best-external
+ - bgp bestpath compare-routerid
+ - bgp dampening 1 1 1 1
+ - bgp graceful-shutdown all neighbors 50 local-preference 100 community 100
+ - bgp log-neighbor-changes
+ - bgp nopeerup-delay post-boot 10
+ - neighbor 198.0.2.1 remote-as 100
+ - neighbor 198.0.2.1 description merge neighbor
+ - neighbor 198.0.2.1 aigp send cost-community 100 poi igp-cost transitive
+ - neighbor 198.0.2.1 route-map test-route out
+ - redistribute connected metric 10
+
+ after:
+ as_number: "65000"
+ bgp:
+ advertise_best_external: true
+ bestpath_options:
+ compare_routerid: true
+ dampening:
+ max_suppress: 1
+ penalty_half_time: 1
+ reuse_route_val: 1
+ suppress_route_val: 1
+ graceful_shutdown:
+ community: "100"
+ local_preference: 100
+ neighbors:
+ time: 50
+ log_neighbor_changes: true
+ nopeerup_delay_options:
+ post_boot: 10
+ neighbors:
+ - aigp:
+ send:
+ cost_community:
+ id: 100
+ poi:
+ igp_cost: true
+ transitive: true
+ description: merge neighbor
+ neighbor_address: 198.0.2.1
+ remote_as: "100"
+ route_maps:
+ - name: test-route
+ out: true
+ redistribute:
+ - connected:
+ metric: 10
+ set: true
+ timers:
+ holdtime: 200
+ keepalive: 100
+ min_holdtime: 150
+
+gathered:
+ after:
+ as_number: "65000"
+ bgp:
+ advertise_best_external: true
+ bestpath_options:
+ compare_routerid: true
+ dampening:
+ max_suppress: 1
+ penalty_half_time: 1
+ reuse_route_val: 1
+ suppress_route_val: 1
+ graceful_shutdown:
+ community: "100"
+ local_preference: 100
+ neighbors:
+ time: 50
+ log_neighbor_changes: true
+ nopeerup_delay_options:
+ post_boot: 10
+ neighbors:
+ - aigp:
+ send:
+ cost_community:
+ id: 100
+ poi:
+ igp_cost: true
+ transitive: true
+ description: merge neighbor
+ neighbor_address: 192.0.2.1
+ remote_as: "100"
+ route_maps:
+ - name: test-route
+ out: true
+ redistribute:
+ - connected:
+ metric: 10
+ set: true
+ timers:
+ holdtime: 200
+ keepalive: 100
+ min_holdtime: 150
+
+replaced:
+ commands:
+ - router bgp 65000
+ - no timers bgp 100 200 150
+ - no bgp bestpath compare-routerid
+ - bgp bestpath med confed
+ - no bgp dampening 1 1 1 1
+ - no bgp graceful-shutdown all neighbors 50 local-preference 100 community 100
+ - bgp nopeerup-delay cold-boot 20
+ - neighbor 192.0.2.2 remote-as 100
+ - neighbor 192.0.2.2 description replace neighbor
+ - neighbor 192.0.2.2 slow-peer detection disable
+ - no neighbor 192.0.2.1
+
+ after:
+ as_number: "65000"
+ bgp:
+ advertise_best_external: true
+ bestpath_options:
+ med:
+ confed: true
+ log_neighbor_changes: true
+ nopeerup_delay_options:
+ cold_boot: 20
+ post_boot: 10
+ neighbors:
+ - description: replace neighbor
+ neighbor_address: 192.0.2.2
+ remote_as: "100"
+ slow_peer:
+ detection:
+ disable: true
+ redistribute:
+ - connected:
+ metric: 10
+ set: true
+
+parsed:
+ after:
+ as_number: "65000"
+ bgp:
+ advertise_best_external: true
+ bestpath_options:
+ compare_routerid: true
+ dampening:
+ max_suppress: 1
+ penalty_half_time: 1
+ reuse_route_val: 1
+ suppress_route_val: 1
+ graceful_shutdown:
+ community: "100"
+ local_preference: 100
+ neighbors:
+ time: 50
+ log_neighbor_changes: true
+ nopeerup_delay_options:
+ post_boot: 10
+ neighbors:
+ - aigp:
+ send:
+ cost_community:
+ id: 100
+ poi:
+ igp_cost: true
+ transitive: true
+ description: merge neighbor
+ neighbor_address: 198.0.2.1
+ remote_as: "100"
+ route_maps:
+ - name: test-route
+ out: true
+ redistribute:
+ - connected:
+ metric: 10
+ set: true
+ timers:
+ holdtime: 200
+ keepalive: 100
+ min_holdtime: 150
+
+rendered:
+ commands:
+ - router bgp 65000
+ - timers bgp 100 200 150
+ - bgp advertise-best-external
+ - bgp bestpath compare-routerid
+ - bgp dampening 1 1 1 1
+ - bgp graceful-shutdown all neighbors 50 local-preference 100 community 100
+ - bgp log-neighbor-changes
+ - bgp nopeerup-delay post-boot 10
+ - neighbor 192.0.2.1 remote-as 100
+ - neighbor 192.0.2.1 description merge neighbor
+ - neighbor 192.0.2.1 aigp send cost-community 100 poi igp-cost transitive
+ - neighbor 192.0.2.1 route-map test-route out
+ - redistribute connected metric 10
+
+deleted:
+ commands:
+ - router bgp 65000
+ - no timers bgp 100 200 150
+ - no bgp advertise-best-external
+ - no bgp bestpath compare-routerid
+ - no bgp dampening 1 1 1 1
+ - no bgp graceful-shutdown all neighbors 50 local-preference 100 community 100
+ - no bgp log-neighbor-changes
+ - no bgp nopeerup-delay post-boot 10
+ - no neighbor 192.0.2.1
+ - no redistribute connected
+
+ after:
+ as_number: "65000"
+
+rtt:
+ commands:
+ - router bgp 65000
+ - no network 192.0.4.2
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_cliconf/defaults/main.yml b/ansible_collections/cisco/ios/tests/integration/targets/ios_cliconf/defaults/main.yml
new file mode 100644
index 000000000..164afead2
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_cliconf/defaults/main.yml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_cliconf/meta/main.yml b/ansible_collections/cisco/ios/tests/integration/targets/ios_cliconf/meta/main.yml
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_cliconf/meta/main.yml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_cliconf/tasks/cli.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_cliconf/tasks/cli.yaml
new file mode 100644
index 000000000..86ca0d9cb
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_cliconf/tasks/cli.yaml
@@ -0,0 +1,22 @@
+---
+- name: Collect all CLI test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/common"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: Run test case (connection=ansible.netcommon.network_cli)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.network_cli
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+ tags:
+ - network_cli
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_cliconf/tasks/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_cliconf/tasks/main.yaml
new file mode 100644
index 000000000..4b7d599c6
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_cliconf/tasks/main.yaml
@@ -0,0 +1,5 @@
+---
+- name: Include the CLI tasks
+ ansible.builtin.include_tasks: cli.yaml
+ tags:
+ - network_cli
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_cliconf/tests/common/_cleanup.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_cliconf/tests/common/_cleanup.yaml
new file mode 100644
index 000000000..a4c0d79df
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_cliconf/tests/common/_cleanup.yaml
@@ -0,0 +1,12 @@
+---
+- name: Clean interface configuration
+ cisco.ios.ios_config:
+ lines:
+ - no description
+ parents: "interface {{ interface_name }}"
+
+- name: Clean banner and disable archive
+ cisco.ios.ios_config:
+ lines:
+ - no banner motd
+ - no archive
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_cliconf/tests/common/_enable_archiving.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_cliconf/tests/common/_enable_archiving.yaml
new file mode 100644
index 000000000..2d31449a5
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_cliconf/tests/common/_enable_archiving.yaml
@@ -0,0 +1,7 @@
+---
+- name: Enable archiving
+ cisco.ios.ios_command:
+ commands:
+ - configure terminal
+ - archive
+ - path flash:/
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_cliconf/tests/common/_test_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_cliconf/tests/common/_test_config.yaml
new file mode 100644
index 000000000..e7fad6c14
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_cliconf/tests/common/_test_config.yaml
@@ -0,0 +1,7 @@
+---
+- name: Set banner
+ register: result
+ cisco.ios.ios_config:
+ lines:
+ - banner motd &oh no this shouldnt happen&
+ ignore_errors: true
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_cliconf/tests/common/commit_conf.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_cliconf/tests/common/commit_conf.yaml
new file mode 100644
index 000000000..5bcb085ce
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_cliconf/tests/common/commit_conf.yaml
@@ -0,0 +1,130 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_cliconf integration tests on connection={{ ansible_connection }}
+
+- name: Tests command_timeout greater than commit_confirmed
+ ansible.builtin.include_tasks: _test_config.yaml
+ vars:
+ ansible_command_timeout: 61
+
+- name: Asserts that the result error equals stderr_ansible_command_timeout
+ ansible.builtin.assert:
+ that:
+ - result.module_stderr is defined
+ - result.module_stderr == stderr_ansible_command_timeout
+
+- name: Disable archiving
+ register: result
+ cisco.ios.ios_config:
+ lines:
+ - no archive
+ ignore_errors: true
+
+- name: Test archiving disabled
+ ansible.builtin.include_tasks: _test_config.yaml
+
+- name: Assert that the result error equals std_err_archiving_disabled
+ ansible.builtin.assert:
+ that:
+ - result.module_stderr is defined
+ - result.module_stderr == std_err_archiving_disabled
+
+- name: Enable archiving
+ ansible.builtin.include_tasks: _enable_archiving.yaml
+
+- name: Change hostname with commit_confirm_immediate
+ vars:
+ ios_commit_confirm_immediate: true
+ ios_commit_confirm_timeout: 1
+ cisco.ios.ios_hostname:
+ state: merged
+ config:
+ hostname: testAppliance
+
+- name: Verify hostname
+ register: get_hostname
+ ios_command:
+ commands:
+ - "show running-config | section hostname"
+
+- name: Assert that the hostname is correctly set
+ ansible.builtin.assert:
+ that:
+ - "'testAppliance' in get_hostname.stdout[0]"
+
+- name: Push failed configuration
+ cisco.ios.ios_config:
+ lines:
+ - banner motd &I will be rolled back&
+ - i_will_fail
+ ignore_errors: true
+
+- name: Test rollback change pending message
+ register: result
+ cisco.ios.ios_config:
+ lines:
+ - banner motd &I wont get this far&
+ ignore_errors: true
+
+- name: Assert that the result error equals std_err_rollback_pending
+ ansible.builtin.assert:
+ that:
+ - result.module_stderr is defined
+ - result.module_stderr == std_err_rollback_pending
+
+- name: Manually revert the failed configuration
+ cisco.ios.ios_command:
+ commands:
+ - configure revert now
+
+- name: Test basic commit confirmed operation
+ register: result
+ cisco.ios.ios_interfaces:
+ state: merged
+ config:
+ - name: "{{interface_name}}"
+ description: this is the start description
+
+- name: Test rollback operation. Device will become unreachable
+ register: result
+ cisco.ios.ios_interfaces:
+ state: merged
+ config:
+ - name: "{{interface_name}}"
+ description: this should be rolled back
+ enabled: false
+ ignore_errors: true
+
+- name: Assert that command timeout is triggered as device unreachable
+ ansible.builtin.assert:
+ that:
+ - "'command timeout triggered' in result.module_stderr"
+
+- name: Wait 60 secs for device to become reachable again
+ ansible.builtin.wait_for:
+ timeout: 60
+
+- name: Verify rollback operation
+ register: get_desc
+ ios_command:
+ commands:
+ - "show interfaces {{interface_name}} | include Description"
+
+- name: Assert that the description equals the start description
+ ansible.builtin.assert:
+ that:
+ - "'this is the start description' in get_desc.stdout[0]"
+
+- name: Verify hostname again
+ register: get_hostname_again
+ ios_command:
+ commands:
+ - "show running-config | section hostname"
+
+- name: Assert that the hostname is not rolled back
+ ansible.builtin.assert:
+ that:
+ - "'testAppliance' in get_hostname_again.stdout[0]"
+
+- name: Verify and cleanup
+ ansible.builtin.include_tasks: _cleanup.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_cliconf/vars/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_cliconf/vars/main.yaml
new file mode 100644
index 000000000..802628ee7
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_cliconf/vars/main.yaml
@@ -0,0 +1,21 @@
+---
+# this is the interface of the device that when shut down
+# MUST leave the device unreachable for the tests to succeed.
+interface_name: GigabitEthernet1
+
+# commit_confirmed timers
+ansible_ios_commit_confirm_immediate: true
+ansible_ios_commit_confirm_timeout: 1
+
+# ansible timeouts must be 'sane' with respect to commit timeouts
+ansible_command_timeout: 30
+ansible_connect_timeout: 30
+ansible_connect_retry_timeout: 30
+
+# expected error messages
+stderr_ansible_command_timeout: "ansible_command_timeout can't be greater than
+ commit_confirm_timeout Please adjust and try again"
+std_err_archiving_disabled: "commit_confirm_immediate option set,
+ but archiving not enabled on device. Please set up archiving and try again"
+std_err_rollback_pending: "Existing rollback change already pending.
+ Please resolve by issuing 'configure confirm' or 'configure revert now'"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_command/defaults/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_command/defaults/main.yaml
new file mode 100644
index 000000000..9ef5ba516
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_command/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "*"
+test_items: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_command/meta/main.yml b/ansible_collections/cisco/ios/tests/integration/targets/ios_command/meta/main.yml
new file mode 100644
index 000000000..ab3ad91bc
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_command/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - prepare_ios_tests
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_command/tasks/cli.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_command/tasks/cli.yaml
new file mode 100644
index 000000000..cd8c04990
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_command/tasks/cli.yaml
@@ -0,0 +1,18 @@
+---
+- name: Collect all CLI test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: Run test cases (connection=ansible.netcommon.network_cli)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+ tags: network_cli
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_command/tasks/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_command/tasks/main.yaml
new file mode 100644
index 000000000..b16c8da06
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_command/tasks/main.yaml
@@ -0,0 +1,3 @@
+---
+- name: Main task for command module
+ ansible.builtin.include_tasks: cli.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_command/tests/cli/bad_operator.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_command/tests/cli/bad_operator.yaml
new file mode 100644
index 000000000..b7580d23f
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_command/tests/cli/bad_operator.yaml
@@ -0,0 +1,19 @@
+---
+- ansible.builtin.debug: msg="START cli/bad_operator.yaml on connection={{ ansible_connection }}"
+
+- name: Test bad operator
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_command:
+ commands:
+ - show version
+ - show interfaces GigabitEthernet 0/0
+ wait_for:
+ - "result[0] contains 'Description: Foo'"
+
+- ansible.builtin.assert:
+ that:
+ - result.failed == true
+ - result.msg is defined
+
+- ansible.builtin.debug: msg="END cli/bad_operator.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_command/tests/cli/cli_command.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_command/tests/cli/cli_command.yaml
new file mode 100644
index 000000000..203ba20d7
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_command/tests/cli/cli_command.yaml
@@ -0,0 +1,28 @@
+---
+- ansible.builtin.debug:
+ msg: START cli/cli_command.yaml on connection={{ ansible_connection }}
+
+- block:
+ - name: Get output for single command
+ register: result
+ ansible.netcommon.cli_command:
+ command: show version
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - result.stdout is defined
+
+ - name: Send invalid command
+ register: result
+ ignore_errors: true
+ ansible.netcommon.cli_command:
+ command: show foo
+
+ - ansible.builtin.assert:
+ that:
+ - result.failed == true
+ - result.msg is defined
+ when: ansible_connection == 'ansible.netcommon.network_cli'
+
+- ansible.builtin.debug: msg="END cli/cli_command.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_command/tests/cli/contains.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_command/tests/cli/contains.yaml
new file mode 100644
index 000000000..5421d6700
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_command/tests/cli/contains.yaml
@@ -0,0 +1,19 @@
+---
+- ansible.builtin.debug: msg="START cli/contains.yaml on connection={{ ansible_connection }}"
+
+- name: Test contains operator
+ register: result
+ cisco.ios.ios_command:
+ commands:
+ - show version
+ - show interface loopback 888
+ wait_for:
+ - result[0] contains Cisco
+ - result[1] contains Loopback888
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - result.stdout is defined
+
+- ansible.builtin.debug: msg="END cli/contains.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_command/tests/cli/error_regex.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_command/tests/cli/error_regex.yaml
new file mode 100644
index 000000000..1578073cf
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_command/tests/cli/error_regex.yaml
@@ -0,0 +1,65 @@
+---
+- ansible.builtin.debug: msg="START cli/error_regex.yaml on connection={{ ansible_connection }}"
+
+- block:
+ - name: Clear logs 1
+ ignore_errors: true
+ ansible.netcommon.cli_command: &id001
+ command: clear logging
+ prompt:
+ - Clear logging buffer
+ answer:
+ - "\r"
+
+ - name: Increase log buffer size
+ ansible.netcommon.cli_config:
+ config: logging buffered 9600000
+
+ - name: Send log with error regex match 1
+ ignore_errors: true
+ ansible.netcommon.cli_command: &id002
+ command: "send log 'IPSEC-3-REPLAY_ERROR: test log_1'\n"
+
+ - name: Pause to avoid rate limiting-1
+ ansible.builtin.pause:
+ seconds: 20
+
+ - name: Fetch logs without command specific error regex
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_command:
+ commands:
+ - show logging
+
+ - name: Ensure task fails due to mismatched regex
+ ansible.builtin.assert:
+ that:
+ - result.failed == true
+
+ - name: Pause to avoid rate limiting-2
+ ansible.builtin.pause:
+ seconds: 20
+
+ - name: Clear logs 2
+ ignore_errors: true
+ ansible.netcommon.cli_command: *id001
+ - name: Send log with error regex match 2
+ ignore_errors: true
+ ansible.netcommon.cli_command: *id002
+ - name: Fetch logs with command specific error regex
+ register: result
+ vars:
+ ansible_terminal_stderr_re:
+ - pattern: connection timed out
+ flags: re.I
+ cisco.ios.ios_command:
+ commands:
+ - show logging
+
+ - name: Ensure task with modified error regex is success
+ ansible.builtin.assert:
+ that:
+ - result.failed == false
+ when: ansible_connection == 'ansible.netcommon.network_cli'
+
+- ansible.builtin.debug: msg="END cli/error_regex.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_command/tests/cli/invalid.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_command/tests/cli/invalid.yaml
new file mode 100644
index 000000000..51cba7989
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_command/tests/cli/invalid.yaml
@@ -0,0 +1,26 @@
+---
+- ansible.builtin.debug: msg="START cli/invalid.yaml on connection={{ ansible_connection }}"
+
+- name: Run invalid command
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_command:
+ commands: show foo
+
+- ansible.builtin.assert:
+ that:
+ - result.failed
+
+- name: Run commands that include invalid command
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_command:
+ commands:
+ - show version
+ - show foo
+
+- ansible.builtin.assert:
+ that:
+ - result.failed
+
+- ansible.builtin.debug: msg="END cli/invalid.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_command/tests/cli/output.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_command/tests/cli/output.yaml
new file mode 100644
index 000000000..3d62758a5
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_command/tests/cli/output.yaml
@@ -0,0 +1,28 @@
+---
+- ansible.builtin.debug: msg="START cli/output.yaml on connection={{ ansible_connection }}"
+
+- name: Get output for single command
+ register: result
+ cisco.ios.ios_command:
+ commands:
+ - show version
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - result.stdout is defined
+
+- name: Get output for multiple commands
+ register: result
+ cisco.ios.ios_command:
+ commands:
+ - show version
+ - show interfaces
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - result.stdout is defined
+ - result.stdout | length == 2
+
+- ansible.builtin.debug: msg="END cli/output.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_command/tests/cli/timeout.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_command/tests/cli/timeout.yaml
new file mode 100644
index 000000000..91e147f0f
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_command/tests/cli/timeout.yaml
@@ -0,0 +1,18 @@
+---
+- ansible.builtin.debug: msg="START cli/timeout.yaml on connection={{ ansible_connection }}"
+
+- name: Test bad condition
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_command:
+ commands:
+ - show version
+ wait_for:
+ - result[0] contains bad_value_string
+
+- ansible.builtin.assert:
+ that:
+ - result.failed == true
+ - result.msg is defined
+
+- ansible.builtin.debug: msg="END cli/timeout.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/defaults/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/defaults/main.yaml
new file mode 100644
index 000000000..9ef5ba516
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "*"
+test_items: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/meta/main.yml b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/meta/main.yml
new file mode 100644
index 000000000..ab3ad91bc
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - prepare_ios_tests
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tasks/cli.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tasks/cli.yaml
new file mode 100644
index 000000000..832946029
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tasks/cli.yaml
@@ -0,0 +1,19 @@
+---
+- name: Collect all CLI test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: Run test cases (connection=ansible.netcommon.network_cli)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.network_cli
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tasks/cli_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tasks/cli_config.yaml
new file mode 100644
index 000000000..acafbeca9
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tasks/cli_config.yaml
@@ -0,0 +1,19 @@
+---
+- name: Collect all cli_config test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/cli_config"
+ patterns: "{{ testcase }}.yaml"
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: Run test cases (connection=ansible.netcommon.network_cli)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.network_cli
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tasks/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tasks/main.yaml
new file mode 100644
index 000000000..527765249
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tasks/main.yaml
@@ -0,0 +1,14 @@
+---
+- name: Main task for config module
+ ansible.builtin.include_tasks: cli.yaml
+ tags:
+ - network_cli
+
+- name: Main task for vli_config tasks on config module
+ ansible.builtin.include_tasks: cli_config.yaml
+ tags:
+ - network_cli
+
+- name: Main task for specific Ansible version
+ ansible.builtin.include_tasks: redirection.yaml
+ when: ansible_version.full is version('2.10.0', '>=')
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tasks/redirection.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tasks/redirection.yaml
new file mode 100644
index 000000000..e8bf1c15b
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tasks/redirection.yaml
@@ -0,0 +1,19 @@
+---
+- name: Collect all redirection CLI test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/redirection"
+ patterns: "{{ testcase }}.yaml"
+ register: shortname_test_cases
+ delegate_to: localhost
+
+- name: Set test_items for redirection
+ ansible.builtin.set_fact:
+ test_items: "{{ shortname_test_cases.files | map(attribute='path') | list }}"
+
+- name: Run test case (connection=ansible.netcommon.network_cli)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.network_cli
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/base_running_config b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/base_running_config
new file mode 100644
index 000000000..37254dc96
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/base_running_config
@@ -0,0 +1,9 @@
+version 15.6
+service timestamps debug datetime msec
+service timestamps log datetime msec
+no service password-encryption
+!
+hostname an-ios-01.ansible.com
+!
+boot-start-marker
+boot-end-marker
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/config.j2 b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/config.j2
new file mode 100644
index 000000000..a12725304
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/config.j2
@@ -0,0 +1,3 @@
+interface Loopback999
+ description this is a test
+ shutdown
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/configblock.j2 b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/configblock.j2
new file mode 100644
index 000000000..46150c4d9
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/configblock.j2
@@ -0,0 +1,5 @@
+ip access-list extended test
+ permit ip host 192.0.2.1 any log
+ permit ip host 192.0.2.2 any log
+ permit ip host 192.0.2.3 any log
+ permit ip host 192.0.2.4 any log
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/configexact1.j2 b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/configexact1.j2
new file mode 100644
index 000000000..82ad080c5
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/configexact1.j2
@@ -0,0 +1,6 @@
+no ip access-list extended test
+ip access-list extended test
+ permit ip host 192.0.2.1 any log
+ permit ip host 192.0.2.2 any log
+ permit ip host 192.0.2.3 any log
+ permit ip host 192.0.2.4 any log
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/configexact2.j2 b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/configexact2.j2
new file mode 100644
index 000000000..46150c4d9
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/configexact2.j2
@@ -0,0 +1,5 @@
+ip access-list extended test
+ permit ip host 192.0.2.1 any log
+ permit ip host 192.0.2.2 any log
+ permit ip host 192.0.2.3 any log
+ permit ip host 192.0.2.4 any log
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/configstrict1.j2 b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/configstrict1.j2
new file mode 100644
index 000000000..46150c4d9
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/configstrict1.j2
@@ -0,0 +1,5 @@
+ip access-list extended test
+ permit ip host 192.0.2.1 any log
+ permit ip host 192.0.2.2 any log
+ permit ip host 192.0.2.3 any log
+ permit ip host 192.0.2.4 any log
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/intended_running_config b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/intended_running_config
new file mode 100644
index 000000000..78e844bf0
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/intended_running_config
@@ -0,0 +1,8 @@
+service timestamps debug datetime msec
+service timestamps log datetime msec
+no service password-encryption
+!
+hostname an-ios-02.ansible.com
+!
+boot-start-marker
+boot-end-marker
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/macro.j2 b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/macro.j2
new file mode 100644
index 000000000..44a7a9bdb
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/macro.j2
@@ -0,0 +1,8 @@
+ A12345678 123456789 123456789 123456789 123456789 123456789 123456789
+ B12345678 123456789 123456789 123456789 123456789 123456789 123456789
+ C12345678 123456789 123456789 123456789 123456789 123456789 123456789
+ D12345678 123456789 123456789 123456789 123456789 123456789 123456789
+ E12345678 123456789 123456789 123456789 123456789 123456789 123456789
+ F12345678 123456789 123456789 123456789 123456789 123456789 123456789
+ G12345678 123456789 123456789 123456789 123456789 123456789 123456789
+ H12345678 123456789 123456789 123456789 123456789 123456789 123456789
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/setupblock.j2 b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/setupblock.j2
new file mode 100644
index 000000000..f57aa49b7
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/setupblock.j2
@@ -0,0 +1,5 @@
+no ip access-list extended test
+ip access-list extended test
+ permit ip host 192.0.2.1 any log
+ permit ip host 192.0.2.2 any log
+ permit ip host 192.0.2.3 any log
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/setupexact.j2 b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/setupexact.j2
new file mode 100644
index 000000000..e8791e272
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/setupexact.j2
@@ -0,0 +1,7 @@
+no ip access-list extended test
+ip access-list extended test
+ permit ip host 192.0.2.1 any log
+ permit ip host 192.0.2.2 any log
+ permit ip host 192.0.2.3 any log
+ permit ip host 192.0.2.4 any log
+ permit ip host 192.0.2.5 any log
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/setupstrict.j2 b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/setupstrict.j2
new file mode 100644
index 000000000..e8791e272
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/setupstrict.j2
@@ -0,0 +1,7 @@
+no ip access-list extended test
+ip access-list extended test
+ permit ip host 192.0.2.1 any log
+ permit ip host 192.0.2.2 any log
+ permit ip host 192.0.2.3 any log
+ permit ip host 192.0.2.4 any log
+ permit ip host 192.0.2.5 any log
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/defaults/config.j2 b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/defaults/config.j2
new file mode 100644
index 000000000..92f35da87
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/defaults/config.j2
@@ -0,0 +1,3 @@
+interface Loopback999
+ description this is a test
+ no shutdown
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/backup.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/backup.yaml
new file mode 100644
index 000000000..92976e58d
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/backup.yaml
@@ -0,0 +1,68 @@
+---
+- ansible.builtin.debug: msg="START cli/cli_backup.yaml on connection={{ ansible_connection }}"
+
+- name: Setup
+ cisco.ios.ios_config:
+ commands:
+ - no description
+ - no shutdown
+ parents:
+ - interface Loopback999
+ match: none
+
+- name: Configure device with configuration
+ register: result
+ cisco.ios.ios_config:
+ src: basic/config.j2
+ backup: true
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+
+- name: Delete configurable backup file path
+ ansible.builtin.file:
+ path: "{{ item }}"
+ state: absent
+ with_items:
+ - "{{ role_path }}/backup_test_dir/"
+ - "{{ role_path }}/backup/backup.cfg"
+
+- name: Take configuration backup in custom filename and directory path
+ become: true
+ register: result
+ cisco.ios.ios_config:
+ backup: true
+ backup_options:
+ filename: backup.cfg
+ dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+
+- name: Take configuration backup in custom filename
+ become: true
+ register: result
+ cisco.ios.ios_config:
+ backup: true
+ backup_options:
+ filename: backup.cfg
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+
+- name: Take configuration backup in custom path and default filename
+ become: true
+ register: result
+ cisco.ios.ios_config:
+ backup: true
+ backup_options:
+ dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+
+- ansible.builtin.debug: msg="END cli/cli_backup.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/defaults.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/defaults.yaml
new file mode 100644
index 000000000..f84fb49e4
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/defaults.yaml
@@ -0,0 +1,67 @@
+---
+- ansible.builtin.debug: msg="START cli/defaults.yaml on connection={{ ansible_connection }}"
+
+- name: Setup
+ cisco.ios.ios_config:
+ commands:
+ - no description
+ - shutdown
+ parents:
+ - interface Loopback999
+ match: none
+
+- name: Configure device with defaults included
+ register: result
+ cisco.ios.ios_config:
+ src: defaults/config.j2
+ defaults: true
+
+- ansible.builtin.debug: var=result
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+
+- name: Check device with defaults included
+ register: result
+ cisco.ios.ios_config:
+ src: defaults/config.j2
+ defaults: true
+
+- ansible.builtin.debug: var=result
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - result.updates is not defined
+
+- name: Check device is in proper prompt after error
+ ignore_errors: true
+ cisco.ios.ios_config:
+ lines:
+ - mac-address-table notification mac-move
+
+- name: Show interfaces brief to ensure device goes to valid prompt
+ register: result
+ cisco.ios.ios_command:
+ commands:
+ - show interfaces
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - result.stdout is defined
+
+- name: Validate terminal error regex
+ ios_config:
+ lines:
+ - switchport private-vlan mapping 10 6000
+ parents: interface GigabitEthernet2
+ register: result
+ ignore_errors: true
+
+- ansible.builtin.assert:
+ that:
+ - result.failed == True
+
+- ansible.builtin.debug: msg="END cli/defaults.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/diff.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/diff.yaml
new file mode 100644
index 000000000..0c504c160
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/diff.yaml
@@ -0,0 +1,33 @@
+---
+- ansible.builtin.debug: msg="START cli/diff.yaml on connection={{ ansible_connection }}"
+
+- name: Ensure hostname is preset
+ cisco.ios.ios_system:
+ hostname: "{{ shorter_hostname }}"
+
+- name: Ios_config diff against retrieved configuration
+ diff: true
+ register: result
+ cisco.ios.ios_config:
+ diff_against: intended
+ intended_config: "{{ lookup('file', '{{ role_path }}/templates/basic/intended_running_config') }}"
+
+- ansible.builtin.assert:
+ that:
+ - "'hostname an-ios-02.ansible.com' in result['diff']['after']"
+ # - "'hostname {{ shorter_hostname }}' in result['diff']['before']"
+
+- name: Ios_config diff against provided running_config
+ diff: true
+ register: result
+ cisco.ios.ios_config:
+ diff_against: intended
+ intended_config: "{{ lookup('file', '{{ role_path }}/templates/basic/intended_running_config') }}"
+ running_config: "{{ lookup('file', '{{ role_path }}/templates/basic/base_running_config') }}"
+
+- ansible.builtin.assert:
+ that:
+ - "'hostname an-ios-02.ansible.com' in result['diff']['after']"
+ - "'hostname an-ios-01.ansible.com' in result['diff']['before']"
+
+- ansible.builtin.debug: msg="END cli/diff.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/macro.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/macro.yaml
new file mode 100644
index 000000000..b01bcfcf2
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/macro.yaml
@@ -0,0 +1,62 @@
+---
+- ansible.builtin.debug: msg="START cli/cli_macro.yaml on connection={{ ansible_connection }}"
+
+- name: Check for macro support
+ register: supports_macro
+ ignore_errors: true
+ cisco.ios.ios_command:
+ commands:
+ - show parser macro brief
+
+- name: Ios_config macro integration tests
+ when: supports_macro is succeeded
+ block:
+ - name: Define macro name
+ ansible.builtin.set_fact:
+ macro_name: MACRO_ANSIBLE_TEST
+
+ - name: Setup - remove configuration
+ cisco.ios.ios_config:
+ lines:
+ - no macro name {{ macro_name }}
+ - do show clock
+ match: none
+
+ - name: Configure macro
+ register: result
+ cisco.ios.ios_config:
+ parents: macro name {{ macro_name }}
+ multiline_delimiter: "@"
+ after: "@"
+ match: line
+ replace: block
+ lines: "{{ lookup('template', 'basic/macro.j2') }}"
+
+ - name: Check if macro has been added
+ ansible.builtin.assert:
+ that:
+ - result.changed == true
+
+ - name: Configure macro again - idempotent check
+ register: result
+ cisco.ios.ios_config:
+ parents: macro name {{ macro_name }}
+ multiline_delimiter: "@"
+ after: "@"
+ match: line
+ replace: block
+ lines: "{{ lookup('template', 'basic/macro.j2') }}"
+
+ - name: Macro already/correctly configured ?
+ ansible.builtin.assert:
+ that:
+ - result.changed == false
+ always:
+ - name: Teardown
+ cisco.ios.ios_config:
+ lines:
+ - no macro name {{ macro_name }}
+ - do show clock
+ match: none
+
+- ansible.builtin.debug: msg="END cli/cli_macro.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/save.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/save.yaml
new file mode 100644
index 000000000..604259715
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/save.yaml
@@ -0,0 +1,49 @@
+---
+- ansible.builtin.debug: msg="START cli/save.yaml on connection={{ ansible_connection }}"
+
+- name: Setup
+ cisco.ios.ios_config:
+ commands:
+ - no description
+ - no shutdown
+ parents:
+ - interface Loopback999
+ match: none
+ save_when: modified
+
+- name: Save should always run
+ register: result
+ cisco.ios.ios_config:
+ save_when: always
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+
+- name: Delete configuration (setup)
+ register: result
+ cisco.ios.ios_config:
+ replace: line
+ lines:
+ - no ip http server
+ save_when: modified
+
+- name: Save should run when changed
+ register: result
+ cisco.ios.ios_config:
+ replace: line
+ lines:
+ - ip http server
+ save_when: modified
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+
+- name: Teardown
+ register: result
+ cisco.ios.ios_config:
+ lines:
+ - no ip http server
+
+- ansible.builtin.debug: msg="END cli/save.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/src_basic.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/src_basic.yaml
new file mode 100644
index 000000000..fbfdc344c
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/src_basic.yaml
@@ -0,0 +1,62 @@
+---
+- ansible.builtin.debug: msg="START cli/src_basic.yaml on connection={{ ansible_connection }}"
+
+- name: Setup
+ cisco.ios.ios_config:
+ commands:
+ - no description
+ - no shutdown
+ parents:
+ - interface Loopback999
+ match: none
+
+- name: Configure device with configuration
+ register: result
+ cisco.ios.ios_config:
+ src: basic/config.j2
+
+- name: Debug, remove me
+ ansible.builtin.debug:
+ msg: "{{ result }}"
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+
+- name: Check device with configuration
+ register: result
+ cisco.ios.ios_config:
+ src: basic/config.j2
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+- name: Check for empty diff
+ check_mode: true
+ register: result
+ cisco.ios.ios_config:
+ running_config: "service timestamps debug datetime msec\nservice timestamps log datetime msec\n"
+ lines:
+ - service timestamps debug datetime msec
+ - service timestamps log datetime msec
+
+- ansible.builtin.assert:
+ that:
+ - result.updates is undefined
+
+- name: Check for diff with ignore lines for running configuration
+ check_mode: true
+ register: result
+ cisco.ios.ios_config:
+ running_config: "service timestamps debug datetime msec\nservice timestamps log datetime msec\n"
+ lines:
+ - service timestamps debug datetime msec
+ - service timestamps log datetime msec
+ diff_ignore_lines: service timestamps log datetime msec
+
+- ansible.builtin.assert:
+ that:
+ - "'service timestamps log datetime msec' in result.updates"
+
+- ansible.builtin.debug: msg="END cli/src_basic.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/src_invalid.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/src_invalid.yaml
new file mode 100644
index 000000000..adae8a39b
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/src_invalid.yaml
@@ -0,0 +1,16 @@
+---
+- ansible.builtin.debug: msg="START cli/src_invalid.yaml on connection={{ ansible_connection }}"
+
+- name: Configure with invalid src
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_config:
+ src: basic/foobar.j2
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - result.failed == true
+ - result.msg == 'path specified in src not found'
+
+- ansible.builtin.debug: msg="END cli/src_invalid.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/src_match_none.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/src_match_none.yaml
new file mode 100644
index 000000000..d65c7a8fe
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/src_match_none.yaml
@@ -0,0 +1,33 @@
+---
+- ansible.builtin.debug: msg="START cli/src_match_none.yaml on connection={{ ansible_connection }}"
+
+- name: Setup
+ cisco.ios.ios_config:
+ commands:
+ - no description
+ - no shutdown
+ parents:
+ - interface Loopback999
+ match: none
+
+- name: Configure device with configuration
+ register: result
+ cisco.ios.ios_config:
+ src: basic/config.j2
+ match: none
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+
+- name: Check device with configuration
+ register: result
+ cisco.ios.ios_config:
+ src: basic/config.j2
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - result.updates is not defined
+
+- ansible.builtin.debug: msg="END cli/src_match_none.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/sublevel.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/sublevel.yaml
new file mode 100644
index 000000000..c0a271b7f
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/sublevel.yaml
@@ -0,0 +1,43 @@
+---
+- ansible.builtin.debug: msg="START cli/sublevel.yaml on connection={{ ansible_connection }}"
+
+- name: Setup test
+ cisco.ios.ios_config:
+ lines:
+ - no ip access-list extended test
+ - no ip access-list standard test
+ match: none
+
+- name: Configure sub level command
+ register: result
+ cisco.ios.ios_config:
+ lines:
+ - permit ip any any log
+ parents:
+ - ip access-list extended test
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - "'ip access-list extended test' in result.updates"
+ - "'permit ip any any log' in result.updates"
+
+- name: Configure sub level command idempotent check
+ register: result
+ cisco.ios.ios_config:
+ lines:
+ - permit ip any any log
+ parents:
+ - ip access-list extended test
+
+# - ansible.builtin.assert:
+# that:
+# - result.changed == false
+
+- name: Teardown
+ cisco.ios.ios_config:
+ lines:
+ - no ip access-list extended test
+ match: none
+
+- ansible.builtin.debug: msg="END cli/sublevel.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/sublevel_block.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/sublevel_block.yaml
new file mode 100644
index 000000000..72f7ee360
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/sublevel_block.yaml
@@ -0,0 +1,65 @@
+---
+- ansible.builtin.debug: msg="START cli/sublevel_block.yaml on connection={{ ansible_connection }}"
+
+- name: Setup
+ cisco.ios.ios_config:
+ lines:
+ - permit ip host 192.0.2.1 any log
+ - permit ip host 192.0.2.2 any log
+ - permit ip host 192.0.2.3 any log
+ parents:
+ - ip access-list extended test
+ before:
+ - no ip access-list extended test
+ after:
+ - exit
+ match: none
+
+- name: Configure sub level command using block replace
+ register: result
+ cisco.ios.ios_config:
+ lines:
+ - permit ip host 192.0.2.1 any log
+ - permit ip host 192.0.2.2 any log
+ - permit ip host 192.0.2.3 any log
+ - permit ip host 192.0.2.4 any log
+ parents:
+ - ip access-list extended test
+ replace: block
+ after:
+ - exit
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - "'ip access-list extended test' in result.updates"
+ - "'permit ip host 192.0.2.1 any log' in result.updates"
+ - "'permit ip host 192.0.2.2 any log' in result.updates"
+ - "'permit ip host 192.0.2.3 any log' in result.updates"
+ - "'permit ip host 192.0.2.4 any log' in result.updates"
+
+- name: Check sub level command using block replace
+ register: result
+ cisco.ios.ios_config:
+ lines:
+ - permit ip host 192.0.2.1 any log
+ - permit ip host 192.0.2.2 any log
+ - permit ip host 192.0.2.3 any log
+ - permit ip host 192.0.2.4 any log
+ parents:
+ - ip access-list extended test
+ replace: block
+ after:
+ - exit
+
+# - ansible.builtin.assert:
+# that:
+# - result.changed == false
+
+- name: Teardown
+ cisco.ios.ios_config:
+ lines:
+ - no ip access-list extended test
+ match: none
+
+- ansible.builtin.debug: msg="END cli/sublevel_block.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/sublevel_exact.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/sublevel_exact.yaml
new file mode 100644
index 000000000..39e29692b
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/sublevel_exact.yaml
@@ -0,0 +1,61 @@
+---
+- ansible.builtin.debug: msg="START cli/sublevel_exact.yaml on connection={{ ansible_connection }}"
+
+- name: Setup
+ cisco.ios.ios_config:
+ lines:
+ - permit ip host 192.0.2.1 any log
+ - permit ip host 192.0.2.2 any log
+ - permit ip host 192.0.2.3 any log
+ - permit ip host 192.0.2.4 any log
+ - permit ip host 192.0.2.5 any log
+ parents: ip access-list extended test
+ before: no ip access-list extended test
+ after: exit
+ match: none
+
+- name: Configure sub level command using exact match
+ register: result
+ cisco.ios.ios_config:
+ lines:
+ - permit ip host 192.0.2.1 any log
+ - permit ip host 192.0.2.2 any log
+ - permit ip host 192.0.2.3 any log
+ - permit ip host 192.0.2.4 any log
+ parents: ip access-list extended test
+ before: no ip access-list extended test
+ after: exit
+ match: exact
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - "'ip access-list extended test' in result.updates"
+ - "'permit ip host 192.0.2.1 any log' in result.updates"
+ - "'permit ip host 192.0.2.2 any log' in result.updates"
+ - "'permit ip host 192.0.2.3 any log' in result.updates"
+ - "'permit ip host 192.0.2.4 any log' in result.updates"
+ - "'permit ip host 192.0.2.5 any log' not in result.updates"
+
+- name: Check sub level command using exact match
+ register: result
+ cisco.ios.ios_config:
+ lines:
+ - permit ip host 192.0.2.1 any log
+ - permit ip host 192.0.2.2 any log
+ - permit ip host 192.0.2.3 any log
+ - permit ip host 192.0.2.4 any log
+ parents: ip access-list extended test
+ match: exact
+
+# - ansible.builtin.assert:
+# that:
+# - result.changed == false
+
+- name: Teardown
+ cisco.ios.ios_config:
+ lines:
+ - no ip access-list extended test
+ match: none
+
+- ansible.builtin.debug: msg="END cli/sublevel_exact.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/sublevel_strict.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/sublevel_strict.yaml
new file mode 100644
index 000000000..1976f2424
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/sublevel_strict.yaml
@@ -0,0 +1,57 @@
+---
+- ansible.builtin.debug: msg="START cli/sublevel_strict.yaml on connection={{ ansible_connection }}"
+
+- name: Setup
+ cisco.ios.ios_config:
+ lines:
+ - permit ip host 192.0.2.1 any log
+ - permit ip host 192.0.2.2 any log
+ - permit ip host 192.0.2.3 any log
+ - permit ip host 192.0.2.4 any log
+ - permit ip host 192.0.2.5 any log
+ parents: ip access-list extended test
+ before: no ip access-list extended test
+ match: none
+
+- name: Configure sub level command using strict match
+ register: result
+ cisco.ios.ios_config:
+ lines:
+ - permit ip host 192.0.2.1 any log
+ - permit ip host 192.0.2.2 any log
+ - permit ip host 192.0.2.3 any log
+ - permit ip host 192.0.2.4 any log
+ parents: ip access-list extended test
+ match: strict
+
+# - ansible.builtin.assert:
+# that:
+# - result.changed == false
+
+- name: Check sub level command using strict match
+ register: result
+ cisco.ios.ios_config:
+ lines:
+ - permit ip host 192.0.2.1 any log
+ - permit ip host 192.0.2.3 any log
+ - permit ip host 192.0.2.2 any log
+ parents: ip access-list extended test
+ after: exit
+ match: strict
+
+# - ansible.builtin.assert:
+# that:
+# - result.changed == true
+# - "'ip access-list extended test' in result.updates"
+# - "'permit ip host 192.0.2.1 any log' not in result.updates"
+# - "'permit ip host 192.0.2.2 any log' in result.updates"
+# - "'permit ip host 192.0.2.3 any log' in result.updates"
+# - "'permit ip host 192.0.2.4 any log' not in result.updates"
+# - "'permit ip host 192.0.2.5 any log' not in result.updates"
+
+- name: Teardown
+ cisco.ios.ios_config:
+ lines: no ip access-list extended test
+ match: none
+
+- ansible.builtin.debug: msg="END cli/sublevel_strict.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/sublevel_strict_mul_parents.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/sublevel_strict_mul_parents.yaml
new file mode 100644
index 000000000..e1af72331
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/sublevel_strict_mul_parents.yaml
@@ -0,0 +1,72 @@
+---
+- ansible.builtin.debug: msg="START cli/sublevel_strict_mul_parents.yaml on connection={{ ansible_connection }}"
+
+- name: Setup
+ cisco.ios.ios_config:
+ lines:
+ - class-map c1
+ - match precedence 7
+ - policy-map p1
+ - class c1
+ before:
+ - no policy-map p1
+ - no class-map c1
+ match: none
+
+- name: Configure sub level command using strict match
+ register: result
+ cisco.ios.ios_config:
+ lines:
+ - set ip precedence 5
+ - police cir percent 10
+ parents:
+ - policy-map p1
+ - class c1
+ match: strict
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - "'set ip precedence 5' in result.updates"
+ - "'police cir percent 10' in result.updates"
+
+- name: Change sub level command order and configuration with strict match
+ register: result
+ cisco.ios.ios_config:
+ lines:
+ - police cir percent 10
+ - set ip precedence 5
+ parents:
+ - policy-map p1
+ - class c1
+ match: strict
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - "'set ip precedence 5' in result.updates"
+ - "'police cir percent 10' in result.updates"
+
+- name: Config sub level command with strict match (idempotent)
+ register: result
+ cisco.ios.ios_config:
+ lines:
+ - set ip precedence 5
+ - police cir percent 10
+ parents:
+ - policy-map p1
+ - class c1
+ match: strict
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+- name: Teardown
+ cisco.ios.ios_config:
+ lines:
+ - no policy-map p1
+ - no class-map c1
+ match: none
+
+- ansible.builtin.debug: msg="END cli/sublevel_strict_mul_parents.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/toplevel.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/toplevel.yaml
new file mode 100644
index 000000000..072566724
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/toplevel.yaml
@@ -0,0 +1,37 @@
+---
+- ansible.builtin.debug: msg="START cli/toplevel.yaml on connection={{ ansible_connection }}"
+
+- name: Setup
+ cisco.ios.ios_config:
+ lines:
+ - hostname {{ shorter_hostname }}
+ match: none
+
+- name: Configure top level command
+ register: result
+ cisco.ios.ios_config:
+ lines:
+ - hostname foo
+
+# - ansible.builtin.assert:
+# that:
+# - result.changed == true
+# - "'hostname foo' in result.updates"
+
+- name: Configure top level command idempotent check
+ register: result
+ cisco.ios.ios_config:
+ lines:
+ - hostname foo
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+- name: Teardown
+ cisco.ios.ios_config:
+ lines:
+ - hostname {{ shorter_hostname }}
+ match: none
+
+- ansible.builtin.debug: msg="END cli/toplevel.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/toplevel_after.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/toplevel_after.yaml
new file mode 100644
index 000000000..db9a9fcb9
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/toplevel_after.yaml
@@ -0,0 +1,44 @@
+---
+- ansible.builtin.debug: msg="START cli/toplevel_after.yaml on connection={{ ansible_connection }}"
+
+- name: Setup
+ cisco.ios.ios_config:
+ lines:
+ - snmp-server contact ansible
+ - hostname {{ shorter_hostname }}
+ match: none
+
+- name: Configure top level command with before
+ register: result
+ cisco.ios.ios_config:
+ lines:
+ - hostname foo
+ after:
+ - snmp-server contact bar
+
+# - ansible.builtin.assert:
+# that:
+# - result.changed == true
+# - "'hostname foo' in result.updates"
+# - "'snmp-server contact bar' in result.updates"
+
+- name: Configure top level command with before idempotent check
+ register: result
+ cisco.ios.ios_config:
+ lines:
+ - hostname foo
+ after:
+ - snmp-server contact foo
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+- name: Teardown
+ cisco.ios.ios_config:
+ lines:
+ - no snmp-server contact
+ - hostname {{ shorter_hostname }}
+ match: none
+
+- ansible.builtin.debug: msg="END cli/toplevel_after.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/toplevel_before.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/toplevel_before.yaml
new file mode 100644
index 000000000..6781daa0b
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/toplevel_before.yaml
@@ -0,0 +1,44 @@
+---
+- ansible.builtin.debug: msg="START cli/toplevel_before.yaml on connection={{ ansible_connection }}"
+
+- name: Setup
+ cisco.ios.ios_config:
+ lines:
+ - snmp-server contact ansible
+ - hostname {{ shorter_hostname }}
+ match: none
+
+- name: Configure top level command with before
+ register: result
+ cisco.ios.ios_config:
+ lines:
+ - hostname foo
+ before:
+ - snmp-server contact bar
+
+# - ansible.builtin.assert:
+# that:
+# - result.changed == true
+# - "'hostname foo' in result.updates"
+# - "'snmp-server contact bar' in result.updates"
+
+- name: Configure top level command with before idempotent check
+ register: result
+ cisco.ios.ios_config:
+ lines:
+ - hostname foo
+ before:
+ - snmp-server contact foo
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+- name: Teardown
+ cisco.ios.ios_config:
+ lines:
+ - no snmp-server contact
+ - hostname {{ shorter_hostname }}
+ match: none
+
+- ansible.builtin.debug: msg="END cli/toplevel_before.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/toplevel_nonidempotent.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/toplevel_nonidempotent.yaml
new file mode 100644
index 000000000..910a5dfd6
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/toplevel_nonidempotent.yaml
@@ -0,0 +1,39 @@
+---
+- ansible.builtin.debug: msg="START cli/toplevel_nonidempotent.yaml on connection={{ ansible_connection }}"
+
+- name: Setup
+ cisco.ios.ios_config:
+ lines:
+ - hostname {{ shorter_hostname }}
+ match: none
+
+- name: Configure top level command
+ register: result
+ cisco.ios.ios_config:
+ lines:
+ - hostname foo
+ match: strict
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - "'hostname foo' in result.updates"
+
+- name: Configure top level command idempotent check
+ register: result
+ cisco.ios.ios_config:
+ lines:
+ - hostname foo
+ match: strict
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+
+- name: Teardown
+ cisco.ios.ios_config:
+ lines:
+ - hostname {{ shorter_hostname }}
+ match: none
+
+- ansible.builtin.debug: msg="END cli/toplevel_nonidempotent.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli_config/cli_backup.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli_config/cli_backup.yaml
new file mode 100644
index 000000000..acfa2cc36
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli_config/cli_backup.yaml
@@ -0,0 +1,59 @@
+---
+- ansible.builtin.debug: msg="END cli_config/backup.yaml on connection={{ ansible_connection }}"
+
+- name: Delete configurable backup file path
+ ansible.builtin.file:
+ path: "{{ item }}"
+ state: absent
+ with_items:
+ - "{{ role_path }}/backup_test_dir/"
+ - "{{ role_path }}/backup/backup.cfg"
+
+- name: Take configuration backup
+ become: true
+ register: result
+ ansible.netcommon.cli_config:
+ backup: true
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+
+- name: Take configuration backup in custom filename and directory path
+ become: true
+ register: result
+ ansible.netcommon.cli_config:
+ backup: true
+ backup_options:
+ filename: backup.cfg
+ dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+
+- name: Take configuration backup in custom filename
+ become: true
+ register: result
+ ansible.netcommon.cli_config:
+ backup: true
+ backup_options:
+ filename: backup.cfg
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+
+- name: Take configuration backup in custom path and default filename
+ become: true
+ register: result
+ ansible.netcommon.cli_config:
+ backup: true
+ backup_options:
+ dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+
+- ansible.builtin.debug: msg="END cli_config/backup.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli_config/cli_basic.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli_config/cli_basic.yaml
new file mode 100644
index 000000000..17eb030eb
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli_config/cli_basic.yaml
@@ -0,0 +1,39 @@
+---
+- ansible.builtin.debug: msg="START cli_config/cli_basic.yaml on connection={{ ansible_connection }}"
+
+- name: Setup
+ ansible.netcommon.cli_config: &id002
+ config: "interface loopback999\nno description\nshutdown\n"
+ diff_match: none
+
+- name: Configure device with configuration
+ register: result
+ ansible.netcommon.cli_config: &id001
+ config: "{{ lookup('template', 'basic/config.j2') }}"
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+
+- name: Idempotence
+ register: result
+ ansible.netcommon.cli_config: *id001
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+- name: Remove configuration
+ ansible.netcommon.cli_config: *id002
+- name: Configure device with configuration
+ register: result
+ ansible.netcommon.cli_config:
+ config: "{{ lookup('template', 'basic/config.j2') }}"
+ defaults: true
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+
+- name: Teardown
+ ansible.netcommon.cli_config: *id002
+- ansible.builtin.debug: msg="END cli_config/cli_basic.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli_config/cli_block_replace.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli_config/cli_block_replace.yaml
new file mode 100644
index 000000000..4b485ee30
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli_config/cli_block_replace.yaml
@@ -0,0 +1,32 @@
+---
+- ansible.builtin.debug: msg="START cli_config/cli_block_replace.yaml on connection={{ ansible_connection }}"
+
+- name: Setup - remove configuration
+ ansible.netcommon.cli_config:
+ config: "{{ lookup('template', 'basic/setupblock.j2') }}"
+ diff_match: none
+
+- name: Block replace
+ register: result
+ ansible.netcommon.cli_config: &id001
+ config: "{{ lookup('template', 'basic/configblock.j2') }}"
+ diff_replace: block
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+
+- name: Block replace (idempotence)
+ register: result
+ ansible.netcommon.cli_config: *id001
+
+# - ansible.builtin.assert:
+# that:
+# - result.changed == false
+
+- name: Teardown
+ ansible.netcommon.cli_config:
+ config: no ip access-list extended test
+ diff_match: none
+
+- ansible.builtin.debug: msg="END cli_config/cli_block_replace.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli_config/cli_exact_match.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli_config/cli_exact_match.yaml
new file mode 100644
index 000000000..5ec393504
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli_config/cli_exact_match.yaml
@@ -0,0 +1,33 @@
+---
+- ansible.builtin.debug: msg="START cli_config/cli_exact_match.yaml on connection={{ ansible_connection }}"
+
+- name: Setup - remove configuration
+ ansible.netcommon.cli_config:
+ config: "{{ lookup('template', 'basic/setupexact.j2') }}"
+ diff_match: none
+
+- name: Configure using exact match
+ register: result
+ ansible.netcommon.cli_config:
+ config: "{{ lookup('template', 'basic/configexact1.j2') }}"
+ diff_match: exact
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+
+- name: Check using exact match
+ register: result
+ ansible.netcommon.cli_config:
+ config: "{{ lookup('template', 'basic/configexact2.j2') }}"
+
+# - ansible.builtin.assert:
+# that:
+# - result.changed == false
+
+- name: Teardown
+ ansible.netcommon.cli_config:
+ config: no ip access-list extended test
+ diff_match: none
+
+- ansible.builtin.debug: msg="END cli_config/cli_exact_match.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli_config/cli_strict_match.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli_config/cli_strict_match.yaml
new file mode 100644
index 000000000..38ec39f79
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli_config/cli_strict_match.yaml
@@ -0,0 +1,24 @@
+---
+- ansible.builtin.debug: msg="START cli_config/cli_strict_match.yaml on connection={{ ansible_connection }}"
+
+- name: Setup - remove configuration
+ ansible.netcommon.cli_config:
+ config: "{{ lookup('template', 'basic/setupstrict.j2') }}"
+ diff_match: none
+
+- name: Configure using strict match
+ register: result
+ ansible.netcommon.cli_config:
+ config: "{{ lookup('template', 'basic/configstrict1.j2') }}"
+ diff_match: strict
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+
+- name: Teardown
+ ansible.netcommon.cli_config:
+ config: no ip access-list extended test
+ diff_match: none
+
+- ansible.builtin.debug: msg="END cli_config/cli_strict_match.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/redirection/shortname.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/redirection/shortname.yaml
new file mode 100644
index 000000000..885ee78a3
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/redirection/shortname.yaml
@@ -0,0 +1,27 @@
+---
+- ansible.builtin.debug: msg="START cli/shortname.yaml on connection={{ ansible_connection }}"
+
+- name: Use src with module alias
+ register: result
+ cisco.ios.config:
+ src: basic/config.j2
+
+- ansible.builtin.assert:
+ that:
+ # make sure that the template content was read and not the path
+ - result.changed == true
+ - result.updates is defined
+
+- name: Use module alias to take configuration backup
+ register: result
+ cisco.ios.config:
+ backup: true
+ backup_options:
+ filename: backup_with_alias.cfg
+ dir_path: "{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}"
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+
+- ansible.builtin.debug: msg="END cli/shortname.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_facts/defaults/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_facts/defaults/main.yaml
new file mode 100644
index 000000000..9ef5ba516
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_facts/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "*"
+test_items: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_facts/meta/main.yml b/ansible_collections/cisco/ios/tests/integration/targets/ios_facts/meta/main.yml
new file mode 100644
index 000000000..ab3ad91bc
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_facts/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - prepare_ios_tests
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_facts/tasks/cli.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_facts/tasks/cli.yaml
new file mode 100644
index 000000000..cd8c04990
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_facts/tasks/cli.yaml
@@ -0,0 +1,18 @@
+---
+- name: Collect all CLI test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: Run test cases (connection=ansible.netcommon.network_cli)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+ tags: network_cli
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_facts/tasks/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_facts/tasks/main.yaml
new file mode 100644
index 000000000..90baa4e36
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_facts/tasks/main.yaml
@@ -0,0 +1,3 @@
+---
+- name: Main task for facts module
+ ansible.builtin.include_tasks: cli.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_facts/tests/cli/all_facts.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_facts/tests/cli/all_facts.yaml
new file mode 100644
index 000000000..1358a9ad2
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_facts/tests/cli/all_facts.yaml
@@ -0,0 +1,63 @@
+---
+- ansible.builtin.debug: msg="START cli/all_facts.yaml on connection={{ ansible_connection }}"
+
+- name: Test getting all facts
+ register: result
+ cisco.ios.ios_facts:
+ gather_subset:
+ - all
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - "'config' in result.ansible_facts.ansible_net_gather_subset"
+ - "'hardware' in result.ansible_facts.ansible_net_gather_subset"
+ - "'default' in result.ansible_facts.ansible_net_gather_subset"
+ - "'interfaces' in result.ansible_facts.ansible_net_gather_subset"
+ - result.ansible_facts.ansible_net_filesystems is defined
+ - result.ansible_facts.ansible_net_memfree_mb > 1
+ - result.ansible_facts.ansible_net_memtotal_mb > 1
+
+- ansible.builtin.assert:
+ that: "{{ item.value.spacetotal_kb }} > {{ item.value.spacefree_kb }}"
+ loop: "{{ lookup('dict', result.ansible_facts.ansible_net_filesystems_info, wantlist=True) }}"
+
+- ansible.builtin.set_fact:
+ supported_network_resources:
+ - interfaces
+ - l2_interfaces
+ - vlans
+ - lag_interfaces
+ - lacp
+ - lacp_interfaces
+ - lldp_global
+ - lldp_interfaces
+ - l3_interfaces
+ - logging_global
+ - acl_interfaces
+ - static_routes
+ - acls
+ - ospfv2
+ - ospfv3
+ - ospf_interfaces
+ - bgp_global
+ - bgp_address_family
+ - route_maps
+ - snmp_server
+ - prefix_lists
+ - ntp_global
+ - service
+ - hostname
+
+- name: Collect list of available network resources for IOS
+ register: result
+ cisco.ios.ios_facts:
+ available_network_resources: true
+
+- name: Assert that correct available_network_resources returned
+ ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - "{{ result['ansible_facts']['available_network_resources'] | symmetric_difference(supported_network_resources) |length == 0 }}"
+
+- ansible.builtin.debug: msg="END cli/all_facts.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_facts/tests/cli/default_facts.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_facts/tests/cli/default_facts.yaml
new file mode 100644
index 000000000..7dc4dfc1e
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_facts/tests/cli/default_facts.yaml
@@ -0,0 +1,21 @@
+---
+- ansible.builtin.debug: msg="START cli/default_facts.yaml on connection={{ ansible_connection }}"
+
+- name: Test getting default facts
+ register: result
+ cisco.ios.ios_facts:
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - "'default' in result.ansible_facts.ansible_net_gather_subset"
+ - "'config' not in result.ansible_facts.ansible_net_gather_subset"
+ - result.ansible_facts.ansible_net_hostname is defined
+ - result.ansible_facts.ansible_net_image is defined
+ - result.ansible_facts.ansible_net_model is defined
+ - result.ansible_facts.ansible_net_python_version is defined
+ - result.ansible_facts.ansible_net_serialnum is defined
+ - result.ansible_facts.ansible_net_system is defined
+ - result.ansible_facts.ansible_net_version is defined
+ - result.ansible_facts.ansible_network_resources == {}
+
+- ansible.builtin.debug: msg="END cli/default.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_facts/tests/cli/invalid_subset.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_facts/tests/cli/invalid_subset.yaml
new file mode 100644
index 000000000..f2d1ae650
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_facts/tests/cli/invalid_subset.yaml
@@ -0,0 +1,32 @@
+---
+- ansible.builtin.debug: msg="START cli/invalid_subset.yaml on connection={{ ansible_connection }}"
+
+- name: Test invalid subset (foobar)
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_facts:
+ gather_subset:
+ - foobar
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - result.failed == true
+ - result.msg == 'Subset must be one of [config, default, hardware, interfaces], got foobar'
+
+- name: Test subset specified multiple times
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_facts:
+ gather_subset:
+ - "!hardware"
+ - hardware
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - result.failed == true
+ - result.msg == 'Bad subset'
+ ignore_errors: true
+
+- ansible.builtin.debug: msg="END cli/invalid_subset.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_facts/tests/cli/not_hardware.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_facts/tests/cli/not_hardware.yaml
new file mode 100644
index 000000000..396415da5
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_facts/tests/cli/not_hardware.yaml
@@ -0,0 +1,21 @@
+---
+- ansible.builtin.debug: msg="START cli/not_hardware_facts.yaml on connection={{ ansible_connection }}"
+
+- name: Test not hardware
+ register: result
+ cisco.ios.ios_facts:
+ gather_subset:
+ - "!hardware"
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - "'config' in result.ansible_facts.ansible_net_gather_subset"
+ - "'default' in result.ansible_facts.ansible_net_gather_subset"
+ - "'interfaces' in result.ansible_facts.ansible_net_gather_subset"
+ - "'hardware' not in result.ansible_facts.ansible_net_gather_subset"
+ - result.ansible_facts.ansible_net_interfaces | length > 1
+ - result.ansible_facts.ansible_net_filesystems is not defined
+ - result.ansible_facts.ansible_net_filesystems_info is not defined
+
+- ansible.builtin.debug: msg="END cli/not_hardware_facts.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/defaults/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/defaults/main.yaml
new file mode 100644
index 000000000..164afead2
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/meta/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/meta/main.yaml
new file mode 100644
index 000000000..23d65c7ef
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/meta/main.yaml
@@ -0,0 +1,2 @@
+---
+dependencies: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tasks/cli.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tasks/cli.yaml
new file mode 100644
index 000000000..6f505600c
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tasks/cli.yaml
@@ -0,0 +1,21 @@
+---
+- name: Collect all CLI test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+ delegate_to: localhost
+
+- name: Run test case (connection=ansible.netcommon.network_cli)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.network_cli
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tasks/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tasks/main.yaml
new file mode 100644
index 000000000..0d12908aa
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tasks/main.yaml
@@ -0,0 +1,5 @@
+---
+- name: Main task for hostname module
+ ansible.builtin.include_tasks: cli.yaml
+ tags:
+ - network_cli
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tests/cli/_parsed.cfg b/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tests/cli/_parsed.cfg
new file mode 100644
index 000000000..657e5bf2b
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tests/cli/_parsed.cfg
@@ -0,0 +1 @@
+hostname testname
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tests/cli/_populate_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tests/cli/_populate_config.yaml
new file mode 100644
index 000000000..f34cedef4
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tests/cli/_populate_config.yaml
@@ -0,0 +1,6 @@
+---
+- name: Pre post task populate hostname configuration
+ cisco.ios.ios_hostname:
+ config:
+ hostname: "box1"
+ state: merged
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tests/cli/_remove_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tests/cli/_remove_config.yaml
new file mode 100644
index 000000000..5addde5e5
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tests/cli/_remove_config.yaml
@@ -0,0 +1,5 @@
+---
+- name: Pre post task remove hostname configuration
+ cisco.ios.ios_hostname:
+ config:
+ state: deleted
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tests/cli/deleted.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tests/cli/deleted.yaml
new file mode 100644
index 000000000..15087ae8a
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tests/cli/deleted.yaml
@@ -0,0 +1,27 @@
+---
+- ansible.builtin.debug:
+ msg: Start Deleted integration state for ios_hostname ansible_connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Ios_hostname deleted - play
+ register: result
+ cisco.ios.ios_hostname:
+ config:
+ state: deleted
+
+ - name: Ios_hostname deleted - assert commands
+ ansible.builtin.assert:
+ that:
+ - deleted['commands'] == result['commands']
+
+ - name: Ios_hostname deleted - assert before
+ ansible.builtin.assert:
+ that:
+ - deleted['before'] == result['before']
+
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tests/cli/empty_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tests/cli/empty_config.yaml
new file mode 100644
index 000000000..cf96ed8c8
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tests/cli/empty_config.yaml
@@ -0,0 +1,58 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_hostname empty_config.yaml integration tests on connection={{ ansible_connection }}
+
+- name: Merged with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_hostname:
+ config:
+ state: merged
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state merged'
+
+- name: Replaced with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_hostname:
+ config:
+ state: replaced
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state replaced'
+
+- name: Overridden with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_hostname:
+ config:
+ state: overridden
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state overridden'
+
+- name: Rendered with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_hostname:
+ config:
+ state: rendered
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state rendered'
+
+- name: Parsed with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_hostname:
+ running_config:
+ state: parsed
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of running_config parameter must not be empty for state parsed'
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tests/cli/gathered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tests/cli/gathered.yaml
new file mode 100644
index 000000000..1f81f2e0b
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tests/cli/gathered.yaml
@@ -0,0 +1,20 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_hostname gathered integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Ios_hostname gather - play
+ register: result
+ cisco.ios.ios_hostname:
+ config:
+ state: gathered
+
+ - name: Ios_hostname gather - assert
+ ansible.builtin.assert:
+ that:
+ - gathered['config'] == result['gathered']
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tests/cli/merged.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tests/cli/merged.yaml
new file mode 100644
index 000000000..3c470b446
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tests/cli/merged.yaml
@@ -0,0 +1,35 @@
+---
+- ansible.builtin.debug:
+ msg: START Merged ios_hostname state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Ios_hostname merged - play
+ register: result
+ cisco.ios.ios_hostname: &id001
+ config:
+ hostname: "boxTest"
+ state: merged
+
+ - name: Ios_hostname merged - assert commands
+ ansible.builtin.assert:
+ that:
+ - merged['commands'] == result['commands']
+
+ - name: Ios_hostname merged - assert after
+ ansible.builtin.assert:
+ that:
+ - merged['after'] == result['after']
+
+ - name: Ios_hostname merged - play (idempotent)
+ register: result
+ cisco.ios.ios_hostname: *id001
+ - name: Ios_hostname merged - assert above task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tests/cli/parsed.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tests/cli/parsed.yaml
new file mode 100644
index 000000000..ee3726544
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tests/cli/parsed.yaml
@@ -0,0 +1,14 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_hostname parsed integration tests on connection={{ ansible_connection }}
+
+- name: Ios_hostname parsed - play
+ register: result
+ cisco.ios.ios_hostname:
+ running_config: "{{ lookup('file', '_parsed.cfg') }}"
+ state: parsed
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - parsed['config'] == result['parsed']
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tests/cli/rendered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tests/cli/rendered.yaml
new file mode 100644
index 000000000..53cba4e0c
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/tests/cli/rendered.yaml
@@ -0,0 +1,16 @@
+---
+- ansible.builtin.debug:
+ msg: Start ios_hostname rendered integration tests ansible_connection={{ ansible_connection }}
+
+- block:
+ - name: Ios_hostname render - play
+ register: result
+ cisco.ios.ios_hostname:
+ config:
+ hostname: "testname"
+ state: rendered
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - result.rendered == rendered['commands']
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/vars/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/vars/main.yaml
new file mode 100644
index 000000000..734325846
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_hostname/vars/main.yaml
@@ -0,0 +1,24 @@
+---
+merged:
+ commands:
+ - hostname boxTest
+ after:
+ hostname: "boxTest"
+
+deleted:
+ before:
+ hostname: "box1"
+ commands:
+ - no hostname box1
+
+parsed:
+ config:
+ hostname: "testname"
+
+gathered:
+ config:
+ hostname: "box1"
+
+rendered:
+ commands:
+ - hostname testname
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/defaults/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/defaults/main.yaml
new file mode 100644
index 000000000..164afead2
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/meta/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/meta/main.yaml
new file mode 100644
index 000000000..23d65c7ef
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/meta/main.yaml
@@ -0,0 +1,2 @@
+---
+dependencies: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tasks/cli.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tasks/cli.yaml
new file mode 100644
index 000000000..6f505600c
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tasks/cli.yaml
@@ -0,0 +1,21 @@
+---
+- name: Collect all CLI test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+ delegate_to: localhost
+
+- name: Run test case (connection=ansible.netcommon.network_cli)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.network_cli
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tasks/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tasks/main.yaml
new file mode 100644
index 000000000..837704560
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tasks/main.yaml
@@ -0,0 +1,5 @@
+---
+- name: Main task for interfaces module
+ ansible.builtin.include_tasks: cli.yaml
+ tags:
+ - network_cli
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/_parsed.cfg b/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/_parsed.cfg
new file mode 100644
index 000000000..bef54b923
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/_parsed.cfg
@@ -0,0 +1,11 @@
+interface GigabitEthernet2
+ description interfaces 0/1
+ mtu 110
+ duplex half
+ no shutdown
+interface GigabitEthernet3
+ description interfaces 0/2
+ mtu 2800
+ speed 100
+ duplex full
+ shutdown
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/_populate_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/_populate_config.yaml
new file mode 100644
index 000000000..c9cee9c28
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/_populate_config.yaml
@@ -0,0 +1,8 @@
+---
+- name: Populate configuration
+ vars:
+ lines:
+ "interface GigabitEthernet 1\ndescription Management interface do not change\ninterface GigabitEthernet 2\ndescription this is interface1\nmtu 1500\nspeed 1000\nno shutdown\ninterface GigabitEthernet 3\ndescription this is interface\
+ \ for testing\nmtu 1500\nspeed 1000\nshutdown\n"
+ ansible.netcommon.cli_config:
+ config: "{{ lines }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/_remove_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/_remove_config.yaml
new file mode 100644
index 000000000..a3f5b0a44
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/_remove_config.yaml
@@ -0,0 +1,18 @@
+---
+- name: Remove configuration
+ vars:
+ lines:
+ "interface loopback888\nno description\nno shutdown\ninterface loopback999\nno description\nno shutdown\ninterface GigabitEthernet 2\nno description\n\
+ no mtu\nno speed\nno shutdown\ninterface GigabitEthernet 3\nno description\nno mtu\nno speed\nno shutdown\n"
+ ansible.netcommon.cli_config:
+ config: "{{ lines }}"
+
+- name: Delete attributes of all configured interfaces
+ register: result
+ cisco.ios.ios_interfaces:
+ config:
+ - name: Port-channel10
+ - name: Port-channel11
+ - name: Port-channel22
+ - name: Port-channel40
+ state: purged
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/deleted.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/deleted.yaml
new file mode 100644
index 000000000..bca6aebec
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/deleted.yaml
@@ -0,0 +1,33 @@
+---
+- ansible.builtin.debug:
+ msg: Start Deleted integration state for ios_interfaces ansible_connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Delete attributes of all configured interfaces
+ register: result
+ cisco.ios.ios_interfaces:
+ config:
+ - name: GigabitEthernet2
+ - name: GigabitEthernet3
+ state: deleted
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ deleted['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ deleted['before'] | symmetric_difference(result['before']) | length == 0 }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ deleted['after'] | symmetric_difference(result['after']) | length == 0 }}"
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/empty_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/empty_config.yaml
new file mode 100644
index 000000000..db1987d1d
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/empty_config.yaml
@@ -0,0 +1,58 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_interfaces empty_config.yaml integration tests on connection={{ ansible_connection }}
+
+- name: Merged with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_interfaces:
+ config:
+ state: merged
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state merged'
+
+- name: Replaced with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_interfaces:
+ config:
+ state: replaced
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state replaced'
+
+- name: Overridden with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_interfaces:
+ config:
+ state: overridden
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state overridden'
+
+- name: Rendered with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_interfaces:
+ config:
+ state: rendered
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state rendered'
+
+- name: Parsed with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_interfaces:
+ running_config:
+ state: parsed
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of running_config parameter must not be empty for state parsed'
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/gathered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/gathered.yaml
new file mode 100644
index 000000000..dd2106005
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/gathered.yaml
@@ -0,0 +1,21 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_interfaces gathered integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Gather the provided configuration with the existing running configuration
+ register: result
+ cisco.ios.ios_interfaces:
+ config:
+ state: gathered
+
+ - name: Assert
+ ansible.builtin.assert:
+ that:
+ - gathered['config'] | symmetric_difference(result.gathered) == []
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/merged.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/merged.yaml
new file mode 100644
index 000000000..c73dd0b11
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/merged.yaml
@@ -0,0 +1,44 @@
+---
+- ansible.builtin.debug:
+ msg: START Merged ios_interfaces state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- block:
+ - name: Merge provided configuration with device configuration
+ register: result
+ cisco.ios.ios_interfaces: &id001
+ config:
+ - name: GigabitEthernet2
+ description: Configured and Merged by Ansible-Network
+ enabled: true
+
+ - name: GigabitEthernet3
+ description: Configured and Merged by Ansible-Network
+ enabled: false
+ state: merged
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['before'] | symmetric_difference(result['before']) | length == 0 }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['after'] | symmetric_difference(result['after']) | length == 0 }}"
+
+ - name: Merge provided configuration with device configuration (idempotent)
+ register: result
+ cisco.ios.ios_interfaces: *id001
+ - name: Assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/overridden.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/overridden.yaml
new file mode 100644
index 000000000..708a9eec9
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/overridden.yaml
@@ -0,0 +1,57 @@
+---
+- ansible.builtin.debug:
+ msg: START Overridden ios_interfaces state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Override device configuration of all interfaces with provided configuration
+ register: result
+ cisco.ios.ios_interfaces: &id001
+ config:
+ - enabled: true
+ name: Loopback888
+ - enabled: true
+ name: Loopback999
+ - enabled: true
+ name: GigabitEthernet1
+ description: Management interface do not change
+ - description: this is interface1
+ enabled: true
+ name: GigabitEthernet2
+ speed: 1000
+ - name: GigabitEthernet3
+ description: Configured and Overridden by Ansible-Network
+ enabled: true
+ speed: 1000
+ - enabled: false
+ name: GigabitEthernet4
+ state: overridden
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ overridden['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ overridden['before'] | symmetric_difference(result['before']) | length == 0 }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ overridden['after'] | symmetric_difference(result['after']) | length == 0 }}"
+
+ - name: Override device configuration of all interfaces with provided configuration (idempotent)
+ register: result
+ cisco.ios.ios_interfaces: *id001
+ - name: Assert that task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/parsed.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/parsed.yaml
new file mode 100644
index 000000000..35c95969d
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/parsed.yaml
@@ -0,0 +1,15 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_interfaces parsed integration tests on connection={{ ansible_connection }}
+
+- name: Parse the commands for provided configuration
+ become: true
+ register: result
+ cisco.ios.ios_interfaces:
+ running_config: "{{ lookup('file', '_parsed.cfg') }}"
+ state: parsed
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - parsed['config']|symmetric_difference(result.parsed) == []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/rendered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/rendered.yaml
new file mode 100644
index 000000000..8b80dbaab
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/rendered.yaml
@@ -0,0 +1,25 @@
+---
+- ansible.builtin.debug:
+ msg: Start ios_interfaces rendered integration tests ansible_connection={{ ansible_connection }}
+
+- block:
+ - name: Render the commands for provided configuration
+ become: true
+ register: result
+ cisco.ios.ios_interfaces:
+ config:
+ - name: GigabitEthernet2
+ description: Configured by Ansible-Network
+ mtu: 110
+ enabled: true
+ - name: GigabitEthernet3
+ description: Configured by Ansible-Network
+ mtu: 2800
+ enabled: false
+ speed: 100
+ state: rendered
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - result.rendered|symmetric_difference(rendered.commands) == []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/replaced.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/replaced.yaml
new file mode 100644
index 000000000..5dd5441d3
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/tests/cli/replaced.yaml
@@ -0,0 +1,43 @@
+---
+- ansible.builtin.debug:
+ msg: START Replaced ios_interfaces state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Replaces device configuration of listed interfaces with provided configuration
+ register: result
+ cisco.ios.ios_interfaces: &id001
+ config:
+ - name: GigabitEthernet2
+ description: Configured and Replaced by Ansible-Network
+ speed: 1000
+ state: replaced
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ replaced['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ replaced['before'] | symmetric_difference(result['before']) | length == 0 }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ replaced['after'] | symmetric_difference(result['after']) | length == 0 }}"
+
+ - name: Replaces device configuration of listed interfaces with provided configuration (idempotent)
+ register: result
+ cisco.ios.ios_interfaces: *id001
+ - name: Assert that task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/vars/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/vars/main.yaml
new file mode 100644
index 000000000..84b8afb22
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_interfaces/vars/main.yaml
@@ -0,0 +1,215 @@
+---
+merged:
+ before:
+ - enabled: true
+ name: GigabitEthernet1
+ description: Management interface do not change
+ - enabled: true
+ name: GigabitEthernet2
+ speed: "1000"
+ - enabled: true
+ name: GigabitEthernet3
+ speed: "1000"
+ - enabled: false
+ name: GigabitEthernet4
+ - enabled: true
+ name: Loopback888
+ - enabled: true
+ name: Loopback999
+ commands:
+ - interface GigabitEthernet2
+ - description Configured and Merged by Ansible-Network
+ - interface GigabitEthernet3
+ - description Configured and Merged by Ansible-Network
+ - shutdown
+ after:
+ - enabled: true
+ description: Management interface do not change
+ name: GigabitEthernet1
+ - description: Configured and Merged by Ansible-Network
+ enabled: true
+ name: GigabitEthernet2
+ speed: "1000"
+ - description: Configured and Merged by Ansible-Network
+ enabled: false
+ name: GigabitEthernet3
+ speed: "1000"
+ - enabled: false
+ name: GigabitEthernet4
+ - enabled: true
+ name: Loopback888
+ - enabled: true
+ name: Loopback999
+
+replaced:
+ commands:
+ - interface GigabitEthernet2
+ - description Configured and Replaced by Ansible-Network
+ after:
+ - description: Management interface do not change
+ enabled: true
+ name: GigabitEthernet1
+ - description: Configured and Replaced by Ansible-Network
+ enabled: true
+ name: GigabitEthernet2
+ speed: "1000"
+ - description: this is interface for testing
+ enabled: false
+ name: GigabitEthernet3
+ speed: "1000"
+ - enabled: false
+ name: GigabitEthernet4
+ - enabled: true
+ name: Loopback888
+ - enabled: true
+ name: Loopback999
+ before:
+ - description: Management interface do not change
+ enabled: true
+ name: GigabitEthernet1
+ - description: this is interface1
+ enabled: true
+ name: GigabitEthernet2
+ speed: "1000"
+ - description: this is interface for testing
+ enabled: false
+ name: GigabitEthernet3
+ speed: "1000"
+ - enabled: false
+ name: GigabitEthernet4
+ - enabled: true
+ name: Loopback888
+ - enabled: true
+ name: Loopback999
+
+overridden:
+ before:
+ - enabled: true
+ name: GigabitEthernet1
+ description: Management interface do not change
+ - description: this is interface1
+ enabled: true
+ name: GigabitEthernet2
+ speed: "1000"
+ - description: this is interface for testing
+ enabled: false
+ name: GigabitEthernet3
+ speed: "1000"
+ - enabled: false
+ name: GigabitEthernet4
+ - enabled: true
+ name: Loopback888
+ - enabled: true
+ name: Loopback999
+ commands:
+ - interface GigabitEthernet3
+ - description Configured and Overridden by Ansible-Network
+ - no shutdown
+ after:
+ - description: Management interface do not change
+ enabled: true
+ name: GigabitEthernet1
+ - description: this is interface1
+ enabled: true
+ name: GigabitEthernet2
+ speed: "1000"
+ - description: Configured and Overridden by Ansible-Network
+ enabled: true
+ name: GigabitEthernet3
+ speed: "1000"
+ - enabled: false
+ name: GigabitEthernet4
+ - enabled: true
+ name: Loopback888
+ - enabled: true
+ name: Loopback999
+
+deleted:
+ before:
+ - description: Management interface do not change
+ enabled: true
+ name: GigabitEthernet1
+ - description: this is interface1
+ enabled: true
+ name: GigabitEthernet2
+ speed: "1000"
+ - description: this is interface for testing
+ enabled: false
+ name: GigabitEthernet3
+ speed: "1000"
+ - enabled: false
+ name: GigabitEthernet4
+ - enabled: true
+ name: Loopback888
+ - enabled: true
+ name: Loopback999
+ commands:
+ - interface GigabitEthernet2
+ - no description this is interface1
+ - no speed 1000
+ - shutdown
+ - interface GigabitEthernet3
+ - no description this is interface for testing
+ - no speed 1000
+ after:
+ - description: Management interface do not change
+ enabled: true
+ name: GigabitEthernet1
+ - enabled: false
+ name: GigabitEthernet2
+ speed: "1000"
+ - enabled: false
+ name: GigabitEthernet3
+ speed: "1000"
+ - enabled: false
+ name: GigabitEthernet4
+ - enabled: true
+ name: Loopback888
+ - enabled: true
+ name: Loopback999
+
+gathered:
+ config:
+ - description: Management interface do not change
+ enabled: true
+ name: GigabitEthernet1
+ - description: this is interface1
+ enabled: true
+ name: GigabitEthernet2
+ speed: "1000"
+ - description: this is interface for testing
+ enabled: false
+ name: GigabitEthernet3
+ speed: "1000"
+ - enabled: false
+ name: GigabitEthernet4
+ - enabled: true
+ name: Loopback888
+ - enabled: true
+ name: Loopback999
+
+parsed:
+ config:
+ - description: interfaces 0/1
+ duplex: half
+ enabled: true
+ mtu: 110
+ name: GigabitEthernet2
+ - description: interfaces 0/2
+ duplex: full
+ enabled: false
+ mtu: 2800
+ name: GigabitEthernet3
+ speed: "100"
+
+rendered:
+ commands:
+ - interface GigabitEthernet2
+ - description Configured by Ansible-Network
+ - mtu 110
+ - no shutdown
+ - interface GigabitEthernet3
+ - description Configured by Ansible-Network
+ - mtu 2800
+ - speed 100
+ - shutdown
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/defaults/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/defaults/main.yaml
new file mode 100644
index 000000000..164afead2
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/meta/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/meta/main.yaml
new file mode 100644
index 000000000..23d65c7ef
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/meta/main.yaml
@@ -0,0 +1,2 @@
+---
+dependencies: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tasks/cli.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tasks/cli.yaml
new file mode 100644
index 000000000..25c50045a
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tasks/cli.yaml
@@ -0,0 +1,25 @@
+---
+- name: Collect all CLI test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+ delegate_to: localhost
+
+- name: Get the IOS version
+ cisco.ios.ios_facts:
+ gather_subset: all
+
+- name: Run test case (connection=ansible.netcommon.network_cli)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.network_cli
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tasks/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tasks/main.yaml
new file mode 100644
index 000000000..adea6a8c3
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tasks/main.yaml
@@ -0,0 +1,5 @@
+---
+- name: Main task for l2_interfaces module
+ ansible.builtin.include_tasks: cli.yaml
+ tags:
+ - network_cli
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/_parsed.cfg b/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/_parsed.cfg
new file mode 100644
index 000000000..74814f934
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/_parsed.cfg
@@ -0,0 +1,8 @@
+interface GigabitEthernet2
+ switchport mode access
+ switchport access vlan 30
+interface GigabitEthernet3
+ switchport trunk allowed vlan 15-20,40
+ switchport trunk encapsulation dot1q
+ switchport trunk native vlan 20
+ switchport trunk pruning vlan 10,20
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/_populate_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/_populate_config.yaml
new file mode 100644
index 000000000..b0655f88f
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/_populate_config.yaml
@@ -0,0 +1,9 @@
+---
+- name: Populate configuration
+ vars:
+ lines:
+ "interface GigabitEthernet 2\nswitchport access vlan 10\ninterface GigabitEthernet 3\nswitchport trunk encapsulation dot1q\nswitchport trunk native\
+ \ vlan 10\nswitchport trunk allowed vlan 10-20,40\nswitchport trunk pruning vlan 10,20\nswitchport mode trunk\n"
+ when: ansible_net_version != "15.6(2)T"
+ ansible.netcommon.cli_config:
+ config: "{{ lines }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/_remove_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/_remove_config.yaml
new file mode 100644
index 000000000..e8d72aaae
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/_remove_config.yaml
@@ -0,0 +1,11 @@
+---
+- name: Remove configuration
+ vars:
+ lines:
+ "interface GigabitEthernet 2\nno switchport access vlan\nno switchport trunk encapsulation\nno switchport trunk native vlan\nno switchport trunk allowed\
+ \ vlan\nno switchport trunk pruning vlan\nno switchport mode\nno switchport voice vlan\ninterface GigabitEthernet 3\nno switchport access vlan\nno switchport\
+ \ trunk encapsulation\nno switchport trunk native vlan\nno switchport trunk allowed vlan\nno switchport trunk pruning vlan\nno switchport mode\nno switchport\
+ \ voice vlan\n"
+ when: ansible_net_version != "15.6(2)T"
+ ansible.netcommon.cli_config:
+ config: "{{ lines }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/_remove_vlan_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/_remove_vlan_config.yaml
new file mode 100644
index 000000000..83a5dd412
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/_remove_vlan_config.yaml
@@ -0,0 +1,5 @@
+---
+- name: Remove all VLAN configuration
+ cisco.ios.ios_vlans:
+ state: deleted
+ when: ansible_net_version != "15.6(2)T"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/deleted.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/deleted.yaml
new file mode 100644
index 000000000..6fc0fe680
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/deleted.yaml
@@ -0,0 +1,41 @@
+---
+- ansible.builtin.debug:
+ msg: Start Deleted integration state for ios_l2_interfaces ansible_connection={{ ansible_connection }}
+
+- block:
+ - ansible.builtin.include_tasks: _remove_config.yaml
+ - ansible.builtin.include_tasks: _populate_config.yaml
+ when: ansible_net_version == "15.6(2)T"
+
+- block:
+ - name: Delete layer 2 attributes from all configured interfaces
+ register: result
+ cisco.ios.ios_l2_interfaces: &id001
+ state: deleted
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ deleted['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ deleted['before'] | symmetric_difference(result['before']) | length == 0 }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ deleted['after'] | symmetric_difference(result['after']) | length == 0 }}"
+
+ - name: Delete attributes of all configured interfaces (idempotent)
+ register: result
+ cisco.ios.ios_l2_interfaces: *id001
+ - name: Assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result.changed == false
+ when: ansible_net_version == "15.6(2)T"
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
+ - ansible.builtin.include_tasks: _remove_vlan_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/empty_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/empty_config.yaml
new file mode 100644
index 000000000..57ac7df89
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/empty_config.yaml
@@ -0,0 +1,58 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_l2_interfaces empty_config.yaml integration tests on connection={{ ansible_connection }}
+
+- name: Merged with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_l2_interfaces:
+ config:
+ state: merged
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state merged'
+
+- name: Replaced with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_l2_interfaces:
+ config:
+ state: replaced
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state replaced'
+
+- name: Overridden with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_l2_interfaces:
+ config:
+ state: overridden
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state overridden'
+
+- name: Rendered with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_l2_interfaces:
+ config:
+ state: rendered
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state rendered'
+
+- name: Parsed with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_l2_interfaces:
+ running_config:
+ state: parsed
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of running_config parameter must not be empty for state parsed'
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/gathered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/gathered.yaml
new file mode 100644
index 000000000..61dd98623
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/gathered.yaml
@@ -0,0 +1,23 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_l2_interfaces gathered integration tests on connection={{ ansible_connection }}
+
+- block:
+ - ansible.builtin.include_tasks: _populate_config.yaml
+ when: ansible_net_version == "15.6(2)T"
+
+- block:
+ - name: Gather the provided configuration with the existing running configuration
+ register: result
+ cisco.ios.ios_l2_interfaces:
+ config:
+ state: gathered
+
+ - name: Assert
+ ansible.builtin.assert:
+ that:
+ - gathered['config'] | symmetric_difference(result.gathered) == []
+ - result['changed'] == false
+ when: ansible_net_version == "15.6(2)T"
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/merged.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/merged.yaml
new file mode 100644
index 000000000..95a127321
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/merged.yaml
@@ -0,0 +1,87 @@
+---
+- ansible.builtin.debug:
+ msg: START Merged ios_l2_interfaces state for integration tests on connection={{ ansible_connection }}
+
+- block:
+ - ansible.builtin.include_tasks: _remove_config.yaml
+ when: ansible_net_version == "15.6(2)T"
+
+- block:
+ - name: Merge provided configuration with device configuration
+ register: result
+ cisco.ios.ios_l2_interfaces: &id001
+ config:
+ - name: GigabitEthernet2
+ access:
+ vlan: 30
+ voice:
+ vlan: 40
+ - name: GigabitEthernet3
+ trunk:
+ allowed_vlans: 15-20,40
+ native_vlan: 20
+ pruning_vlans: 10,20
+ encapsulation: dot1q
+ mode: trunk
+ state: merged
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['before'] | symmetric_difference(result['before']) | length == 0 }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['after'] | symmetric_difference(result['after']) | length == 0 }}"
+
+ - name: Merge provided configuration with device configuration (idempotent)
+ register: result
+ cisco.ios.ios_l2_interfaces: *id001
+ - name: Assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+
+ - name: Merge new configuration with already merged configuration
+ register: result
+ cisco.ios.ios_l2_interfaces: &id002
+ config:
+ - name: GigabitEthernet3
+ trunk:
+ allowed_vlans: 200
+ pruning_vlans: 40-60
+ state: merged
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged_again['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['after'] | symmetric_difference(result['before']) | length == 0 }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged_again['after'] | symmetric_difference(result['after']) | length == 0 }}"
+
+ - name: Merge new configuration with already merged configuration (idempotent)
+ register: result
+ cisco.ios.ios_l2_interfaces: *id002
+ - name: Assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+
+ when: ansible_net_version == "15.6(2)T"
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
+ - ansible.builtin.include_tasks: _remove_vlan_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/overridden.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/overridden.yaml
new file mode 100644
index 000000000..481027944
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/overridden.yaml
@@ -0,0 +1,47 @@
+---
+- ansible.builtin.debug:
+ msg: START Overridden ios_l2_interfaces state for integration tests on connection={{ ansible_connection }}
+
+- block:
+ - ansible.builtin.include_tasks: _remove_config.yaml
+ - ansible.builtin.include_tasks: _populate_config.yaml
+ when: ansible_net_version == "15.6(2)T"
+
+- block:
+ - name: Override device layer 2 configuration from all interfaces with provided configuration
+ register: result
+ cisco.ios.ios_l2_interfaces: &id001
+ config:
+ - name: GigabitEthernet3
+ trunk:
+ allowed_vlans: 30-35,40
+ native_vlan: 30
+ encapsulation: isl
+ state: overridden
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ overridden['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ overridden['before'] | symmetric_difference(result['before']) | length == 0 }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ overridden['after'] | symmetric_difference(result['after']) | length == 0 }}"
+
+ - name: Override device layer 2 configuration from all interfaces with provided configuration (idempotent)
+ register: result
+ cisco.ios.ios_l2_interfaces: *id001
+ - name: Assert that task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ when: ansible_net_version == "15.6(2)T"
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
+ - ansible.builtin.include_tasks: _remove_vlan_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/parsed.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/parsed.yaml
new file mode 100644
index 000000000..2c82013dc
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/parsed.yaml
@@ -0,0 +1,16 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_l2_interfaces parsed integration tests on connection={{ ansible_connection }}
+
+- block:
+ - name: Parse the commands for provided configuration
+ become: true
+ register: result
+ cisco.ios.ios_l2_interfaces:
+ running_config: "{{ lookup('file', '_parsed.cfg') }}"
+ state: parsed
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - parsed['config']|symmetric_difference(result.parsed) == []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/rendered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/rendered.yaml
new file mode 100644
index 000000000..04a7cf0f6
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/rendered.yaml
@@ -0,0 +1,26 @@
+---
+- ansible.builtin.debug:
+ msg: Start ios_l2_interfaces rendered integration tests ansible_connection={{ ansible_connection }}
+
+- block:
+ - name: Render the commands for provided configuration
+ become: true
+ register: result
+ cisco.ios.ios_l2_interfaces:
+ config:
+ - name: GigabitEthernet2
+ access:
+ vlan: 30
+
+ - name: GigabitEthernet3
+ trunk:
+ allowed_vlans: 10-20,40
+ native_vlan: 20
+ pruning_vlans: 10,20
+ encapsulation: dot1q
+ state: rendered
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - result.rendered|symmetric_difference(rendered.commands) == []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/replaced.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/replaced.yaml
new file mode 100644
index 000000000..8ad1b5382
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/replaced.yaml
@@ -0,0 +1,52 @@
+---
+- ansible.builtin.debug:
+ msg: START Replaced ios_l2_interfaces state for integration tests on connection={{ ansible_connection }}
+
+- block:
+ - ansible.builtin.include_tasks: _remove_config.yaml
+ - ansible.builtin.include_tasks: _populate_config.yaml
+ when: ansible_net_version == "15.6(2)T"
+
+- block:
+ - name: Replaces device layer 2 configuration from listed interfaces with provided configuration
+ register: result
+ cisco.ios.ios_l2_interfaces: &id001
+ config:
+ - name: GigabitEthernet2
+ access:
+ vlan: 40
+ voice:
+ vlan: 20
+ - name: GigabitEthernet3
+ trunk:
+ native_vlan: 20
+ pruning_vlans: 10-20,30
+ encapsulation: dot1q
+ state: replaced
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ replaced['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ replaced['before'] | symmetric_difference(result['before']) | length == 0 }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ replaced['after'] | symmetric_difference(result['after']) | length == 0 }}"
+
+ - name: Replaces device layer 2 configuration from listed interfaces with provided configuration (idempotent)
+ register: result
+ cisco.ios.ios_l2_interfaces: *id001
+ - name: Assert that task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ when: ansible_net_version == "15.6(2)T"
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
+ - ansible.builtin.include_tasks: _remove_vlan_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/rtt.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/rtt.yaml
new file mode 100644
index 000000000..4654e6ca1
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/tests/cli/rtt.yaml
@@ -0,0 +1,64 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_l2_interfaces round trip integration tests on connection={{ ansible_connection }}
+
+- block:
+ - ansible.builtin.include_tasks: _remove_config.yaml
+ when: ansible_net_version == "15.6(2)T"
+
+- block:
+ - name: Apply the provided configuration (base config)
+ register: base_config
+ cisco.ios.ios_l2_interfaces:
+ config:
+ - name: GigabitEthernet2
+ access:
+ vlan: 30
+ - mode: trunk
+ name: GigabitEthernet3
+ trunk:
+ allowed_vlans: 15-20,40
+ native_vlan: 20
+ pruning_vlans: 10,20
+ encapsulation: dot1q
+ state: merged
+
+ - name: Gather layer 2 interfaces facts
+ cisco.ios.ios_facts:
+ gather_subset:
+ - "!all"
+ - "!min"
+ gather_network_resources:
+ - l2_interfaces
+
+ - name: Apply the provided configuration (config to be reverted)
+ register: result
+ cisco.ios.ios_l2_interfaces:
+ config:
+ - name: GigabitEthernet3
+ trunk:
+ allowed_vlans: 30-35,40
+ native_vlan: 30
+ encapsulation: isl
+ state: overridden
+
+ - ansible.builtin.assert:
+ that:
+ - result.commands|length == 8
+ - result.changed == true
+ - result.commands|symmetric_difference(overridden.commands) == []
+
+ - name: Revert back to base configuration using facts round trip
+ register: revert
+ cisco.ios.ios_l2_interfaces:
+ config: "{{ ansible_facts['network_resources']['l2_interfaces'] }}"
+ state: overridden
+
+ - ansible.builtin.assert:
+ that:
+ - revert.commands|length == 7
+ - revert.changed == true
+ - revert.commands|symmetric_difference(rtt.commands) == []
+ when: ansible_net_version == "15.6(2)T"
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/vars/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/vars/main.yaml
new file mode 100644
index 000000000..019527d89
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_l2_interfaces/vars/main.yaml
@@ -0,0 +1,213 @@
+---
+merged:
+ before:
+ - name: GigabitEthernet0/0
+ - name: GigabitEthernet2
+ - name: GigabitEthernet3
+ commands:
+ - interface GigabitEthernet2
+ - switchport access vlan 30
+ - switchport voice vlan 40
+ - interface GigabitEthernet3
+ - switchport trunk encapsulation dot1q
+ - switchport trunk native vlan 20
+ - switchport trunk allowed vlan 15-20,40
+ - switchport trunk pruning vlan 10,20
+ - switchport mode trunk
+ after:
+ - name: GigabitEthernet0/0
+ - access:
+ vlan: 30
+ voice:
+ vlan: 40
+ name: GigabitEthernet2
+ - mode: trunk
+ name: GigabitEthernet3
+ trunk:
+ allowed_vlans:
+ - 15-20
+ - "40"
+ encapsulation: dot1q
+ native_vlan: 20
+ pruning_vlans:
+ - "10"
+ - "20"
+merged_again:
+ commands:
+ - interface GigabitEthernet3
+ - switchport trunk allowed vlan 200,15-20,40
+ - switchport trunk pruning vlan 40-60,10,20
+ after:
+ - name: GigabitEthernet0/0
+ - access:
+ vlan: 30
+ name: GigabitEthernet2
+ - mode: trunk
+ name: GigabitEthernet3
+ trunk:
+ allowed_vlans:
+ - 15-20
+ - "40"
+ - "200"
+ encapsulation: dot1q
+ native_vlan: 20
+ pruning_vlans:
+ - "10"
+ - "20"
+ - 40-60
+replaced:
+ before:
+ - name: GigabitEthernet0/0
+ - access:
+ vlan: 10
+ name: GigabitEthernet2
+ - mode: trunk
+ name: GigabitEthernet3
+ trunk:
+ allowed_vlans:
+ - 10-20
+ - "40"
+ encapsulation: dot1q
+ native_vlan: 10
+ pruning_vlans:
+ - "10"
+ - "20"
+ commands:
+ - interface GigabitEthernet2
+ - switchport access vlan 40
+ - switchport voice vlan 20
+ - interface GigabitEthernet3
+ - no switchport mode
+ - no switchport trunk allowed vlan
+ - switchport trunk native vlan 20
+ - switchport trunk pruning vlan 10-20,30
+ after:
+ - name: GigabitEthernet0/0
+ - access:
+ vlan: 40
+ name: GigabitEthernet2
+ voice:
+ vlan: 20
+ - name: GigabitEthernet3
+ trunk:
+ encapsulation: dot1q
+ native_vlan: 20
+ pruning_vlans:
+ - 10-20
+ - "30"
+overridden:
+ before:
+ - name: GigabitEthernet0/0
+ - access:
+ vlan: 10
+ name: GigabitEthernet2
+ - mode: trunk
+ name: GigabitEthernet3
+ trunk:
+ allowed_vlans:
+ - 10-20
+ - "40"
+ encapsulation: dot1q
+ native_vlan: 10
+ pruning_vlans:
+ - "10"
+ - "20"
+ commands:
+ - interface GigabitEthernet2
+ - no switchport access vlan
+ - interface GigabitEthernet3
+ - no switchport mode
+ - no switchport trunk pruning vlan
+ - switchport trunk encapsulation isl
+ - switchport trunk native vlan 30
+ - switchport trunk allowed vlan 30-35,40
+ after:
+ - name: GigabitEthernet0/0
+ - name: GigabitEthernet2
+ - name: GigabitEthernet3
+ trunk:
+ allowed_vlans:
+ - 30-35
+ - "40"
+ encapsulation: isl
+ native_vlan: 30
+deleted:
+ before:
+ - name: GigabitEthernet0/0
+ - access:
+ vlan: 10
+ name: GigabitEthernet2
+ - mode: trunk
+ name: GigabitEthernet3
+ trunk:
+ allowed_vlans:
+ - 10-20
+ - "40"
+ encapsulation: dot1q
+ native_vlan: 10
+ pruning_vlans:
+ - "10"
+ - "20"
+ commands:
+ - interface GigabitEthernet2
+ - no switchport access vlan
+ - interface GigabitEthernet3
+ - no switchport mode
+ - no switchport trunk encapsulation
+ - no switchport trunk native vlan
+ - no switchport trunk allowed vlan
+ - no switchport trunk pruning vlan
+ after:
+ - name: GigabitEthernet0/0
+ - name: GigabitEthernet2
+ - name: GigabitEthernet3
+gathered:
+ config:
+ - access:
+ vlan: 30
+ name: GigabitEthernet2
+ - mode: trunk
+ name: GigabitEthernet3
+ trunk:
+ allowed_vlans:
+ - "10-20"
+ - "40"
+ encapsulation: dot1q
+ native_vlan: 10
+ pruning_vlans:
+ - "10"
+ - "20"
+parsed:
+ config:
+ - access:
+ vlan: 30
+ mode: access
+ name: GigabitEthernet2
+ - name: GigabitEthernet3
+ trunk:
+ allowed_vlans:
+ - "15-20"
+ - "40"
+ encapsulation: dot1q
+ native_vlan: 20
+ pruning_vlans:
+ - "10"
+ - "20"
+rendered:
+ commands:
+ - interface GigabitEthernet2
+ - switchport access vlan 30
+ - interface GigabitEthernet3
+ - switchport trunk encapsulation dot1q
+ - switchport trunk native vlan 20
+ - switchport trunk allowed vlan 10-20,40
+ - switchport trunk pruning vlan 10,20
+rtt:
+ commands:
+ - interface GigabitEthernet2
+ - switchport access vlan 30
+ - interface GigabitEthernet3
+ - switchport trunk encapsulation dot1q
+ - switchport trunk native vlan 20
+ - switchport trunk allowed vlan 15-20,40
+ - switchport trunk pruning vlan 10,20
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/defaults/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/defaults/main.yaml
new file mode 100644
index 000000000..164afead2
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/meta/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/meta/main.yaml
new file mode 100644
index 000000000..23d65c7ef
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/meta/main.yaml
@@ -0,0 +1,2 @@
+---
+dependencies: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tasks/cli.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tasks/cli.yaml
new file mode 100644
index 000000000..6f505600c
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tasks/cli.yaml
@@ -0,0 +1,21 @@
+---
+- name: Collect all CLI test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+ delegate_to: localhost
+
+- name: Run test case (connection=ansible.netcommon.network_cli)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.network_cli
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tasks/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tasks/main.yaml
new file mode 100644
index 000000000..dbaa9f032
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tasks/main.yaml
@@ -0,0 +1,5 @@
+---
+- name: Main task for l3_interfaces module
+ ansible.builtin.include_tasks: cli.yaml
+ tags:
+ - network_cli
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/_parsed.cfg b/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/_parsed.cfg
new file mode 100644
index 000000000..fee28ab03
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/_parsed.cfg
@@ -0,0 +1,7 @@
+interface GigabitEthernet2
+ ip address dhcp client-id GigabitEthernet0/0 hostname test.com
+interface GigabitEthernet3
+ ip address 198.51.100.1 255.255.255.0 secondary
+ ip address 198.51.100.2 255.255.255.0
+ ipv6 address autoconfig
+ ipv6 address 2001:db8:0:3::/64
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/_populate_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/_populate_config.yaml
new file mode 100644
index 000000000..5d1fceeb0
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/_populate_config.yaml
@@ -0,0 +1,8 @@
+---
+- name: L3_interface - populate configuration
+ vars:
+ lines:
+ "interface GigabitEthernet 2\nip address 203.0.113.27 255.255.255.0\ninterface GigabitEthernet 3\nip address 192.0.2.1 255.255.255.0 secondary\nip\
+ \ address 192.0.2.2 255.255.255.0\nipv6 address autoconfig\nipv6 address 2001:db8:0:3::/64\n"
+ ansible.netcommon.cli_config:
+ config: "{{ lines }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/_remove_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/_remove_config.yaml
new file mode 100644
index 000000000..554173b64
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/_remove_config.yaml
@@ -0,0 +1,8 @@
+---
+- name: L3_interface - remove configuration
+ vars:
+ lines:
+ "interface Loopback 999\nno ip address\ninterface GigabitEthernet 2\nno ip address\nno ipv6 address\ninterface GigabitEthernet 3\nno ip address\nno\
+ \ ipv6 address\n"
+ ansible.netcommon.cli_config:
+ config: "{{ lines }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/deleted.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/deleted.yaml
new file mode 100644
index 000000000..31150d559
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/deleted.yaml
@@ -0,0 +1,41 @@
+---
+- ansible.builtin.debug:
+ msg: Start Deleted integration state for ios_l3_interfaces ansible_connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: L3_interface deleted - delete attributes of provided configured interfaces
+ register: result
+ cisco.ios.ios_l3_interfaces: &id001
+ config:
+ - name: GigabitEthernet2
+ - name: GigabitEthernet3
+ state: deleted
+
+ - name: L3_interface deleted - assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ deleted['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: L3_interface deleted - assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ deleted['before'] | symmetric_difference(result['before']) | length == 0 }}"
+
+ - name: L3_interface deleted - assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ deleted['after'] | symmetric_difference(result['after']) | length == 0 }}"
+
+ - name: L3_interface deleted - delete attributes of all configured interfaces (idempotent)
+ register: result
+ cisco.ios.ios_l3_interfaces: *id001
+ - name: L3_interface deleted - assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result.changed == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/empty_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/empty_config.yaml
new file mode 100644
index 000000000..86dc6d2cf
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/empty_config.yaml
@@ -0,0 +1,58 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_l3_interfaces empty_config.yaml integration tests on connection={{ ansible_connection }}
+
+- name: Merged with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_l3_interfaces:
+ config:
+ state: merged
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state merged'
+
+- name: Replaced with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_l3_interfaces:
+ config:
+ state: replaced
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state replaced'
+
+- name: Overridden with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_l3_interfaces:
+ config:
+ state: overridden
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state overridden'
+
+- name: Rendered with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_l3_interfaces:
+ config:
+ state: rendered
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state rendered'
+
+- name: Parsed with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_l3_interfaces:
+ running_config:
+ state: parsed
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of running_config parameter must not be empty for state parsed'
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/gathered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/gathered.yaml
new file mode 100644
index 000000000..fca604ffb
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/gathered.yaml
@@ -0,0 +1,20 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_l3_interfaces gathered integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: L3_interface gathered - gather the provided configuration
+ register: result
+ cisco.ios.ios_l3_interfaces:
+ config:
+ state: gathered
+
+ - name: L3_interface gathered - assert
+ ansible.builtin.assert:
+ that:
+ - gathered['config'] | symmetric_difference(result.gathered) == []
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/merged.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/merged.yaml
new file mode 100644
index 000000000..06228ea7f
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/merged.yaml
@@ -0,0 +1,51 @@
+---
+- ansible.builtin.debug:
+ msg: START Merged ios_l3_interfaces state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- block:
+ - name: L3_interface merged - merge provided configuration with device configuration
+ register: result
+ cisco.ios.ios_l3_interfaces: &id001
+ config:
+ - name: Loopback999
+ ipv4:
+ - address: 192.0.2.1/24
+ - name: GigabitEthernet2
+ ipv6:
+ - autoconfig:
+ enable: true
+ - name: GigabitEthernet3
+ ipv4:
+ - address: 198.51.100.1/24
+ secondary: true
+ - address: 198.51.100.2/24
+ ipv6:
+ - address: 2001:db8:0:3::/64
+ state: merged
+
+ - name: L3_interface merged - assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: L3_interface merged - assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['before'] | symmetric_difference(result['before']) | length == 0 }}"
+
+ - name: L3_interface merged - assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['after'] | symmetric_difference(result['after']) | length == 0 }}"
+
+ - name: L3_interface merged - merge provided configuration with device configuration (idempotent)
+ register: result
+ cisco.ios.ios_l3_interfaces: *id001
+ - name: L3_interface merged - assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/overridden.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/overridden.yaml
new file mode 100644
index 000000000..0638fc4ed
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/overridden.yaml
@@ -0,0 +1,50 @@
+---
+- ansible.builtin.debug:
+ msg: START Overridden ios_l3_interfaces state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: L3_interface overridden - override device configuration of all interfaces with provided configuration
+ register: result
+ cisco.ios.ios_l3_interfaces: &id001
+ config:
+ - name: GigabitEthernet1
+ ipv4:
+ - dhcp:
+ enable: true
+
+ - name: GigabitEthernet3
+ ipv4:
+ - address: 198.51.100.1/24
+
+ - address: 198.51.100.2/24
+ secondary: true
+ state: overridden
+
+ - name: L3_interface overridden - assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ overridden['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: L3_interface overridden - assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ overridden['before'] | symmetric_difference(result['before']) | length == 0 }}"
+
+ - name: L3_interface overridden - assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ overridden['after'] | symmetric_difference(result['after']) | length == 0 }}"
+
+ - name: L3_interface overridden - override device configuration of all interfaces with provided configuration (idempotent)
+ register: result
+ cisco.ios.ios_l3_interfaces: *id001
+ - name: L3_interface overridden - assert that task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/parsed.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/parsed.yaml
new file mode 100644
index 000000000..780b59051
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/parsed.yaml
@@ -0,0 +1,15 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_l3_interfaces parsed integration tests on connection={{ ansible_connection }}
+
+- name: L3_interface parsed - parse the commands for provided configuration
+ become: true
+ register: result
+ cisco.ios.ios_l3_interfaces:
+ running_config: "{{ lookup('file', '_parsed.cfg') }}"
+ state: parsed
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - parsed['config']|symmetric_difference(result.parsed) == []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/rendered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/rendered.yaml
new file mode 100644
index 000000000..f1d0f4da5
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/rendered.yaml
@@ -0,0 +1,36 @@
+---
+- ansible.builtin.debug:
+ msg: Start ios_l3_interfaces rendered integration tests ansible_connection={{ ansible_connection }}
+
+- block:
+ - name: Render the commands for provided configuration
+ become: true
+ register: result
+ cisco.ios.ios_l3_interfaces:
+ config:
+ - name: Loopback999
+ ipv4:
+ - address: 192.0.2.1/24
+ - name: GigabitEthernet2
+ ipv4:
+ - dhcp:
+ client_id: GigabitEthernet0/0
+ hostname: test.com
+ ipv6:
+ - autoconfig:
+ enable: true
+ - name: GigabitEthernet3
+ ipv4:
+ - address: 198.51.100.1/24
+ secondary: true
+ - address: 198.51.100.2/24
+ ipv6:
+ - dhcp:
+ enable: true
+ - address: 2001:db8:0:3::/64
+ state: rendered
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - result.rendered|symmetric_difference(rendered.commands) == []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/replaced.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/replaced.yaml
new file mode 100644
index 000000000..1fcac9968
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/replaced.yaml
@@ -0,0 +1,51 @@
+---
+- ansible.builtin.debug:
+ msg: START Replaced ios_l3_interfaces state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: L3_interface replaced - replaces device configuration of listed interfaces with provided configuration
+ register: result
+ cisco.ios.ios_l3_interfaces: &id001
+ config:
+ - name: GigabitEthernet2
+ ipv4:
+ - address: 203.0.114.1/24
+
+ - name: GigabitEthernet3
+ ipv4:
+ - address: 198.51.100.1/24
+ secondary: true
+
+ - address: 198.51.100.2/24
+ ipv6:
+ - address: 2001:db8:1:1::/64
+ state: replaced
+
+ - name: L3_interface replaced - assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ replaced['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: L3_interface replaced - assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ replaced['before'] | symmetric_difference(result['before']) | length == 0 }}"
+
+ - name: L3_interface replaced - assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ replaced['after'] | symmetric_difference(result['after']) | length == 0 }}"
+
+ - name: L3_interface replaced - replaces device configuration of listed interfaces with provided configuration (idempotent)
+ register: result
+ cisco.ios.ios_l3_interfaces: *id001
+ - name: L3_interface replaced - assert that task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/rtt.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/rtt.yaml
new file mode 100644
index 000000000..3b3eb2d7f
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/tests/cli/rtt.yaml
@@ -0,0 +1,60 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_l3_interfaces round trip integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- block:
+ - name: L3_interface RTT - apply the provided configuration (base config)
+ register: result
+ cisco.ios.ios_l3_interfaces:
+ config:
+ - name: Loopback999
+ ipv4:
+ - address: 192.0.2.1/24
+ - name: GigabitEthernet1
+ ipv4:
+ - dhcp:
+ enable: true
+ - name: GigabitEthernet3
+ ipv4:
+ - address: 198.51.100.1/24
+ secondary: true
+ - address: 198.51.100.2/24
+ ipv6:
+ - address: 2001:db8:0:3::/64
+ state: merged
+
+ - name: L3_interface RTT - gather layer 3 interfaces facts
+ cisco.ios.ios_facts:
+ gather_subset:
+ - "!all"
+ - "!min"
+ gather_network_resources:
+ - l3_interfaces
+
+ - name: L3_interface RTT - apply the provided configuration (config to be reverted)
+ # register: result
+ cisco.ios.ios_l3_interfaces:
+ config:
+ - name: Loopback999
+ ipv4:
+ - address: 192.0.2.2/24
+ - name: GigabitEthernet1
+ ipv4:
+ - dhcp:
+ enable: true
+ state: replaced
+
+ - name: L3_interface RTT - revert back to base configuration using facts round trip
+ register: revert
+ cisco.ios.ios_l3_interfaces:
+ config: "{{ ansible_facts['network_resources']['l3_interfaces'] }}"
+ state: overridden
+
+ - ansible.builtin.assert:
+ that:
+ - revert.changed == true
+ - "{{ revert['commands'] | symmetric_difference(rtt['commands']) | length == 0 }}"
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/vars/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/vars/main.yaml
new file mode 100644
index 000000000..44ca9b85e
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_l3_interfaces/vars/main.yaml
@@ -0,0 +1,239 @@
+---
+merged:
+ before:
+ - name: Loopback888
+ - name: Loopback999
+ - ipv4:
+ - dhcp:
+ enable: true
+ name: GigabitEthernet1
+ - name: GigabitEthernet2
+ - name: GigabitEthernet3
+ - name: GigabitEthernet4
+ commands:
+ - interface loopback999
+ - ip address 192.0.2.1 255.255.255.0
+ - interface GigabitEthernet2
+ - ipv6 address autoconfig
+ - interface GigabitEthernet3
+ - ip address 198.51.100.1 255.255.255.0 secondary
+ - ip address 198.51.100.2 255.255.255.0
+ - ipv6 address 2001:db8:0:3::/64
+ after:
+ - name: Loopback888
+ - ipv4:
+ - address: 192.0.2.1/24
+ name: Loopback999
+ - ipv4:
+ - dhcp:
+ enable: true
+ name: GigabitEthernet1
+ - ipv6:
+ - autoconfig:
+ enable: true
+ name: GigabitEthernet2
+ - ipv4:
+ - address: 198.51.100.1/24
+ secondary: true
+ - address: 198.51.100.2/24
+ ipv6:
+ - address: 2001:DB8:0:3::/64
+ name: GigabitEthernet3
+ - name: GigabitEthernet4
+
+replaced:
+ before:
+ - name: Loopback888
+ - name: Loopback999
+ - ipv4:
+ - dhcp:
+ enable: true
+ name: GigabitEthernet1
+ - ipv4:
+ - address: 203.0.113.27/24
+ name: GigabitEthernet2
+ - ipv4:
+ - address: 192.0.2.1/24
+ secondary: true
+ - address: 192.0.2.2/24
+ ipv6:
+ - address: 2001:DB8:0:3::/64
+ - autoconfig:
+ enable: true
+ name: GigabitEthernet3
+ - name: GigabitEthernet4
+ commands:
+ - interface GigabitEthernet2
+ - no ip address 203.0.113.27 255.255.255.0
+ - ip address 203.0.114.1 255.255.255.0
+ - interface GigabitEthernet3
+ - no ipv6 address autoconfig
+ - no ipv6 address 2001:db8:0:3::/64
+ - no ip address 192.0.2.2 255.255.255.0
+ - no ip address 192.0.2.1 255.255.255.0 secondary
+ - ipv6 address 2001:db8:1:1::/64
+ - ip address 198.51.100.2 255.255.255.0
+ - ip address 198.51.100.1 255.255.255.0 secondary
+ after:
+ - name: Loopback888
+ - name: Loopback999
+ - ipv4:
+ - dhcp:
+ enable: true
+ name: GigabitEthernet1
+ - ipv4:
+ - address: 203.0.114.1/24
+ name: GigabitEthernet2
+ - ipv4:
+ - address: 198.51.100.1/24
+ secondary: true
+ - address: 198.51.100.2/24
+ ipv6:
+ - address: 2001:DB8:1:1::/64
+ name: GigabitEthernet3
+ - name: GigabitEthernet4
+
+overridden:
+ before:
+ - name: Loopback888
+ - name: Loopback999
+ - ipv4:
+ - dhcp:
+ enable: true
+ name: GigabitEthernet1
+ - ipv4:
+ - address: 203.0.113.27/24
+ name: GigabitEthernet2
+ - ipv4:
+ - address: 192.0.2.1/24
+ secondary: true
+ - address: 192.0.2.2/24
+ ipv6:
+ - address: 2001:DB8:0:3::/64
+ - autoconfig:
+ enable: true
+ name: GigabitEthernet3
+ - name: GigabitEthernet4
+ commands:
+ - interface GigabitEthernet2
+ - no ip address 203.0.113.27 255.255.255.0
+ - interface GigabitEthernet3
+ - no ipv6 address autoconfig
+ - no ipv6 address 2001:db8:0:3::/64
+ - no ip address 192.0.2.2 255.255.255.0
+ - no ip address 192.0.2.1 255.255.255.0 secondary
+ - ip address 198.51.100.2 255.255.255.0 secondary
+ - ip address 198.51.100.1 255.255.255.0
+ after:
+ - name: Loopback888
+ - name: Loopback999
+ - ipv4:
+ - dhcp:
+ enable: true
+ name: GigabitEthernet1
+ - name: GigabitEthernet2
+ - ipv4:
+ - address: 198.51.100.2/24
+ secondary: true
+ - address: 198.51.100.1/24
+ name: GigabitEthernet3
+ - name: GigabitEthernet4
+
+deleted:
+ before:
+ - ipv4:
+ - dhcp:
+ enable: true
+ name: GigabitEthernet1
+ - ipv4:
+ - address: 203.0.113.27/24
+ name: GigabitEthernet2
+ - ipv4:
+ - address: 192.0.2.1/24
+ secondary: true
+ - address: 192.0.2.2/24
+ ipv6:
+ - address: 2001:DB8:0:3::/64
+ - autoconfig:
+ enable: true
+ name: GigabitEthernet3
+ - name: GigabitEthernet4
+ - name: Loopback888
+ - name: Loopback999
+ commands:
+ - interface GigabitEthernet2
+ - no ip address 203.0.113.27 255.255.255.0
+ - interface GigabitEthernet3
+ - no ip address 192.0.2.1 255.255.255.0 secondary
+ - no ip address 192.0.2.2 255.255.255.0
+ - no ipv6 address 2001:db8:0:3::/64
+ - no ipv6 address autoconfig
+ after:
+ - name: Loopback888
+ - name: Loopback999
+ - ipv4:
+ - dhcp:
+ enable: true
+ name: GigabitEthernet1
+ - name: GigabitEthernet2
+ - name: GigabitEthernet3
+ - name: GigabitEthernet4
+
+gathered:
+ config:
+ - name: Loopback888
+ - name: Loopback999
+ - ipv4:
+ - dhcp:
+ enable: true
+ name: GigabitEthernet1
+ - ipv4:
+ - address: 203.0.113.27/24
+ name: GigabitEthernet2
+ - ipv4:
+ - address: 192.0.2.1/24
+ secondary: true
+ - address: 192.0.2.2/24
+ ipv6:
+ - address: 2001:DB8:0:3::/64
+ - autoconfig:
+ enable: true
+ name: GigabitEthernet3
+ - name: GigabitEthernet4
+
+parsed:
+ config:
+ - ipv4:
+ - dhcp:
+ client_id: GigabitEthernet0/0
+ enable: true
+ hostname: test.com
+ name: GigabitEthernet2
+ - ipv4:
+ - address: 198.51.100.1/24
+ secondary: true
+ - address: 198.51.100.2/24
+ ipv6:
+ - autoconfig:
+ enable: true
+ - address: 2001:db8:0:3::/64
+ name: GigabitEthernet3
+
+rtt:
+ commands:
+ - interface loopback999
+ - no ip address 192.0.2.2 255.255.255.0
+ - ip address 192.0.2.1 255.255.255.0
+
+rendered:
+ commands:
+ - interface loopback999
+ - ip address 192.0.2.1 255.255.255.0
+ - interface GigabitEthernet2
+ - ip address dhcp client-id GigabitEthernet0/0 hostname test.com
+ - ipv6 address autoconfig
+ - interface GigabitEthernet3
+ - ip address 198.51.100.1 255.255.255.0 secondary
+ - ip address 198.51.100.2 255.255.255.0
+ - ipv6 address dhcp
+ - ipv6 address 2001:db8:0:3::/64
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/aliases b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/aliases
new file mode 100644
index 000000000..6bb69158a
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/aliases
@@ -0,0 +1 @@
+shippable/ios/group1
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/defaults/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/defaults/main.yaml
new file mode 100644
index 000000000..164afead2
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/meta/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/meta/main.yaml
new file mode 100644
index 000000000..23d65c7ef
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/meta/main.yaml
@@ -0,0 +1,2 @@
+---
+dependencies: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tasks/cli.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tasks/cli.yaml
new file mode 100644
index 000000000..25c50045a
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tasks/cli.yaml
@@ -0,0 +1,25 @@
+---
+- name: Collect all CLI test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+ delegate_to: localhost
+
+- name: Get the IOS version
+ cisco.ios.ios_facts:
+ gather_subset: all
+
+- name: Run test case (connection=ansible.netcommon.network_cli)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.network_cli
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tasks/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tasks/main.yaml
new file mode 100644
index 000000000..a9773ae64
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tasks/main.yaml
@@ -0,0 +1,5 @@
+---
+- name: Main task for lacp module
+ ansible.builtin.include_tasks: cli.yaml
+ tags:
+ - network_cli
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tests/cli/_parsed.cfg b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tests/cli/_parsed.cfg
new file mode 100644
index 000000000..ae49b0d45
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tests/cli/_parsed.cfg
@@ -0,0 +1 @@
+123, 5e00.0000.8000
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tests/cli/_populate_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tests/cli/_populate_config.yaml
new file mode 100644
index 000000000..737d5b638
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tests/cli/_populate_config.yaml
@@ -0,0 +1,7 @@
+---
+- name: Populate configuration
+ vars:
+ lines: "lacp system-priority 500\n"
+ when: ansible_net_version != "15.6(2)T"
+ ansible.netcommon.cli_config:
+ config: "{{ lines }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tests/cli/_remove_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tests/cli/_remove_config.yaml
new file mode 100644
index 000000000..ef9dcd5e8
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tests/cli/_remove_config.yaml
@@ -0,0 +1,7 @@
+---
+- name: Remove configuration
+ vars:
+ lines: "no lacp system-priority\n"
+ when: ansible_net_version != "15.6(2)T"
+ ansible.netcommon.cli_config:
+ config: "{{ lines }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tests/cli/deleted.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tests/cli/deleted.yaml
new file mode 100644
index 000000000..50e83f768
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tests/cli/deleted.yaml
@@ -0,0 +1,39 @@
+---
+- ansible.builtin.debug:
+ msg: Start Deleted integration state for ios_lacp ansible_connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Delete configured system lacp
+ register: result
+ cisco.ios.ios_lacp: &id001
+ state: deleted
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ deleted['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ deleted['before'] == result['before'] }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ deleted['before'] == result['before'] }}"
+
+ - name: Delete configured system lacp (idempotent)
+ register: result
+ cisco.ios.ios_lacp: *id001
+ - name: Assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result.changed == false
+ when: ansible_net_version != "15.6(2)T"
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tests/cli/empty_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tests/cli/empty_config.yaml
new file mode 100644
index 000000000..b120779e0
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tests/cli/empty_config.yaml
@@ -0,0 +1,49 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_lacp empty_config.yaml integration tests on connection={{ ansible_connection }}
+
+- block:
+ - name: Merged with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_lacp:
+ config:
+ state: merged
+
+ - ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state merged'
+
+ - name: Replaced with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_lacp:
+ config:
+ state: replaced
+
+ - ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state replaced'
+
+ - name: Rendered with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_lacp:
+ config:
+ state: rendered
+
+ - ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state rendered'
+
+ - name: Parsed with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_lacp:
+ running_config:
+ state: parsed
+
+ - ansible.builtin.assert:
+ that:
+ - result.msg == 'value of running_config parameter must not be empty for state parsed'
+ when: ansible_net_version != "15.6(2)T"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tests/cli/gathered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tests/cli/gathered.yaml
new file mode 100644
index 000000000..e555569ff
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tests/cli/gathered.yaml
@@ -0,0 +1,21 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_lacp gathered integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Gather the provided configuration with the existing running configuration
+ register: result
+ cisco.ios.ios_lacp:
+ config:
+ state: gathered
+
+ - name: Assert
+ ansible.builtin.assert:
+ that:
+ - "{{result['gathered'] == gathered['config'] }}"
+ - result['changed'] == false
+ when: ansible_net_version != "15.6(2)T"
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tests/cli/merged.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tests/cli/merged.yaml
new file mode 100644
index 000000000..110a3e23c
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tests/cli/merged.yaml
@@ -0,0 +1,40 @@
+---
+- ansible.builtin.debug:
+ msg: START Merged ios_lacp state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- block:
+ - name: Merge provided configuration system lacp
+ register: result
+ cisco.ios.ios_lacp: &id001
+ config:
+ system:
+ priority: 10
+ state: merged
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['before'] == result['before'] }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['before'] == result['before'] }}"
+
+ - name: Merge provided configuration system lacp (idempotent)
+ register: result
+ cisco.ios.ios_lacp: *id001
+ - name: Assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ when: ansible_net_version != "15.6(2)T"
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tests/cli/parsed.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tests/cli/parsed.yaml
new file mode 100644
index 000000000..ab1f57894
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tests/cli/parsed.yaml
@@ -0,0 +1,17 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_lacp parsed integration tests on connection={{ ansible_connection }}
+
+- block:
+ - name: Parse the commands for provided configuration
+ become: true
+ register: result
+ cisco.ios.ios_lacp:
+ running_config: "{{ lookup('file', '_parsed.cfg') }}"
+ state: parsed
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - "{{result['parsed'] == parsed['config'] }}"
+ when: ansible_net_version != "15.6(2)T"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tests/cli/rendered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tests/cli/rendered.yaml
new file mode 100644
index 000000000..1d520a73e
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tests/cli/rendered.yaml
@@ -0,0 +1,19 @@
+---
+- ansible.builtin.debug:
+ msg: Start ios_lacp rendered integration tests ansible_connection={{ ansible_connection }}
+
+- block:
+ - name: Render the commands for provided configuration
+ become: true
+ register: result
+ cisco.ios.ios_lacp:
+ config:
+ system:
+ priority: 10
+ state: rendered
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - result.rendered|symmetric_difference(merged.commands) == []
+ when: ansible_net_version != "15.6(2)T"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tests/cli/replaced.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tests/cli/replaced.yaml
new file mode 100644
index 000000000..2f3d38fb5
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/tests/cli/replaced.yaml
@@ -0,0 +1,42 @@
+---
+- ansible.builtin.debug:
+ msg: START Replaced ios_lacp state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Replaces system lacp configuration provided lacp configuration
+ register: result
+ cisco.ios.ios_lacp: &id001
+ config:
+ system:
+ priority: 20
+ state: replaced
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ replaced['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ replaced['before'] == result['before'] }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ replaced['before'] == result['before'] }}"
+
+ - name: Replaces system lacp configuration provided lacp configuration (idempotent)
+ register: result
+ cisco.ios.ios_lacp: *id001
+ - name: Assert that task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ when: ansible_net_version != "15.6(2)T"
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/vars/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/vars/main.yaml
new file mode 100644
index 000000000..5c3611f4b
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp/vars/main.yaml
@@ -0,0 +1,38 @@
+---
+merged:
+ before:
+ system:
+ priority: 32768
+ commands:
+ - lacp system-priority 10
+ after:
+ - system:
+ priority: 10
+replaced:
+ before:
+ system:
+ priority: 500
+ commands:
+ - lacp system-priority 20
+ after:
+ system:
+ priority: 20
+deleted:
+ before:
+ system:
+ priority: 500
+ commands:
+ - no lacp system-priority
+ after:
+ system:
+ priority: 32768
+
+gathered:
+ config:
+ system:
+ priority: 500
+
+parsed:
+ config:
+ system:
+ priority: 123
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/defaults/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/defaults/main.yaml
new file mode 100644
index 000000000..164afead2
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tasks/cli.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tasks/cli.yaml
new file mode 100644
index 000000000..25c50045a
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tasks/cli.yaml
@@ -0,0 +1,25 @@
+---
+- name: Collect all CLI test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+ delegate_to: localhost
+
+- name: Get the IOS version
+ cisco.ios.ios_facts:
+ gather_subset: all
+
+- name: Run test case (connection=ansible.netcommon.network_cli)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.network_cli
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tasks/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tasks/main.yaml
new file mode 100644
index 000000000..a9773ae64
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tasks/main.yaml
@@ -0,0 +1,5 @@
+---
+- name: Main task for lacp module
+ ansible.builtin.include_tasks: cli.yaml
+ tags:
+ - network_cli
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/_add_port_channels.yml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/_add_port_channels.yml
new file mode 100644
index 000000000..b53822c04
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/_add_port_channels.yml
@@ -0,0 +1,7 @@
+---
+- name: Add Port-channels for tests
+ cisco.ios.ios_interfaces:
+ config:
+ - name: Port-channel10
+ - name: Port-channel40
+ state: merged
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/_parsed.cfg b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/_parsed.cfg
new file mode 100644
index 000000000..e3209c7f6
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/_parsed.cfg
@@ -0,0 +1,7 @@
+interface GigabitEthernet2
+ lacp port-priority 10
+interface GigabitEthernet3
+ lacp port-priority 20
+interface Port-channel10
+ lacp max-bundle 2
+ lacp fast-switchover
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/_populate_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/_populate_config.yaml
new file mode 100644
index 000000000..51514c511
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/_populate_config.yaml
@@ -0,0 +1,9 @@
+---
+- name: Populate configuration
+ vars:
+ lines:
+ "interface GigabitEthernet 2\nlacp port-priority 30\ninterface GigabitEthernet 3\nlacp port-priority 20\ninterface Port-channel 10\nlacp fast-switchover\n\
+ lacp max-bundle 2\ninterface Port-channel 40\nlacp max-bundle 4\ninterface loopback888\ninterface loopback999\n"
+ when: ansible_net_version != "15.6(2)T"
+ ansible.netcommon.cli_config:
+ config: "{{ lines }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/_remove_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/_remove_config.yaml
new file mode 100644
index 000000000..8544171de
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/_remove_config.yaml
@@ -0,0 +1,19 @@
+---
+- name: Remove configuration
+ vars:
+ lines:
+ "interface GigabitEthernet 2\nno lacp port-priority\ninterface GigabitEthernet 3\nno lacp port-priority\ninterface Port-channel 10\nno lacp fast-switchover\n\
+ no lacp max-bundle\ninterface Port-channel 40\nno lacp fast-switchover\nno lacp max-bundle\n"
+ when: ansible_net_version != "15.6(2)T"
+ ansible.netcommon.cli_config:
+ config: "{{ lines }}"
+
+- name: Delete attributes of all configured interfaces
+ register: result
+ cisco.ios.ios_interfaces:
+ config:
+ - name: Port-channel10
+ - name: Port-channel11
+ - name: Port-channel22
+ - name: Port-channel40
+ state: purged
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/deleted.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/deleted.yaml
new file mode 100644
index 000000000..dffd32e1d
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/deleted.yaml
@@ -0,0 +1,39 @@
+---
+- ansible.builtin.debug:
+ msg: Start Deleted integration state for ios_lacp_interfaces ansible_connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Delete lacp attributes for all configured interfaces
+ register: result
+ cisco.ios.ios_lacp_interfaces: &id001
+ state: deleted
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ deleted['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ deleted['before'] | symmetric_difference(result['before']) | length == 0 }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ deleted['after'] | symmetric_difference(result['after']) | length == 0 }}"
+
+ - name: Delete lacp attributes for all configured interfaces (idempotent)
+ register: result
+ cisco.ios.ios_lacp_interfaces: *id001
+ - name: Assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result.changed == false
+ when: ansible_net_version != "15.6(2)T"
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/empty_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/empty_config.yaml
new file mode 100644
index 000000000..67fa01bca
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/empty_config.yaml
@@ -0,0 +1,60 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_lacp_interfaces empty_config.yaml integration tests on connection={{ ansible_connection }}
+
+- block:
+ - name: Merged with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_lacp_interfaces:
+ config:
+ state: merged
+
+ - ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state merged'
+
+ - name: Replaced with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_lacp_interfaces:
+ config:
+ state: replaced
+
+ - ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state replaced'
+
+ - name: Overridden with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_lacp_interfaces:
+ config:
+ state: overridden
+
+ - ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state overridden'
+
+ - name: Rendered with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_lacp_interfaces:
+ config:
+ state: rendered
+
+ - ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state rendered'
+
+ - name: Parsed with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_lacp_interfaces:
+ running_config:
+ state: parsed
+
+ - ansible.builtin.assert:
+ that:
+ - result.msg == 'value of running_config parameter must not be empty for state parsed'
+ when: ansible_net_version != "15.6(2)T"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/gathered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/gathered.yaml
new file mode 100644
index 000000000..633da0a9b
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/gathered.yaml
@@ -0,0 +1,21 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_lacp_interfaces gathered integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Gather the provided configuration with the existing running configuration
+ register: result
+ cisco.ios.ios_lacp_interfaces:
+ config:
+ state: gathered
+
+ - name: Assert
+ ansible.builtin.assert:
+ that:
+ - gathered['config'] | symmetric_difference(result.gathered) == []
+ - result['changed'] == false
+ when: ansible_net_version != "15.6(2)T"
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/merged.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/merged.yaml
new file mode 100644
index 000000000..d06219c62
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/merged.yaml
@@ -0,0 +1,47 @@
+---
+- ansible.builtin.debug:
+ msg: START Merged ios_lacp_interfaces state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+- ansible.builtin.include_tasks: _add_port_channels.yml
+- block:
+ - name: Merge the provided configuration with the existing running configuration
+ register: result
+ cisco.ios.ios_lacp_interfaces: &id001
+ config:
+ - name: GigabitEthernet2
+ port_priority: 30
+
+ - name: GigabitEthernet3
+ port_priority: 20
+
+ - name: Port-channel10
+ fast_switchover: true
+ max_bundle: 2
+ state: merged
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['before'] | symmetric_difference(result['before']) | length == 0 }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['after'] | symmetric_difference(result['after']) | length == 0 }}"
+
+ - name: Merge the provided configuration with the existing running configuration (idempotent)
+ register: result
+ cisco.ios.ios_lacp_interfaces: *id001
+ - name: Assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ when: ansible_net_version != "15.6(2)T"
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/overridden.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/overridden.yaml
new file mode 100644
index 000000000..28d1de3f2
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/overridden.yaml
@@ -0,0 +1,45 @@
+---
+- ansible.builtin.debug:
+ msg: START Overridden ios_lacp_interfaces state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Override device configuration of all lacp_interfaces with provided configuration
+ register: result
+ cisco.ios.ios_lacp_interfaces: &id001
+ config:
+ - name: GigabitEthernet3
+ port_priority: 40
+ - name: Port-channel40
+ fast_switchover: true
+ max_bundle: 2
+ state: overridden
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ overridden['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ overridden['before'] | symmetric_difference(result['before']) | length == 0 }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ overridden['after'] | symmetric_difference(result['after']) | length == 0 }}"
+
+ - name: Override device configuration of all lacp_interfaces with provided configuration (idempotent)
+ register: result
+ cisco.ios.ios_lacp_interfaces: *id001
+ - name: Assert that task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ when: ansible_net_version != "15.6(2)T"
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/parsed.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/parsed.yaml
new file mode 100644
index 000000000..d670245a0
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/parsed.yaml
@@ -0,0 +1,17 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_lacp_interfaces parsed integration tests on connection={{ ansible_connection }}
+
+- block:
+ - name: Parse the commands for provided configuration
+ become: true
+ register: result
+ cisco.ios.ios_lacp_interfaces:
+ running_config: "{{ lookup('file', '_parsed.cfg') }}"
+ state: parsed
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - parsed['config']|symmetric_difference(result.parsed) == []
+ when: ansible_net_version != "15.6(2)T"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/rendered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/rendered.yaml
new file mode 100644
index 000000000..96405701e
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/rendered.yaml
@@ -0,0 +1,24 @@
+---
+- ansible.builtin.debug:
+ msg: Start ios_lacp_interfaces rendered integration tests ansible_connection={{ ansible_connection }}
+
+- block:
+ - name: Render the commands for provided configuration
+ become: true
+ register: result
+ cisco.ios.ios_lacp_interfaces:
+ config:
+ - name: GigabitEthernet2
+ port_priority: 30
+ - name: GigabitEthernet3
+ port_priority: 20
+ - name: Port-channel10
+ fast_switchover: true
+ max_bundle: 2
+ state: rendered
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - result.rendered|symmetric_difference(merged.commands) == []
+ when: ansible_net_version != "15.6(2)T"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/replaced.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/replaced.yaml
new file mode 100644
index 000000000..0fec8cdd7
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/replaced.yaml
@@ -0,0 +1,45 @@
+---
+- ansible.builtin.debug:
+ msg: START Replaced ios_lacp_interfaces state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Replaces device configuration of listed lacp_interfaces with provided configuration
+ register: result
+ cisco.ios.ios_lacp_interfaces: &id001
+ config:
+ - name: GigabitEthernet2
+ port_priority: 10
+
+ - name: Port-channel40
+ fast_switchover: true
+ state: replaced
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ replaced['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ replaced['before'] | symmetric_difference(result['before']) | length == 0 }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ replaced['after'] | symmetric_difference(result['after']) | length == 0 }}"
+
+ - name: Replaces device configuration of listed lacp_interfaces with provided configuration (idempotent)
+ register: result
+ cisco.ios.ios_lacp_interfaces: *id001
+ - name: Assert that task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ when: ansible_net_version != "15.6(2)T"
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/rtt.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/rtt.yaml
new file mode 100644
index 000000000..74c63f6b6
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/tests/cli/rtt.yaml
@@ -0,0 +1,57 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_lacp_interfaces round trip integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- block:
+ - name: Apply the provided configuration (base config)
+ register: base_config
+ cisco.ios.ios_lacp_interfaces:
+ config:
+ - name: GigabitEthernet2
+ port_priority: 30
+ - name: GigabitEthernet3
+ port_priority: 20
+ - name: Port-channel10
+ fast_switchover: true
+ max_bundle: 2
+ state: merged
+
+ - name: Gather lacp interfaces facts
+ cisco.ios.ios_facts:
+ gather_subset:
+ - "!all"
+ - "!min"
+ gather_network_resources:
+ - lacp_interfaces
+
+ - name: Apply the provided configuration (config to be reverted)
+ register: result
+ cisco.ios.ios_lacp_interfaces:
+ config:
+ - name: GigabitEthernet3
+ port_priority: 40
+ - name: Port-channel40
+ fast_switchover: true
+ max_bundle: 2
+ state: overridden
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - result.commands|symmetric_difference(overridden_rtt.commands) == []
+
+ - name: Revert back to base configuration using facts round trip
+ register: revert
+ cisco.ios.ios_lacp_interfaces:
+ config: "{{ ansible_facts['network_resources']['lacp_interfaces'] }}"
+ state: overridden
+
+ - ansible.builtin.assert:
+ that:
+ - revert.changed == true
+ - revert.commands|symmetric_difference(rtt.commands) == []
+ when: ansible_net_version != "15.6(2)T"
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/vars/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/vars/main.yaml
new file mode 100644
index 000000000..9adf18f04
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lacp_interfaces/vars/main.yaml
@@ -0,0 +1,181 @@
+---
+merged:
+ before:
+ - name: loopback888
+ - name: loopback999
+ - name: Port-channel10
+ - name: Port-channel40
+ - name: GigabitEthernet1
+ - name: GigabitEthernet2
+ - name: GigabitEthernet3
+ - name: GigabitEthernet4
+ commands:
+ - interface GigabitEthernet2
+ - lacp port-priority 30
+ - interface GigabitEthernet3
+ - lacp port-priority 20
+ - interface Port-channel10
+ - lacp max-bundle 2
+ - lacp fast-switchover
+ after:
+ - name: loopback888
+ - name: loopback999
+ - fast_switchover: true
+ max_bundle: 2
+ name: Port-channel10
+ - name: Port-channel40
+ - name: GigabitEthernet1
+ - name: GigabitEthernet2
+ port_priority: 30
+ - name: GigabitEthernet3
+ port_priority: 20
+ - name: GigabitEthernet4
+
+replaced:
+ before:
+ - name: loopback888
+ - name: loopback999
+ - fast_switchover: true
+ max_bundle: 2
+ name: Port-channel10
+ - name: Port-channel40
+ - name: GigabitEthernet1
+ - name: GigabitEthernet2
+ port_priority: 30
+ - name: GigabitEthernet3
+ port_priority: 20
+ - name: GigabitEthernet4
+ commands:
+ - interface GigabitEthernet2
+ - lacp port-priority 10
+ - interface Port-channel40
+ - lacp fast-switchover
+ after:
+ - name: loopback888
+ - name: loopback999
+ - fast_switchover: true
+ max_bundle: 2
+ name: Port-channel10
+ - fast_switchover: true
+ name: Port-channel40
+ - name: GigabitEthernet1
+ - name: GigabitEthernet2
+ port_priority: 10
+ - name: GigabitEthernet3
+ port_priority: 20
+ - name: GigabitEthernet4
+
+overridden:
+ before:
+ - name: loopback888
+ - name: loopback999
+ - fast_switchover: true
+ max_bundle: 2
+ name: Port-channel10
+ - name: GigabitEthernet1
+ - name: Port-channel40
+ - name: GigabitEthernet2
+ port_priority: 30
+ - name: GigabitEthernet3
+ port_priority: 20
+ - name: GigabitEthernet4
+ commands:
+ - interface GigabitEthernet2
+ - no lacp port-priority
+ - interface GigabitEthernet3
+ - lacp port-priority 40
+ - interface Port-channel10
+ - no lacp fast-switchover
+ - no lacp max-bundle
+ - interface Port-channel40
+ - lacp fast-switchover
+ - lacp max-bundle 2
+ after:
+ - name: loopback888
+ - name: loopback999
+ - name: Port-channel10
+ - fast_switchover: true
+ max_bundle: 2
+ name: Port-channel40
+ - name: GigabitEthernet1
+ - name: GigabitEthernet2
+ - name: GigabitEthernet3
+ port_priority: 40
+ - name: GigabitEthernet4
+
+deleted:
+ before:
+ - name: loopback888
+ - name: loopback999
+ - fast_switchover: true
+ max_bundle: 2
+ name: Port-channel10
+ - name: Port-channel40
+ - name: GigabitEthernet1
+ - name: GigabitEthernet2
+ port_priority: 30
+ - name: GigabitEthernet3
+ port_priority: 20
+ - name: GigabitEthernet4
+ commands:
+ - interface GigabitEthernet2
+ - no lacp port-priority
+ - interface GigabitEthernet3
+ - no lacp port-priority
+ - interface Port-channel10
+ - no lacp fast-switchover
+ - no lacp max-bundle
+ after:
+ - name: loopback888
+ - name: loopback999
+ - name: Port-channel10
+ - name: Port-channel40
+ - name: GigabitEthernet1
+ - name: GigabitEthernet2
+ - name: GigabitEthernet3
+ - name: GigabitEthernet4
+
+gathered:
+ config:
+ - name: loopback888
+ - name: loopback999
+ - fast_switchover: true
+ max_bundle: 2
+ name: Port-channel10
+ - name: Port-channel40
+ - name: GigabitEthernet1
+ - name: GigabitEthernet2
+ port_priority: 30
+ - name: GigabitEthernet3
+ port_priority: 20
+ - name: GigabitEthernet4
+
+parsed:
+ config:
+ - name: GigabitEthernet2
+ port_priority: 10
+ - name: GigabitEthernet3
+ port_priority: 20
+ - fast_switchover: true
+ max_bundle: 2
+ name: Port-channel10
+
+overridden_rtt:
+ commands:
+ - interface Port-channel10
+ - no lacp max-bundle
+ - no lacp fast-switchover
+ - interface GigabitEthernet2
+ - no lacp port-priority
+ - interface GigabitEthernet3
+ - lacp port-priority 40
+
+rtt:
+ commands:
+ - interface Port-channel10
+ - lacp max-bundle 2
+ - lacp fast-switchover
+ - interface GigabitEthernet2
+ - lacp port-priority 30
+ - interface GigabitEthernet3
+ - lacp port-priority 20
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/defaults/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/defaults/main.yaml
new file mode 100644
index 000000000..164afead2
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/meta/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/meta/main.yaml
new file mode 100644
index 000000000..23d65c7ef
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/meta/main.yaml
@@ -0,0 +1,2 @@
+---
+dependencies: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tasks/cli.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tasks/cli.yaml
new file mode 100644
index 000000000..25c50045a
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tasks/cli.yaml
@@ -0,0 +1,25 @@
+---
+- name: Collect all CLI test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+ delegate_to: localhost
+
+- name: Get the IOS version
+ cisco.ios.ios_facts:
+ gather_subset: all
+
+- name: Run test case (connection=ansible.netcommon.network_cli)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.network_cli
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tasks/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tasks/main.yaml
new file mode 100644
index 000000000..0ee0eca11
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tasks/main.yaml
@@ -0,0 +1,5 @@
+---
+- name: Main task for lag_interfaces module
+ ansible.builtin.include_tasks: cli.yaml
+ tags:
+ - network_cli
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/_add_port_channels.yml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/_add_port_channels.yml
new file mode 100644
index 000000000..b53822c04
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/_add_port_channels.yml
@@ -0,0 +1,7 @@
+---
+- name: Add Port-channels for tests
+ cisco.ios.ios_interfaces:
+ config:
+ - name: Port-channel10
+ - name: Port-channel40
+ state: merged
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/_parsed.cfg b/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/_parsed.cfg
new file mode 100644
index 000000000..ff4cce038
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/_parsed.cfg
@@ -0,0 +1,4 @@
+interface GigabitEthernet2
+ channel-group 11 mode active
+interface GigabitEthernet3
+ channel-group 22 mode passive
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/_populate_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/_populate_config.yaml
new file mode 100644
index 000000000..faf1cf9e3
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/_populate_config.yaml
@@ -0,0 +1,9 @@
+---
+- name: Populate configuration
+ vars:
+ lines: "interface GigabitEthernet 2\nchannel-group 11 mode active\ninterface GigabitEthernet 3\nchannel-group 22 mode active\n"
+ when: ansible_net_version != "15.6(2)T"
+ ansible.netcommon.cli_config:
+ config: "{{ lines }}"
+
+- ansible.builtin.include_tasks: _add_port_channels.yml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/_populate_port_channel.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/_populate_port_channel.yaml
new file mode 100644
index 000000000..42329c733
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/_populate_port_channel.yaml
@@ -0,0 +1,7 @@
+---
+- name: Populate port-channel configuration
+ vars:
+ lines: "interface Port-channel11\ninterface Port-channel22\n"
+ when: ansible_net_version != "15.6(2)T"
+ ansible.netcommon.cli_config:
+ config: "{{ lines }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/_remove_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/_remove_config.yaml
new file mode 100644
index 000000000..b32e6f1af
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/_remove_config.yaml
@@ -0,0 +1,7 @@
+---
+- name: Remove configuration
+ vars:
+ lines: "interface GigabitEthernet 2\nno channel-group\ninterface GigabitEthernet 3\nno channel-group"
+ when: ansible_net_version != "15.6(2)T"
+ ansible.netcommon.cli_config:
+ config: "{{ lines }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/deleted.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/deleted.yaml
new file mode 100644
index 000000000..ef2b987a8
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/deleted.yaml
@@ -0,0 +1,34 @@
+---
+- ansible.builtin.debug:
+ msg: Start Deleted integration state for ios_lag_interfaces ansible_connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _populate_port_channel.yaml
+- ansible.builtin.include_tasks: _remove_config.yaml
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Delete attributes of all configured interfaces
+ register: result
+ cisco.ios.ios_lag_interfaces: &id001
+ state: deleted
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ deleted['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ deleted['before'] | symmetric_difference(result['before']) | length == 0 }}"
+
+ - name: Delete attributes of all configured interfaces (idempotent)
+ register: result
+ cisco.ios.ios_lag_interfaces: *id001
+ - name: Assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result.changed == false
+ when: ansible_net_version != "15.6(2)T"
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/empty_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/empty_config.yaml
new file mode 100644
index 000000000..6c58640df
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/empty_config.yaml
@@ -0,0 +1,61 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_lag_interfaces empty_config.yaml integration tests on connection={{ ansible_connection }}
+
+- block:
+ - name: Merged with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_lag_interfaces:
+ config:
+ state: merged
+
+ - ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state merged'
+
+ - name: Replaced with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_lag_interfaces:
+ config:
+ state: replaced
+
+ - ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state replaced'
+
+ - name: Overridden with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_lag_interfaces:
+ config:
+ state: overridden
+
+ - ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state overridden'
+
+ - name: Rendered with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_lag_interfaces:
+ config:
+ state: rendered
+
+ - ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state rendered'
+
+ - name: Parsed with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_lag_interfaces:
+ running_config:
+ state: parsed
+
+ - ansible.builtin.assert:
+ that:
+ - result.msg == 'value of running_config parameter must not be empty for state parsed'
+
+ when: ansible_net_version != "15.6(2)T"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/gathered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/gathered.yaml
new file mode 100644
index 000000000..11e319b29
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/gathered.yaml
@@ -0,0 +1,23 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_lag_interfaces gathered integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _populate_port_channel.yaml
+- ansible.builtin.include_tasks: _remove_config.yaml
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Gather the provided configuration with the existing running configuration
+ register: result
+ cisco.ios.ios_lag_interfaces:
+ config:
+ state: gathered
+
+ - name: Assert
+ ansible.builtin.assert:
+ that:
+ - gathered['config'] | symmetric_difference(result.gathered) == []
+ - result['changed'] == false
+ when: ansible_net_version != "15.6(2)T"
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/merged.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/merged.yaml
new file mode 100644
index 000000000..b93369287
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/merged.yaml
@@ -0,0 +1,42 @@
+---
+- ansible.builtin.debug:
+ msg: START Merged ios_lag_interfaces state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _populate_port_channel.yaml
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- block:
+ - name: Merge provided configuration with device configuration
+ register: result
+ cisco.ios.ios_lag_interfaces: &id001
+ config:
+ - name: Port-channel11
+ members:
+ - member: GigabitEthernet2
+ mode: active
+ - name: Port-channel22
+ members:
+ - member: GigabitEthernet3
+ mode: passive
+ state: merged
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['after'] | symmetric_difference(result['after']) | length == 0 }}"
+
+ - name: Merge provided configuration with device configuration (idempotent)
+ register: result
+ cisco.ios.ios_lag_interfaces: *id001
+ - name: Assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ when: ansible_net_version != "15.6(2)T"
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/overridden.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/overridden.yaml
new file mode 100644
index 000000000..7f8a69637
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/overridden.yaml
@@ -0,0 +1,38 @@
+---
+- ansible.builtin.debug:
+ msg: START Overridden ios_lag_interfaces state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _populate_port_channel.yaml
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Override device configuration of all interfaces with provided configuration
+ register: result
+ cisco.ios.ios_lag_interfaces: &id001
+ config:
+ - name: Port-channel22
+ members:
+ - member: GigabitEthernet3
+ mode: passive
+ state: overridden
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ overridden['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ overridden['before'] | symmetric_difference(result['before']) | length == 0 }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ overridden['after'] | symmetric_difference(result['after']) | length == 0 }}"
+
+ when: ansible_net_version != "15.6(2)T"
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/parsed.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/parsed.yaml
new file mode 100644
index 000000000..614964d08
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/parsed.yaml
@@ -0,0 +1,17 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_lag_interfaces parsed integration tests on connection={{ ansible_connection }}
+
+- block:
+ - name: Parse the commands for provided configuration
+ become: true
+ register: result
+ cisco.ios.ios_lag_interfaces:
+ running_config: "{{ lookup('file', '_parsed.cfg') }}"
+ state: parsed
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - parsed['config']|symmetric_difference(result.parsed) == []
+ when: ansible_net_version != "15.6(2)T"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/rendered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/rendered.yaml
new file mode 100644
index 000000000..ca6e8b4e3
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/rendered.yaml
@@ -0,0 +1,25 @@
+---
+- ansible.builtin.debug:
+ msg: Start ios_lag_interfaces rendered integration tests ansible_connection={{ ansible_connection }}
+
+- block:
+ - name: Render the commands for provided configuration
+ become: true
+ register: result
+ cisco.ios.ios_lag_interfaces:
+ config:
+ - name: Port-channel11
+ members:
+ - member: GigabitEthernet2
+ mode: active
+ - name: Port-channel22
+ members:
+ - member: GigabitEthernet3
+ mode: passive
+ state: rendered
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - result.rendered|symmetric_difference(merged.commands) == []
+ when: ansible_net_version != "15.6(2)T"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/replaced.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/replaced.yaml
new file mode 100644
index 000000000..1f23ca456
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/replaced.yaml
@@ -0,0 +1,38 @@
+---
+- ansible.builtin.debug:
+ msg: START Replaced ios_lag_interfaces state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _populate_port_channel.yaml
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Replaces device configuration of listed interfaces with provided configuration
+ register: result
+ cisco.ios.ios_lag_interfaces: &id001
+ config:
+ - name: Port-channel11
+ members:
+ - member: GigabitEthernet2
+ mode: passive
+ state: replaced
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ replaced['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ replaced['before'] | symmetric_difference(result['before']) | length == 0 }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ replaced['after'] | symmetric_difference(result['after']) | length == 0 }}"
+
+ when: ansible_net_version != "15.6(2)T"
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/rtt.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/rtt.yaml
new file mode 100644
index 000000000..02a61482f
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/tests/cli/rtt.yaml
@@ -0,0 +1,60 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_lag_interfaces round trip integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _populate_port_channel.yaml
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- block:
+ - name: Apply the provided configuration (base config)
+ register: base_config
+ cisco.ios.ios_lag_interfaces:
+ config:
+ - name: Port-channel11
+ members:
+ - member: GigabitEthernet2
+ mode: active
+ - name: Port-channel22
+ members:
+ - member: GigabitEthernet3
+ mode: active
+ state: merged
+
+ - name: Gather lag interfaces facts
+ cisco.ios.ios_facts:
+ gather_subset:
+ - "!all"
+ - "!min"
+ gather_network_resources:
+ - lag_interfaces
+
+ - name: Apply the provided configuration (config to be reverted)
+ register: result
+ cisco.ios.ios_lag_interfaces:
+ config:
+ - name: Port-channel22
+ members:
+ - member: GigabitEthernet3
+ mode: passive
+ state: overridden
+
+ - ansible.builtin.assert:
+ that:
+ - result.commands|length == 4
+ - result.changed == true
+ - result.commands|symmetric_difference(overridden.commands) == []
+
+ - name: Revert back to base configuration using facts round trip
+ register: revert
+ cisco.ios.ios_lag_interfaces:
+ config: "{{ ansible_facts['network_resources']['lag_interfaces'] }}"
+ state: overridden
+
+ - ansible.builtin.assert:
+ that:
+ - revert.commands|length == 2
+ - revert.changed == true
+ - revert.commands|symmetric_difference(rtt.commands) == []
+ when: ansible_net_version != "15.6(2)T"
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/vars/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/vars/main.yaml
new file mode 100644
index 000000000..41c992d86
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lag_interfaces/vars/main.yaml
@@ -0,0 +1,147 @@
+---
+merged:
+ commands:
+ - interface GigabitEthernet2
+ - channel-group 11 mode active
+ - interface GigabitEthernet3
+ - channel-group 22 mode passive
+ after:
+ - members:
+ - member: GigabitEthernet2
+ mode: active
+ name: Port-channel11
+ - members:
+ - member: GigabitEthernet3
+ mode: passive
+ name: Port-channel22
+ - members:
+ - {}
+ name: Port-channel10
+ - members:
+ - {}
+ name: Port-channel40
+
+replaced:
+ before:
+ - members:
+ - member: GigabitEthernet2
+ mode: active
+ name: Port-channel11
+ - members:
+ - member: GigabitEthernet3
+ mode: active
+ name: Port-channel22
+ - members:
+ - {}
+ name: Port-channel10
+ - members:
+ - {}
+ name: Port-channel40
+ commands:
+ - interface GigabitEthernet2
+ - channel-group 11 mode passive
+ after:
+ - members:
+ - member: GigabitEthernet2
+ mode: active
+ name: Port-channel11
+ - members:
+ - member: GigabitEthernet3
+ mode: active
+ name: Port-channel22
+ - members:
+ - {}
+ name: Port-channel10
+ - members:
+ - {}
+ name: Port-channel40
+
+overridden:
+ before:
+ - members:
+ - member: GigabitEthernet2
+ mode: active
+ name: Port-channel11
+ - members:
+ - member: GigabitEthernet3
+ mode: active
+ name: Port-channel22
+ - members:
+ - {}
+ name: Port-channel10
+ - members:
+ - {}
+ name: Port-channel40
+ commands:
+ - interface GigabitEthernet2
+ - no channel-group 11 mode active
+ - interface GigabitEthernet3
+ - channel-group 22 mode passive
+ after:
+ - members:
+ - member: GigabitEthernet3
+ mode: active
+ name: Port-channel22
+ - members:
+ - {}
+ name: Port-channel10
+ - members:
+ - {}
+ name: Port-channel11
+ - members:
+ - {}
+ name: Port-channel40
+
+deleted:
+ before:
+ - members:
+ - member: GigabitEthernet2
+ mode: active
+ name: Port-channel11
+ - members:
+ - member: GigabitEthernet3
+ mode: active
+ name: Port-channel22
+ - members:
+ - {}
+ name: Port-channel10
+ - members:
+ - {}
+ name: Port-channel40
+ commands:
+ - interface GigabitEthernet2
+ - no channel-group 11 mode active
+ - interface GigabitEthernet3
+ - no channel-group 22 mode active
+
+gathered:
+ config:
+ - members:
+ - member: GigabitEthernet2
+ mode: active
+ name: Port-channel11
+ - members:
+ - member: GigabitEthernet3
+ mode: active
+ name: Port-channel22
+ - members:
+ - {}
+ name: Port-channel10
+ - members:
+ - {}
+ name: Port-channel40
+
+parsed:
+ config:
+ - members:
+ - member: GigabitEthernet2
+ mode: active
+ name: Port-channel11
+ - members:
+ - member: GigabitEthernet3
+ mode: passive
+ name: Port-channel22
+rtt:
+ commands:
+ - interface GigabitEthernet2
+ - channel-group 11 mode active
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_linkagg/defaults/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_linkagg/defaults/main.yaml
new file mode 100644
index 000000000..9ef5ba516
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_linkagg/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "*"
+test_items: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_linkagg/meta/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_linkagg/meta/main.yaml
new file mode 100644
index 000000000..ab3ad91bc
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_linkagg/meta/main.yaml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - prepare_ios_tests
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_linkagg/tasks/cli.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_linkagg/tasks/cli.yaml
new file mode 100644
index 000000000..cd8c04990
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_linkagg/tasks/cli.yaml
@@ -0,0 +1,18 @@
+---
+- name: Collect all CLI test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: Run test cases (connection=ansible.netcommon.network_cli)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+ tags: network_cli
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_linkagg/tasks/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_linkagg/tasks/main.yaml
new file mode 100644
index 000000000..3360559bd
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_linkagg/tasks/main.yaml
@@ -0,0 +1,3 @@
+---
+- name: Main task for linkagg module
+ ansible.builtin.include_tasks: cli.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_linkagg/tests/cli/basic.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_linkagg/tests/cli/basic.yaml
new file mode 100644
index 000000000..079c1f8fe
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_linkagg/tests/cli/basic.yaml
@@ -0,0 +1,157 @@
+---
+- ansible.builtin.debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}"
+
+- ansible.builtin.set_fact: switch_type="{{ switch_type }}"
+
+- block:
+ - name: Setup - remove configuration used in test(part1)
+ ignore_errors: true
+ cisco.ios.ios_config:
+ lines:
+ - no interface port-channel 20
+
+ - name: Setup - remove configuration used in test(part2)
+ ignore_errors: true
+ cisco.ios.ios_config:
+ lines:
+ - no interface port-channel 5
+
+ - name: Setup - remove configuration used in test(part3)
+ loop:
+ - interface GigabitEthernet2
+ - interface GigabitEthernet3
+ cisco.ios.ios_config:
+ lines:
+ - no channel-group 20 mode active
+ parents: "{{ item }}"
+
+ - name: Create linkagg
+ register: result
+ cisco.ios.ios_linkagg: &id001
+ group: 20
+ state: present
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - "'interface port-channel 20' in result.commands"
+
+ - name: Create linkagg (idempotent)
+ register: result
+ cisco.ios.ios_linkagg: *id001
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+ - name: Set link aggregation group to members
+ register: result
+ cisco.ios.ios_linkagg: &id002
+ group: 20
+ mode: active
+ members:
+ - GigabitEthernet2
+ - GigabitEthernet3
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - "'interface GigabitEthernet2' in result.commands"
+ - "'channel-group 20 mode active' in result.commands"
+ - "'interface GigabitEthernet3' in result.commands"
+ - "'channel-group 20 mode active' in result.commands"
+
+ - name: Set link aggregation group to members (idempotent)
+ register: result
+ cisco.ios.ios_linkagg: *id002
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+ - name: Remove link aggregation group from member
+ register: result
+ cisco.ios.ios_linkagg: &id003
+ group: 20
+ mode: active
+ members:
+ - GigabitEthernet3
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - "'interface GigabitEthernet2' in result.commands"
+ - "'no channel-group 20 mode active' in result.commands"
+
+ - name: Remove link aggregation group from member (idempotent)
+ register: result
+ cisco.ios.ios_linkagg: *id003
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+ - name: Remove linkagg
+ register: result
+ cisco.ios.ios_linkagg: &id004
+ group: 20
+ state: absent
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - "'no interface port-channel 20' in result.commands"
+
+ - name: Remove linkagg (idempotent)
+ register: result
+ cisco.ios.ios_linkagg: *id004
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+ - name: Create aggregate of linkagg definitions
+ register: result
+ cisco.ios.ios_linkagg: &id005
+ aggregate:
+ - group: 5
+
+ - group: 20
+ mode: active
+ members:
+ - GigabitEthernet2
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - "'interface port-channel 5' in result.commands"
+ - "'interface port-channel 20' in result.commands"
+ - "'interface GigabitEthernet2' in result.commands"
+ - "'channel-group 20 mode active' in result.commands"
+
+ - name: Create aggregate of linkagg definitions (idempotent)
+ register: result
+ cisco.ios.ios_linkagg: *id005
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+ - name: Teardown(part1)
+ ignore_errors: true
+ cisco.ios.ios_config:
+ lines:
+ - no interface port-channel 20
+
+ - name: Teardown(part2)
+ ignore_errors: true
+ cisco.ios.ios_config:
+ lines:
+ - no interface port-channel 5
+
+ - name: Teardown(part3)
+ loop:
+ - interface GigabitEthernet2
+ - interface GigabitEthernet3
+ cisco.ios.ios_config:
+ lines:
+ - no channel-group 20 mode active
+ parents: "{{ item }}"
+ when: switch_type == 'L2'
+
+- ansible.builtin.debug: msg="END cli/basic.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp/defaults/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp/defaults/main.yaml
new file mode 100644
index 000000000..5f709c5aa
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp/defaults/main.yaml
@@ -0,0 +1,2 @@
+---
+testcase: "*"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp/meta/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp/meta/main.yaml
new file mode 100644
index 000000000..ab3ad91bc
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp/meta/main.yaml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - prepare_ios_tests
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp/tasks/cli.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp/tasks/cli.yaml
new file mode 100644
index 000000000..cd8c04990
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp/tasks/cli.yaml
@@ -0,0 +1,18 @@
+---
+- name: Collect all CLI test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: Run test cases (connection=ansible.netcommon.network_cli)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+ tags: network_cli
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp/tasks/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp/tasks/main.yaml
new file mode 100644
index 000000000..e2d4a7b2d
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp/tasks/main.yaml
@@ -0,0 +1,3 @@
+---
+- name: Main task for lldp module
+ ansible.builtin.include_tasks: cli.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp/tests/cli/basic.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp/tests/cli/basic.yaml
new file mode 100644
index 000000000..8fb6e07e7
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp/tests/cli/basic.yaml
@@ -0,0 +1,46 @@
+---
+- ansible.builtin.debug: msg="START ios_lldp cli/basic.yaml on connection={{ ansible_connection }}"
+
+- name: Make sure lldp is not running before tests
+ cisco.ios.ios_config:
+ lines: no lldp run
+
+- name: Enable lldp service
+ register: result
+ cisco.ios.ios_lldp:
+ state: present
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - '"lldp run" in result.commands'
+
+- name: Enable lldp service again (idempotent)
+ register: result
+ cisco.ios.ios_lldp:
+ state: present
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+- name: Disable lldp service
+ register: result
+ cisco.ios.ios_lldp:
+ state: absent
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - '"no lldp run" in result.commands'
+
+- name: Disable lldp service (idempotent)
+ register: result
+ cisco.ios.ios_lldp:
+ state: absent
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+- ansible.builtin.debug: msg="END ios_lldp cli/basic.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/aliases b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/aliases
new file mode 100644
index 000000000..6bb69158a
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/aliases
@@ -0,0 +1 @@
+shippable/ios/group1
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/defaults/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/defaults/main.yaml
new file mode 100644
index 000000000..164afead2
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/meta/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/meta/main.yaml
new file mode 100644
index 000000000..23d65c7ef
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/meta/main.yaml
@@ -0,0 +1,2 @@
+---
+dependencies: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tasks/cli.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tasks/cli.yaml
new file mode 100644
index 000000000..6f505600c
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tasks/cli.yaml
@@ -0,0 +1,21 @@
+---
+- name: Collect all CLI test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+ delegate_to: localhost
+
+- name: Run test case (connection=ansible.netcommon.network_cli)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.network_cli
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tasks/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tasks/main.yaml
new file mode 100644
index 000000000..5f860fde9
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tasks/main.yaml
@@ -0,0 +1,5 @@
+---
+- name: Main task for lldp_global module
+ ansible.builtin.include_tasks: cli.yaml
+ tags:
+ - network_cli
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tests/cli/_parsed.cfg b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tests/cli/_parsed.cfg
new file mode 100644
index 000000000..b809a02ad
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tests/cli/_parsed.cfg
@@ -0,0 +1,4 @@
+lldp timer 10
+lldp holdtime 10
+lldp reinit 3
+lldp run
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tests/cli/_populate_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tests/cli/_populate_config.yaml
new file mode 100644
index 000000000..fd4b65d7d
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tests/cli/_populate_config.yaml
@@ -0,0 +1,6 @@
+---
+- name: Populate configuration
+ vars:
+ lines: "lldp holdtime 10\nlldp run\nlldp timer 100\nlldp reinit 3\n"
+ ansible.netcommon.cli_config:
+ config: "{{ lines }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tests/cli/_remove_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tests/cli/_remove_config.yaml
new file mode 100644
index 000000000..ee432a3b3
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tests/cli/_remove_config.yaml
@@ -0,0 +1,6 @@
+---
+- name: Remove configuration
+ vars:
+ lines: "no lldp holdtime\nno lldp run\nno lldp timer\nno lldp reinit\n"
+ ansible.netcommon.cli_config:
+ config: "{{ lines }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tests/cli/deleted.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tests/cli/deleted.yaml
new file mode 100644
index 000000000..c9b52812c
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tests/cli/deleted.yaml
@@ -0,0 +1,38 @@
+---
+- ansible.builtin.debug:
+ msg: Start Deleted integration state for ios_lldp_global ansible_connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Delete configured global lldp
+ register: result
+ cisco.ios.ios_lldp_global: &id001
+ state: deleted
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ deleted['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ deleted['before'] == result['before'] }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ deleted['after'] == result['after'] }}"
+
+ - name: Delete configured global lldp (idempotent)
+ register: result
+ cisco.ios.ios_lldp_global: *id001
+ - name: Assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result.changed == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tests/cli/empty_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tests/cli/empty_config.yaml
new file mode 100644
index 000000000..99b96472f
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tests/cli/empty_config.yaml
@@ -0,0 +1,47 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_lldp_global empty_config.yaml integration tests on connection={{ ansible_connection }}
+
+- name: Merged with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_lldp_global:
+ config:
+ state: merged
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state merged'
+
+- name: Replaced with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_lldp_global:
+ config:
+ state: replaced
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state replaced'
+
+- name: Rendered with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_lldp_global:
+ config:
+ state: rendered
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state rendered'
+
+- name: Parsed with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_lldp_global:
+ running_config:
+ state: parsed
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of running_config parameter must not be empty for state parsed'
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tests/cli/gathered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tests/cli/gathered.yaml
new file mode 100644
index 000000000..8db1ef6e6
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tests/cli/gathered.yaml
@@ -0,0 +1,19 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_lldp_global gathered integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Gather the provided configuration with the existing running configuration
+ register: result
+ cisco.ios.ios_lldp_global:
+ config:
+ state: gathered
+
+ - name: Assert
+ ansible.builtin.assert:
+ that:
+ - "{{ result['gathered'] == gathered['config'] }}"
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tests/cli/merged.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tests/cli/merged.yaml
new file mode 100644
index 000000000..3fbaa739e
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tests/cli/merged.yaml
@@ -0,0 +1,41 @@
+---
+- ansible.builtin.debug:
+ msg: START Merged ios_lldp_global state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- block:
+ - name: Merge provided configuration global lldp
+ register: result
+ cisco.ios.ios_lldp_global: &id001
+ config:
+ holdtime: 10
+ enabled: true
+ reinit: 3
+ timer: 20
+ state: merged
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['before'] == result['before'] }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['after'] == result['after'] }}"
+
+ - name: Merge provided configuration global lldp (idempotent)
+ register: result
+ cisco.ios.ios_lldp_global: *id001
+ - name: Assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tests/cli/parsed.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tests/cli/parsed.yaml
new file mode 100644
index 000000000..795ebe7d5
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tests/cli/parsed.yaml
@@ -0,0 +1,15 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_lldp_global parsed integration tests on connection={{ ansible_connection }}
+
+- name: Parse the commands for provided configuration
+ become: true
+ register: result
+ cisco.ios.ios_lldp_global:
+ running_config: "{{ lookup('file', '_parsed.cfg') }}"
+ state: parsed
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - "{{ result['parsed'] == parsed['config'] }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tests/cli/rendered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tests/cli/rendered.yaml
new file mode 100644
index 000000000..3879c7fd0
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tests/cli/rendered.yaml
@@ -0,0 +1,20 @@
+---
+- ansible.builtin.debug:
+ msg: Start ios_lldp_global rendered integration tests ansible_connection={{ ansible_connection }}
+
+- block:
+ - name: Render the commands for provided configuration
+ become: true
+ register: result
+ cisco.ios.ios_lldp_global:
+ config:
+ holdtime: 10
+ enabled: true
+ reinit: 3
+ timer: 20
+ state: rendered
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - result.rendered|symmetric_difference(merged.commands) == []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tests/cli/replaced.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tests/cli/replaced.yaml
new file mode 100644
index 000000000..78b60032e
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/tests/cli/replaced.yaml
@@ -0,0 +1,41 @@
+---
+- ansible.builtin.debug:
+ msg: START Replaced ios_lldp_global state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Replaces global lldp configuration with provided lldp configuration
+ register: result
+ cisco.ios.ios_lldp_global: &id001
+ config:
+ holdtime: 20
+ reinit: 5
+ state: replaced
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ replaced['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ replaced['before'] == result['before'] }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ replaced['after'] == result['after'] }}"
+
+ - name: Replaces global lldp configuration with provided lldp configuration (idempotent)
+ register: result
+ cisco.ios.ios_lldp_global: *id001
+ - name: Assert that task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/vars/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/vars/main.yaml
new file mode 100644
index 000000000..233af2fb2
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_global/vars/main.yaml
@@ -0,0 +1,51 @@
+---
+merged:
+ before: {}
+ commands:
+ - lldp holdtime 10
+ - lldp run
+ - lldp timer 20
+ - lldp reinit 3
+ after:
+ timer: 20
+ holdtime: 10
+ reinit: 3
+ enabled: true
+replaced:
+ before:
+ timer: 100
+ holdtime: 10
+ reinit: 3
+ enabled: true
+ commands:
+ - no lldp run
+ - no lldp timer
+ - lldp holdtime 20
+ - lldp reinit 5
+ after:
+ holdtime: 20
+ reinit: 5
+deleted:
+ before:
+ timer: 100
+ holdtime: 10
+ reinit: 3
+ enabled: true
+ commands:
+ - no lldp holdtime
+ - no lldp run
+ - no lldp timer
+ - no lldp reinit
+ after: {}
+gathered:
+ config:
+ enabled: true
+ holdtime: 10
+ reinit: 3
+ timer: 100
+parsed:
+ config:
+ enabled: true
+ holdtime: 10
+ reinit: 3
+ timer: 10
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/defaults/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/defaults/main.yaml
new file mode 100644
index 000000000..164afead2
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tasks/cli.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tasks/cli.yaml
new file mode 100644
index 000000000..6f505600c
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tasks/cli.yaml
@@ -0,0 +1,21 @@
+---
+- name: Collect all CLI test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+ delegate_to: localhost
+
+- name: Run test case (connection=ansible.netcommon.network_cli)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.network_cli
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tasks/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tasks/main.yaml
new file mode 100644
index 000000000..5694eecfb
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tasks/main.yaml
@@ -0,0 +1,5 @@
+---
+- name: Main task for lldp_interfaces module
+ ansible.builtin.include_tasks: cli.yaml
+ tags:
+ - network_cli
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/_enable_lldp.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/_enable_lldp.yaml
new file mode 100644
index 000000000..94df00bfb
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/_enable_lldp.yaml
@@ -0,0 +1,6 @@
+---
+- name: Enable lldp configuration
+ vars:
+ lines: "lldp run\n"
+ ansible.netcommon.cli_config:
+ config: "{{ lines }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/_parsed.cfg b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/_parsed.cfg
new file mode 100644
index 000000000..3721da684
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/_parsed.cfg
@@ -0,0 +1,17 @@
+GigabitEthernet1:
+ Tx: enabled
+ Rx: disabled
+ Tx state: IDLE
+ Rx state: WAIT FOR FRAME
+
+GigabitEthernet2:
+ Tx: enabled
+ Rx: enabled
+ Tx state: IDLE
+ Rx state: WAIT FOR FRAME
+
+GigabitEthernet3:
+ Tx: disabled
+ Rx: enabled
+ Tx state: IDLE
+ Rx state: INIT
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/_populate_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/_populate_config.yaml
new file mode 100644
index 000000000..bfb0136e2
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/_populate_config.yaml
@@ -0,0 +1,8 @@
+---
+- name: Populate configuration
+ vars:
+ lines:
+ "interface GigabitEthernet 1\nlldp receive\nlldp transmit\ninterface GigabitEthernet 2\nlldp receive\nlldp transmit\ninterface GigabitEthernet 3\n\
+ lldp receive\nlldp transmit\n"
+ ansible.netcommon.cli_config:
+ config: "{{ lines }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/_remove_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/_remove_config.yaml
new file mode 100644
index 000000000..24246729f
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/_remove_config.yaml
@@ -0,0 +1,8 @@
+---
+- name: Remove configuration
+ vars:
+ lines:
+ "interface GigabitEthernet 1\nno lldp receive\nno lldp transmit\ninterface GigabitEthernet 2\nno lldp receive\nno lldp transmit\ninterface GigabitEthernet\
+ \ 3\nno lldp receive\nno lldp transmit\n"
+ ansible.netcommon.cli_config:
+ config: "{{ lines }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/deleted.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/deleted.yaml
new file mode 100644
index 000000000..d899d8272
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/deleted.yaml
@@ -0,0 +1,40 @@
+---
+- ansible.builtin.debug:
+ msg: Start Deleted integration state for ios_lldp_interfaces ansible_connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _enable_lldp.yaml
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Delete lldp attributes for respective configured interfaces
+ register: result
+ cisco.ios.ios_lldp_interfaces: &id001
+ state: deleted
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ deleted['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ deleted['before'] | symmetric_difference(result['before']) | length == 0 }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ deleted['after'] | symmetric_difference(result['after']) | length == 0 }}"
+
+ - name: Delete lldp attributes for respective configured interfaces (idempotent)
+ register: result
+ cisco.ios.ios_lldp_interfaces: *id001
+ - name: Assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result.changed == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/empty_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/empty_config.yaml
new file mode 100644
index 000000000..7a03d3846
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/empty_config.yaml
@@ -0,0 +1,58 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_lldp_interfaces empty_config.yaml integration tests on connection={{ ansible_connection }}
+
+- name: Merged with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_lldp_interfaces:
+ config:
+ state: merged
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state merged'
+
+- name: Replaced with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_lldp_interfaces:
+ config:
+ state: replaced
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state replaced'
+
+- name: Overridden with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_lldp_interfaces:
+ config:
+ state: overridden
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state overridden'
+
+- name: Rendered with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_lldp_interfaces:
+ config:
+ state: rendered
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state rendered'
+
+- name: Parsed with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_lldp_interfaces:
+ running_config:
+ state: parsed
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of running_config parameter must not be empty for state parsed'
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/gathered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/gathered.yaml
new file mode 100644
index 000000000..1c7b55da2
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/gathered.yaml
@@ -0,0 +1,22 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_lldp_interfaces gathered integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _enable_lldp.yaml
+- ansible.builtin.include_tasks: _remove_config.yaml
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Gather the provided configuration with the existing running configuration
+ register: result
+ cisco.ios.ios_lldp_interfaces:
+ config:
+ state: gathered
+
+ - name: Assert
+ ansible.builtin.assert:
+ that:
+ - gathered['config'] | symmetric_difference(result.gathered) == []
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/merged.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/merged.yaml
new file mode 100644
index 000000000..c9b9e1812
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/merged.yaml
@@ -0,0 +1,48 @@
+---
+- ansible.builtin.debug:
+ msg: START Merged ios_lldp_interfaces state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _enable_lldp.yaml
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- block:
+ - name: Merge the provided configuration with the existing running configuration
+ register: result
+ cisco.ios.ios_lldp_interfaces: &id001
+ config:
+ - name: GigabitEthernet1
+ receive: true
+ transmit: true
+ - name: GigabitEthernet2
+ receive: true
+ transmit: true
+ - name: GigabitEthernet3
+ receive: true
+ transmit: false
+ state: merged
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['before'] | symmetric_difference(result['before']) | length == 0 }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['after'] | symmetric_difference(result['after']) | length == 0 }}"
+
+ - name: Merge the provided configuration with the existing running configuration (idempotent)
+ register: result
+ cisco.ios.ios_lldp_interfaces: *id001
+ - name: Assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/overridden.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/overridden.yaml
new file mode 100644
index 000000000..5ff99b778
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/overridden.yaml
@@ -0,0 +1,47 @@
+---
+- ansible.builtin.debug:
+ msg: START Overridden ios_lldp_interfaces state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _enable_lldp.yaml
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Override device configuration of all lldp_interfaces with provided configuration
+ register: result
+ cisco.ios.ios_lldp_interfaces: &id001
+ config:
+ - name: GigabitEthernet1
+ receive: true
+ transmit: true
+
+ - name: GigabitEthernet3
+ receive: true
+ state: overridden
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ overridden['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ overridden['before'] | symmetric_difference(result['before']) | length == 0 }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ overridden['after'] | symmetric_difference(result['after']) | length == 0 }}"
+
+ - name: Override device configuration of all lldp_interfaces with provided configuration (idempotent)
+ register: result
+ cisco.ios.ios_lldp_interfaces: *id001
+ - name: Assert that task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/parsed.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/parsed.yaml
new file mode 100644
index 000000000..bbc838b8d
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/parsed.yaml
@@ -0,0 +1,15 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_lldp_interfaces parsed integration tests on connection={{ ansible_connection }}
+
+- name: Parse the commands for provided configuration
+ become: true
+ register: result
+ cisco.ios.ios_lldp_interfaces:
+ running_config: "{{ lookup('file', '_parsed.cfg') }}"
+ state: parsed
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - parsed['config']|symmetric_difference(result.parsed) == []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/rendered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/rendered.yaml
new file mode 100644
index 000000000..7ebbe3410
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/rendered.yaml
@@ -0,0 +1,24 @@
+---
+- ansible.builtin.debug:
+ msg: Start ios_lldp_interfaces rendered integration tests ansible_connection={{ ansible_connection }}
+
+- block:
+ - name: Render the commands for provided configuration
+ become: true
+ register: result
+ cisco.ios.ios_lldp_interfaces:
+ config:
+ - name: GigabitEthernet1
+ receive: true
+ transmit: true
+ - name: GigabitEthernet2
+ receive: true
+ transmit: true
+ - name: GigabitEthernet3
+ receive: true
+ state: rendered
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - result.rendered|symmetric_difference(rendered.commands) == []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/replaced.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/replaced.yaml
new file mode 100644
index 000000000..0e005fa88
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/replaced.yaml
@@ -0,0 +1,47 @@
+---
+- ansible.builtin.debug:
+ msg: START Replaced ios_lldp_interfaces state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _enable_lldp.yaml
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Replaces device configuration of listed lldp_interfaces with provided configuration
+ register: result
+ cisco.ios.ios_lldp_interfaces: &id001
+ config:
+ - name: GigabitEthernet2
+ transmit: true
+
+ - name: GigabitEthernet3
+ receive: true
+ transmit: false
+ state: replaced
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ replaced['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ replaced['before'] | symmetric_difference(result['before']) | length == 0 }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ replaced['after'] | symmetric_difference(result['after']) | length == 0 }}"
+
+ - name: Replaces device configuration of listed lldp_interfaces with provided configuration (idempotent)
+ register: result
+ cisco.ios.ios_lldp_interfaces: *id001
+ - name: Assert that task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/rtt.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/rtt.yaml
new file mode 100644
index 000000000..e274b51a2
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/tests/cli/rtt.yaml
@@ -0,0 +1,62 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_lldp_interfaces round trip integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _enable_lldp.yaml
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- block:
+ - name: Apply the provided configuration (base config)
+ register: base_config
+ cisco.ios.ios_lldp_interfaces:
+ config:
+ - name: GigabitEthernet0/0
+ receive: true
+ transmit: true
+ - name: GigabitEthernet2
+ receive: true
+ transmit: true
+ - name: GigabitEthernet3
+ receive: true
+ transmit: true
+ state: merged
+
+ - name: Gather lldp interfaces facts
+ cisco.ios.ios_facts:
+ gather_subset:
+ - "!all"
+ - "!min"
+ gather_network_resources:
+ - lldp_interfaces
+
+ - name: Apply the provided configuration (config to be reverted)
+ register: result
+ cisco.ios.ios_lldp_interfaces:
+ config:
+ - name: GigabitEthernet0/0
+ receive: true
+ transmit: true
+ - name: GigabitEthernet3
+ receive: true
+ state: overridden
+
+ - ansible.builtin.assert:
+ that:
+ - result.commands|length == 5
+ - result.changed == true
+ - result.commands|symmetric_difference(overridden.commands) == []
+
+ - name: Revert back to base configuration using facts round trip
+ register: revert
+ cisco.ios.ios_lldp_interfaces:
+ config: "{{ ansible_facts['network_resources']['lldp_interfaces'] }}"
+ state: overridden
+
+ - ansible.builtin.assert:
+ that:
+ - revert.commands|length == 5
+ - revert.changed == true
+ - revert.commands|symmetric_difference(rtt.commands) == []
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/vars/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/vars/main.yaml
new file mode 100644
index 000000000..1f3165777
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_lldp_interfaces/vars/main.yaml
@@ -0,0 +1,188 @@
+---
+merged:
+ before:
+ - name: GigabitEthernet1
+ receive: false
+ transmit: false
+ - name: GigabitEthernet2
+ receive: false
+ transmit: false
+ - name: GigabitEthernet3
+ receive: false
+ transmit: false
+ - name: GigabitEthernet4
+ receive: false
+ transmit: false
+ commands:
+ - interface GigabitEthernet1
+ - lldp receive
+ - lldp transmit
+ - interface GigabitEthernet2
+ - lldp receive
+ - lldp transmit
+ - interface GigabitEthernet3
+ - lldp receive
+ after:
+ - name: GigabitEthernet1
+ receive: true
+ transmit: true
+ - name: GigabitEthernet2
+ receive: true
+ transmit: true
+ - name: GigabitEthernet3
+ receive: true
+ transmit: false
+ - name: GigabitEthernet4
+ receive: false
+ transmit: false
+
+replaced:
+ before:
+ - name: GigabitEthernet1
+ receive: true
+ transmit: true
+ - name: GigabitEthernet2
+ receive: true
+ transmit: true
+ - name: GigabitEthernet3
+ receive: true
+ transmit: true
+ - name: GigabitEthernet4
+ receive: false
+ transmit: false
+ commands:
+ - interface GigabitEthernet2
+ - no lldp receive
+ - interface GigabitEthernet3
+ - no lldp transmit
+ after:
+ - name: GigabitEthernet1
+ receive: true
+ transmit: true
+ - name: GigabitEthernet2
+ receive: false
+ transmit: true
+ - name: GigabitEthernet3
+ receive: true
+ transmit: false
+ - name: GigabitEthernet4
+ receive: false
+ transmit: false
+
+overridden:
+ before:
+ - name: GigabitEthernet1
+ receive: true
+ transmit: true
+ - name: GigabitEthernet2
+ receive: true
+ transmit: true
+ - name: GigabitEthernet3
+ receive: true
+ transmit: true
+ - name: GigabitEthernet4
+ receive: false
+ transmit: false
+ commands:
+ - interface GigabitEthernet2
+ - no lldp receive
+ - no lldp transmit
+ - interface GigabitEthernet3
+ - no lldp transmit
+ after:
+ - name: GigabitEthernet1
+ receive: true
+ transmit: true
+ - name: GigabitEthernet2
+ receive: false
+ transmit: false
+ - name: GigabitEthernet3
+ receive: true
+ transmit: false
+ - name: GigabitEthernet4
+ receive: false
+ transmit: false
+
+deleted:
+ before:
+ - name: GigabitEthernet1
+ receive: true
+ transmit: true
+ - name: GigabitEthernet2
+ receive: true
+ transmit: true
+ - name: GigabitEthernet3
+ receive: true
+ transmit: true
+ - name: GigabitEthernet4
+ receive: false
+ transmit: false
+ commands:
+ - interface GigabitEthernet1
+ - no lldp receive
+ - no lldp transmit
+ - interface GigabitEthernet2
+ - no lldp receive
+ - no lldp transmit
+ - interface GigabitEthernet3
+ - no lldp receive
+ - no lldp transmit
+ after:
+ - name: GigabitEthernet1
+ receive: false
+ transmit: false
+ - name: GigabitEthernet2
+ receive: false
+ transmit: false
+ - name: GigabitEthernet3
+ receive: false
+ transmit: false
+ - name: GigabitEthernet4
+ receive: false
+ transmit: false
+
+gathered:
+ config:
+ - name: GigabitEthernet1
+ receive: true
+ transmit: true
+ - name: GigabitEthernet2
+ receive: true
+ transmit: true
+ - name: GigabitEthernet3
+ receive: true
+ transmit: true
+ - name: GigabitEthernet4
+ receive: false
+ transmit: false
+
+parsed:
+ config:
+ - name: GigabitEthernet1
+ receive: false
+ transmit: true
+ - name: GigabitEthernet2
+ receive: true
+ transmit: true
+ - name: GigabitEthernet3
+ receive: true
+ transmit: false
+
+rtt:
+ commands:
+ - interface GigabitEthernet2
+ - lldp receive
+ - lldp transmit
+ - interface GigabitEthernet3
+ - lldp transmit
+
+rendered:
+ commands:
+ - interface GigabitEthernet1
+ - lldp receive
+ - lldp transmit
+ - interface GigabitEthernet2
+ - lldp receive
+ - lldp transmit
+ - interface GigabitEthernet3
+ - lldp receive
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_logging/defaults/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging/defaults/main.yaml
new file mode 100644
index 000000000..5f709c5aa
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging/defaults/main.yaml
@@ -0,0 +1,2 @@
+---
+testcase: "*"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_logging/meta/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging/meta/main.yaml
new file mode 100644
index 000000000..ab3ad91bc
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging/meta/main.yaml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - prepare_ios_tests
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_logging/tasks/cli.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging/tasks/cli.yaml
new file mode 100644
index 000000000..cd8c04990
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging/tasks/cli.yaml
@@ -0,0 +1,18 @@
+---
+- name: Collect all CLI test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: Run test cases (connection=ansible.netcommon.network_cli)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+ tags: network_cli
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_logging/tasks/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging/tasks/main.yaml
new file mode 100644
index 000000000..5e6448cf7
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging/tasks/main.yaml
@@ -0,0 +1,3 @@
+---
+- name: Main task for logging module
+ ansible.builtin.include_tasks: cli.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_logging/tests/cli/basic.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging/tests/cli/basic.yaml
new file mode 100644
index 000000000..d14396195
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging/tests/cli/basic.yaml
@@ -0,0 +1,134 @@
+---
+- name: Remove host logging
+ cisco.ios.ios_logging: &id001
+ dest: host
+ name: 172.16.0.1
+ state: absent
+
+- name: Remove console
+ cisco.ios.ios_logging:
+ dest: console
+ level: warnings
+ state: absent
+
+- name: Remove buffer
+ cisco.ios.ios_logging:
+ dest: buffered
+ size: 8000
+ state: absent
+
+- name: Set up host logging
+ register: result
+ cisco.ios.ios_logging:
+ dest: host
+ name: 172.16.0.1
+ facility: local7
+ state: present
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - '"logging host 172.16.0.1" in result.commands'
+ - '"logging facility local7" in result.commands'
+
+- name: Set up host logging again (idempotent)
+ register: result
+ cisco.ios.ios_logging:
+ dest: host
+ name: 172.16.0.1
+ state: present
+
+- ansible.builtin.assert: &id002
+ that:
+ - result.changed == false
+
+- name: Delete/disable host logging
+ register: result
+ cisco.ios.ios_logging: *id001
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - '"no logging host 172.16.0.1" in result.commands'
+
+- name: Delete/disable host logging (idempotent)
+ register: result
+ cisco.ios.ios_logging: *id001
+- ansible.builtin.assert: *id002
+- name: Console logging with level warnings
+ register: result
+ cisco.ios.ios_logging:
+ dest: console
+ level: warnings
+ state: present
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - '"logging console warnings" in result.commands'
+
+- name: Configure buffer size
+ register: result
+ cisco.ios.ios_logging:
+ dest: buffered
+ size: 8000
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - '"logging buffered 8000" in result.commands'
+
+- name: Change logging parameters using aggregate
+ register: result
+ cisco.ios.ios_logging:
+ aggregate:
+ - dest: console
+ level: notifications
+
+ - dest: buffered
+ size: 9000
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - '"logging buffered 9000" in result.commands'
+ - '"logging console notifications" in result.commands'
+
+- name: Set both logging destination and facility
+ register: result
+ cisco.ios.ios_logging: &id003
+ dest: buffered
+ facility: uucp
+ level: alerts
+ size: 4096
+ state: present
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - '"logging buffered 4096 alerts" in result.commands'
+ - '"logging facility uucp" in result.commands'
+
+- name: Set both logging destination and facility (idempotent)
+ register: result
+ cisco.ios.ios_logging: *id003
+- ansible.builtin.assert: *id002
+- name: Remove logging as collection teardown
+ register: result
+ cisco.ios.ios_logging:
+ aggregate:
+ - dest: console
+ level: notifications
+
+ - dest: buffered
+ size: 4096
+ level: alerts
+
+ - facility: uucp
+ state: absent
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - '"no logging console" in result.commands'
+ - '"no logging buffered" in result.commands'
+ - '"no logging facility uucp" in result.commands'
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/defaults/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/defaults/main.yaml
new file mode 100644
index 000000000..164afead2
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/meta/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/meta/main.yaml
new file mode 100644
index 000000000..23d65c7ef
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/meta/main.yaml
@@ -0,0 +1,2 @@
+---
+dependencies: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tasks/cli.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tasks/cli.yaml
new file mode 100644
index 000000000..6f505600c
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tasks/cli.yaml
@@ -0,0 +1,21 @@
+---
+- name: Collect all CLI test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+ delegate_to: localhost
+
+- name: Run test case (connection=ansible.netcommon.network_cli)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.network_cli
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tasks/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tasks/main.yaml
new file mode 100644
index 000000000..1528a842f
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tasks/main.yaml
@@ -0,0 +1,5 @@
+---
+- name: Main task for logging_global module
+ ansible.builtin.include_tasks: cli.yaml
+ tags:
+ - network_cli
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/_parsed.cfg b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/_parsed.cfg
new file mode 100644
index 000000000..e8bae05ba
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/_parsed.cfg
@@ -0,0 +1 @@
+logging buffered xml 5099 notifications
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/_populate_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/_populate_config.yaml
new file mode 100644
index 000000000..f4c0db153
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/_populate_config.yaml
@@ -0,0 +1,36 @@
+---
+- name: Config apply - [merged] apply provided configuration
+ cisco.ios.ios_logging_global:
+ config:
+ buffered:
+ severity: notifications
+ size: 5099
+ xml: true
+ console:
+ severity: critical
+ xml: true
+ facility: local5
+ hosts:
+ - hostname: 192.0.2.12
+ - hostname: 192.0.2.11
+ xml: true
+ - hostname: 192.0.2.10
+ filtered: true
+ stream: 10
+ - hostname: 192.0.2.13
+ transport:
+ tcp:
+ port: 514
+ monitor:
+ severity: warnings
+ message_counter:
+ - log
+ - syslog
+ trap: errors
+ userinfo: true
+ logging_on: enable
+ exception: 4099
+ dmvpn:
+ rate_limit: 10
+ cns_events: warnings
+ state: merged
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/_remove_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/_remove_config.yaml
new file mode 100644
index 000000000..dbe9af694
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/_remove_config.yaml
@@ -0,0 +1,4 @@
+---
+- name: Config remove - [deleted] remove exiting configuration
+ cisco.ios.ios_logging_global:
+ state: deleted
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/deleted.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/deleted.yaml
new file mode 100644
index 000000000..c0690ed59
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/deleted.yaml
@@ -0,0 +1,20 @@
+---
+- ansible.builtin.debug:
+ msg: Start Deleted integration state for ios_logging ansible_connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Test - [deleted] remove all configuration
+ cisco.ios.ios_logging_global:
+ state: deleted
+ register: result
+
+ - name: Test - [deleted] assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ deleted['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/empty_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/empty_config.yaml
new file mode 100644
index 000000000..a2ba6ad8f
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/empty_config.yaml
@@ -0,0 +1,58 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_logging_global empty_config.yaml integration tests on connection={{ ansible_connection }}
+
+- name: Merged with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_logging_global:
+ config:
+ state: merged
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state merged'
+
+- name: Replaced with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_logging_global:
+ config:
+ state: replaced
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state replaced'
+
+- name: Overridden with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_logging_global:
+ config:
+ state: overridden
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state overridden'
+
+- name: Rendered with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_logging_global:
+ config:
+ state: rendered
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state rendered'
+
+- name: Parsed with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_logging_global:
+ running_config:
+ state: parsed
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of running_config parameter must not be empty for state parsed'
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/gathered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/gathered.yaml
new file mode 100644
index 000000000..d9eb5ea48
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/gathered.yaml
@@ -0,0 +1,20 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_logging_global gathered integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Test - [gathered] gather the provided configuration with the existing running configuration
+ register: result
+ cisco.ios.ios_logging_global:
+ config:
+ state: gathered
+
+ - name: Test - [gathered] assert
+ ansible.builtin.assert:
+ that:
+ - result.changed == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/merged.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/merged.yaml
new file mode 100644
index 000000000..7c3a84b8e
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/merged.yaml
@@ -0,0 +1,61 @@
+---
+- ansible.builtin.debug:
+ msg: Start Merged integration state for ios_logging_global ansible_connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- block:
+ - name: Test - [merged] apply provided configuration
+ cisco.ios.ios_logging_global:
+ config:
+ buffered:
+ severity: notifications
+ size: 5099
+ xml: true
+ console:
+ severity: critical
+ xml: true
+ facility: local5
+ hosts:
+ - hostname: 192.0.2.12
+ - hostname: 192.0.2.11
+ xml: true
+ - hostname: 192.0.2.10
+ filtered: true
+ stream: 10
+ - hostname: 192.0.2.13
+ transport:
+ tcp:
+ port: 514
+ monitor:
+ severity: warnings
+ message_counter:
+ - log
+ - syslog
+ trap: errors
+ userinfo: true
+ logging_on: enable
+ exception: 4099
+ dmvpn:
+ rate_limit: 10
+ cns_events: warnings
+ state: merged
+ register: result
+
+ - name: Test - [merged] assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Test - [merged] assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - merged['before'] == {}
+
+ - name: Test - [merged] assert that after dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - merged['after'] == result['after']
+
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/overridden.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/overridden.yaml
new file mode 100644
index 000000000..50551a5c0
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/overridden.yaml
@@ -0,0 +1,49 @@
+---
+- ansible.builtin.debug:
+ msg: START Overridden ios_logging_global state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Test - [overridden] override provided logging configuration
+ register: result
+ cisco.ios.ios_logging_global: &overrideid001
+ config:
+ monitor:
+ severity: critical
+ buffered:
+ severity: warnings
+ xml: true
+ size: 5099
+ facility: local6
+ hosts:
+ - host: 192.0.2.12
+ xml: true
+ state: overridden
+
+ - name: Test - [overridden] assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ overridden['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Test - [overridden] assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - merged['after'] == result['before']
+
+ - name: Test - [overridden] assert that after dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - overridden['after'] == result['after']
+
+ - name: Test - [overridden] override provided IOS logging global configuration idempotent
+ register: result
+ cisco.ios.ios_logging_global: *overrideid001
+ - name: Test - [overridden] assert that task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/parsed.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/parsed.yaml
new file mode 100644
index 000000000..605a5fd25
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/parsed.yaml
@@ -0,0 +1,14 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_logging_global parsed integration tests on connection={{ ansible_connection }}
+
+- name: Test - [parsed] parse the commands for provided configuration
+ register: result
+ cisco.ios.ios_logging_global:
+ running_config: "{{ lookup('file', '_parsed.cfg') }}"
+ state: parsed
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - parsed['after'] == result.parsed
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/rendered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/rendered.yaml
new file mode 100644
index 000000000..8cfdf88d1
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/rendered.yaml
@@ -0,0 +1,75 @@
+---
+- ansible.builtin.debug:
+ msg: Start ios_logging_global rendered integration tests ansible_connection={{ ansible_connection }}
+
+- block:
+ - name: Test - [rendered] render the commands for provided configuration
+ register: result
+ cisco.ios.ios_logging_global:
+ config:
+ buginf: true
+ buffered:
+ severity: notifications
+ size: 5099
+ xml: true
+ cns_events: warnings
+ console:
+ severity: critical
+ xml: true
+ count: true
+ delimiter:
+ tcp: true
+ discriminator: msglog01 severity includes 5
+ dmvpn:
+ rate_limit: 10
+ esm:
+ config: true
+ exception: 4099
+ facility: local5
+ filter:
+ - url: tftp://192.0.2.18/ESM/elate.tcl
+ args: TESTInst2
+ - url: tftp://192.0.2.14/ESM/escalate.tcl
+ args: TESTInst
+ history:
+ severity: alerts
+ hosts:
+ - hostname: 192.0.2.1
+ - hostname: 192.0.2.11
+ xml: true
+ transport:
+ tcp:
+ port: 514
+ - hostname: 192.0.2.10
+ filtered: true
+ stream: 10
+ message_counter:
+ - log
+ - syslog
+ monitor:
+ severity: warnings
+ origin_id:
+ tag: hostname
+ persistent:
+ batch: 4444
+ queue_limit:
+ esm: 150
+ rate_limit:
+ all: true
+ size: 2
+ except_severity: alerts
+ reload:
+ severity: alerts
+ server_arp: true
+ source_interface:
+ - interface: GBit1/0
+ - interface: CTunnel2
+ trap: errors
+ userinfo: true
+ logging_on: disable
+ state: rendered
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - result.rendered|symmetric_difference(rendered.commands) == []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/replaced.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/replaced.yaml
new file mode 100644
index 000000000..34a99499f
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/replaced.yaml
@@ -0,0 +1,48 @@
+---
+- ansible.builtin.debug:
+ msg: START Replaced ios_logging_global state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Test - [replaced] replace provided logging configuration
+ register: result
+ cisco.ios.ios_logging_global: &replacedid001
+ config:
+ buffered:
+ severity: alerts
+ size: 6025
+ facility: local6
+ hosts:
+ - host: 192.0.2.19
+ - host: 192.0.2.10
+ filtered: true
+ stream: 15
+ state: replaced
+
+ - name: Test - [replaced] assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ replaced['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Test - [replaced] assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - merged['after'] == result['before']
+
+ - name: Test - [replaced] assert that after dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - replaced['after'] == result['after']
+
+ - name: Test - [replaced] replaced provided IOS logging global configuration idempotent
+ register: result
+ cisco.ios.ios_logging_global: *replacedid001
+ - name: Test - [replaced] assert that task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/vars/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/vars/main.yaml
new file mode 100644
index 000000000..bc55bf31f
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/vars/main.yaml
@@ -0,0 +1,171 @@
+---
+merged:
+ before: {}
+
+ commands:
+ - logging on
+ - logging host 192.0.2.13 transport tcp port 514
+ - logging userinfo
+ - logging facility local5
+ - logging message-counter log
+ - logging dmvpn rate-limit 10
+ - logging host 192.0.2.12
+ - logging host 192.0.2.11 xml
+ - logging message-counter syslog
+ - logging buffered xml 5099 notifications
+ - logging console xml critical
+ - logging monitor warnings
+ - logging exception 4099
+ - logging host 192.0.2.10 filtered stream 10
+ - logging cns-events warnings
+ - logging trap errors
+
+ after:
+ buffered:
+ severity: notifications
+ size: 5099
+ xml: true
+ cns_events: warnings
+ console:
+ severity: critical
+ xml: true
+ dmvpn:
+ rate_limit: 10
+ exception: 4099
+ facility: local5
+ hosts:
+ - host: 192.0.2.10
+ filtered: true
+ stream: 10
+ - host: 192.0.2.11
+ xml: true
+ - host: 192.0.2.12
+ - host: 192.0.2.13
+ transport:
+ tcp:
+ port: 514
+ message_counter:
+ - log
+ monitor:
+ severity: warnings
+ trap: errors
+ userinfo: true
+
+replaced:
+ commands:
+ - logging buffered 6025 alerts
+ - no logging cns-events warnings
+ - no logging console xml critical
+ - no logging dmvpn rate-limit 10
+ - no logging exception 4099
+ - logging facility local6
+ - no logging monitor warnings
+ - no logging trap errors
+ - no logging userinfo
+ - logging host 192.0.2.19
+ - no logging host 192.0.2.10
+ - logging host 192.0.2.10 filtered stream 15
+ - no logging host 192.0.2.11
+ - no logging host 192.0.2.12
+ - no logging host 192.0.2.13
+ - no logging message-counter log
+
+ after:
+ buffered:
+ severity: alerts
+ size: 6025
+ facility: local6
+ hosts:
+ - host: 192.0.2.10
+ filtered: true
+ stream: 15
+ - host: 192.0.2.19
+
+overridden:
+ commands:
+ - logging buffered xml 5099 warnings
+ - no logging cns-events warnings
+ - no logging console xml critical
+ - no logging dmvpn rate-limit 10
+ - no logging exception 4099
+ - logging facility local6
+ - logging monitor critical
+ - no logging trap errors
+ - no logging userinfo
+ - no logging host 192.0.2.12
+ - logging host 192.0.2.12 xml
+ - no logging host 192.0.2.10
+ - no logging host 192.0.2.11
+ - no logging host 192.0.2.13
+ - no logging message-counter log
+
+ after:
+ buffered:
+ severity: warnings
+ xml: true
+ size: 5099
+ facility: local6
+ hosts:
+ - host: 192.0.2.12
+ xml: true
+ monitor:
+ severity: critical
+
+deleted:
+ commands:
+ - no logging message-counter log
+ - no logging host 192.0.2.13
+ - no logging host 192.0.2.11
+ - no logging host 192.0.2.12
+ - no logging host 192.0.2.10
+ - no logging exception 4099
+ - no logging userinfo
+ - no logging buffered xml 5099 notifications
+ - no logging console xml critical
+ - no logging monitor warnings
+ - no logging cns-events warnings
+ - no logging dmvpn rate-limit 10
+ - no logging trap errors
+ - no logging facility local5
+ after: {}
+
+parsed:
+ after:
+ buffered:
+ severity: notifications
+ size: 5099
+ xml: true
+
+rendered:
+ commands:
+ - logging buffered xml 5099 notifications
+ - logging buginf
+ - logging cns-events warnings
+ - logging console xml critical
+ - logging count
+ - logging delimiter tcp
+ - logging dmvpn rate-limit 10
+ - logging esm config
+ - logging exception 4099
+ - logging facility local5
+ - logging history alerts
+ - logging monitor warnings
+ - no logging on
+ - logging origin-id hostname
+ - logging persistent batch 4444
+ - logging queue-limit esm 150
+ - logging rate-limit all 2 except alerts
+ - logging reload alerts
+ - logging server-arp
+ - logging trap errors
+ - logging userinfo
+ - logging host 192.0.2.1
+ - logging host 192.0.2.11 transport tcp port 514
+ - logging host 192.0.2.10 filtered stream 10
+ - logging filter tftp://192.0.2.18/ESM/elate.tcl args TESTInst2
+ - logging filter tftp://192.0.2.14/ESM/escalate.tcl args TESTInst
+ - logging source-interface GBit1/0
+ - logging source-interface CTunnel2
+ - logging message-counter log
+ - logging message-counter syslog
+ - logging discriminator msglog01 severity includes 5
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp/defaults/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp/defaults/main.yaml
new file mode 100644
index 000000000..5f709c5aa
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp/defaults/main.yaml
@@ -0,0 +1,2 @@
+---
+testcase: "*"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp/meta/main.yml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp/meta/main.yml
new file mode 100644
index 000000000..ab3ad91bc
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - prepare_ios_tests
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp/tasks/cli.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp/tasks/cli.yaml
new file mode 100644
index 000000000..cd8c04990
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp/tasks/cli.yaml
@@ -0,0 +1,18 @@
+---
+- name: Collect all CLI test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: Run test cases (connection=ansible.netcommon.network_cli)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+ tags: network_cli
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp/tasks/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp/tasks/main.yaml
new file mode 100644
index 000000000..3d2666f3e
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp/tasks/main.yaml
@@ -0,0 +1,3 @@
+---
+- name: Main task for ntp module
+ ansible.builtin.include_tasks: cli.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp/tests/cli/ntp_configuration.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp/tests/cli/ntp_configuration.yaml
new file mode 100644
index 000000000..92063dfb5
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp/tests/cli/ntp_configuration.yaml
@@ -0,0 +1,87 @@
+---
+- ansible.builtin.debug: msg="START connection={{ ansible_connection }} ios_ntp sanity test"
+
+- name: Remove ntp (if set)
+ ignore_errors: true
+ cisco.ios.ios_ntp: &id007
+ server: 10.75.32.5
+ source_int: "{{ test_interface }}"
+ acl: NTP_ACL
+ logging: true
+ key_id: 10
+ auth_key: 15435A030726242723273C21181319000A
+ auth: true
+ state: absent
+
+- block:
+ - name: Configure ntp
+ register: result
+ cisco.ios.ios_ntp: &id001
+ server: 10.75.32.5
+ source_int: "{{ test_interface }}"
+ state: present
+
+ - ansible.builtin.assert: &id002
+ that:
+ - result.changed == true
+
+ - name: Idempotent check
+ register: result
+ cisco.ios.ios_ntp: *id001
+ - ansible.builtin.assert: &id004
+ that:
+ - result.changed == false
+
+ - name: Load ACL ntp_acl into device
+ register: result
+ cisco.ios.ios_config:
+ lines:
+ - 10 permit ip host 192.0.2.1 any log
+ parents: ip access-list extended NTP_ACL
+
+ - ansible.builtin.assert: *id002
+ - name: Configure ntp
+ register: result
+ cisco.ios.ios_ntp: &id003
+ acl: NTP_ACL
+ logging: true
+ state: present
+
+ - ansible.builtin.assert: *id002
+ - name: Idempotent check
+ register: result
+ cisco.ios.ios_ntp: *id003
+ - ansible.builtin.assert: *id004
+ - name: Configure ntp with different values
+ register: result
+ cisco.ios.ios_ntp: &id005
+ key_id: 10
+ auth_key: 15435A030726242723273C21181319000A
+ auth: true
+ vrf: my_mgmt_vrf
+ state: present
+
+ - ansible.builtin.assert: *id002
+ - name: Idempotent check
+ register: result
+ cisco.ios.ios_ntp: *id005
+ - ansible.builtin.assert: *id004
+ - name: Remove part of configuration
+ register: result
+ cisco.ios.ios_ntp: &id006
+ acl: NTP_ACL
+ logging: true
+ state: absent
+
+ - ansible.builtin.assert: *id002
+ - name: Idempotent check
+ register: result
+ cisco.ios.ios_ntp: *id006
+ - ansible.builtin.assert: *id004
+ always:
+ - name: Remove ntp configuration
+ cisco.ios.ios_ntp: *id007
+ - name: Remove ntp_acl from device
+ cisco.ios.ios_config:
+ lines:
+ - no ip access-list extended NTP_ACL
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/defaults/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/defaults/main.yaml
new file mode 100644
index 000000000..164afead2
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/meta/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/meta/main.yaml
new file mode 100644
index 000000000..23d65c7ef
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/meta/main.yaml
@@ -0,0 +1,2 @@
+---
+dependencies: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tasks/cli.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tasks/cli.yaml
new file mode 100644
index 000000000..6f505600c
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tasks/cli.yaml
@@ -0,0 +1,21 @@
+---
+- name: Collect all CLI test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+ delegate_to: localhost
+
+- name: Run test case (connection=ansible.netcommon.network_cli)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.network_cli
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tasks/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tasks/main.yaml
new file mode 100644
index 000000000..226cde87e
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tasks/main.yaml
@@ -0,0 +1,5 @@
+---
+- name: Main task for ntp_global module
+ ansible.builtin.include_tasks: cli.yaml
+ tags:
+ - network_cli
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/_parsed.cfg b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/_parsed.cfg
new file mode 100644
index 000000000..b087717e0
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/_parsed.cfg
@@ -0,0 +1,10 @@
+ntp max-associations 34
+ntp logging
+ntp panic update
+ntp orphan 4
+ntp mindistance 10
+ntp maxdistance 3
+ntp broadcastdelay 22
+ntp master 4
+ntp peer 192.0.2.10 version 2
+ntp server 192.0.2.11 key 2
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/_populate_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/_populate_config.yaml
new file mode 100644
index 000000000..50912f0f6
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/_populate_config.yaml
@@ -0,0 +1,17 @@
+---
+- name: Populate configuration ntp_global
+ cisco.ios.ios_ntp_global:
+ config:
+ broadcast_delay: 22
+ logging: true
+ master:
+ stratum: 4
+ max_associations: 34
+ max_distance: 3
+ min_distance: 10
+ orphan: 4
+ panic_update: true
+ peers:
+ - peer: 192.0.2.10
+ version: 2
+ state: merged
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/_remove_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/_remove_config.yaml
new file mode 100644
index 000000000..39b17268f
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/_remove_config.yaml
@@ -0,0 +1,5 @@
+---
+- name: Remove all configuration ntp_global
+ cisco.ios.ios_ntp_global:
+ config:
+ state: deleted
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/deleted.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/deleted.yaml
new file mode 100644
index 000000000..1c1120e7f
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/deleted.yaml
@@ -0,0 +1,34 @@
+---
+- ansible.builtin.debug:
+ msg: Start Deleted integration state for ios_ntp_global ansible_connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Ios_ntp_global deleted - play
+ register: result
+ cisco.ios.ios_ntp_global: &id001
+ config:
+ state: deleted
+
+ - name: Ios_ntp_global deleted - assert commands
+ ansible.builtin.assert:
+ that:
+ - deleted['commands'] == result['commands']
+
+ - name: Ios_ntp_global deleted - assert before
+ ansible.builtin.assert:
+ that:
+ - deleted['before'] == result['before']
+
+ - name: Ios_ntp_global deleted - play (idempotent)
+ register: result
+ cisco.ios.ios_ntp_global: *id001
+ - name: Ios_ntp_global deleted - assert above task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result.changed == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/empty_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/empty_config.yaml
new file mode 100644
index 000000000..6de39bf6a
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/empty_config.yaml
@@ -0,0 +1,58 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_ntp_global empty_config.yaml integration tests on connection={{ ansible_connection }}
+
+- name: Merged with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_ntp_global:
+ config:
+ state: merged
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state merged'
+
+- name: Replaced with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_ntp_global:
+ config:
+ state: replaced
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state replaced'
+
+- name: Overridden with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_ntp_global:
+ config:
+ state: overridden
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state overridden'
+
+- name: Rendered with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_ntp_global:
+ config:
+ state: rendered
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state rendered'
+
+- name: Parsed with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_ntp_global:
+ running_config:
+ state: parsed
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of running_config parameter must not be empty for state parsed'
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/gathered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/gathered.yaml
new file mode 100644
index 000000000..39923de4f
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/gathered.yaml
@@ -0,0 +1,20 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_ntp_global gathered integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Ios_ntp_global gather - play
+ register: result
+ cisco.ios.ios_ntp_global:
+ config:
+ state: gathered
+
+ - name: Ios_ntp_global gather - assert
+ ansible.builtin.assert:
+ that:
+ - gathered['config'] == result['gathered']
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/merged.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/merged.yaml
new file mode 100644
index 000000000..2f99e6da0
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/merged.yaml
@@ -0,0 +1,37 @@
+---
+- ansible.builtin.debug:
+ msg: START Merged ios_ntp_global state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- block:
+ - name: Ios_ntp_global merged - play
+ register: result
+ cisco.ios.ios_ntp_global: &id001
+ config:
+ master:
+ stratum: 4
+ max_associations: 34
+ max_distance: 3
+ min_distance: 10
+ state: merged
+
+ - name: Ios_ntp_global merged - assert commands
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Ios_ntp_global merged - assert after
+ ansible.builtin.assert:
+ that:
+ - merged['after'] == result['after']
+
+ - name: Ios_ntp_global merged - play (idempotent)
+ register: result
+ cisco.ios.ios_ntp_global: *id001
+ - name: Ios_ntp_global merged - assert above task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/overridden.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/overridden.yaml
new file mode 100644
index 000000000..5dc413fcc
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/overridden.yaml
@@ -0,0 +1,44 @@
+---
+- ansible.builtin.debug:
+ msg: START Overridden ios_ntp_global state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Ios_ntp_global overridden - play
+ register: result
+ cisco.ios.ios_ntp_global: &id001
+ config:
+ broadcast_delay: 113
+ orphan: 10
+ servers:
+ - server: 192.0.2.15
+ key: 2
+ state: overridden
+
+ - name: Ios_ntp_global overridden - assert commands
+ ansible.builtin.assert:
+ that:
+ - overridden['commands'] == result['commands']
+
+ - name: Ios_ntp_global overridden - assert before
+ ansible.builtin.assert:
+ that:
+ - overridden['before'] == result['before']
+
+ - name: Ios_ntp_global overridden - assert after
+ ansible.builtin.assert:
+ that:
+ - overridden['after'] == result['after']
+
+ - name: Ios_ntp_global overridden - play (idempotent)
+ register: result
+ cisco.ios.ios_ntp_global: *id001
+ - name: Ios_ntp_global overridden - assert above task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/parsed.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/parsed.yaml
new file mode 100644
index 000000000..dfcefbe7b
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/parsed.yaml
@@ -0,0 +1,14 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_ntp_global parsed integration tests on connection={{ ansible_connection }}
+
+- name: Ios_ntp_global parsed - play
+ register: result
+ cisco.ios.ios_ntp_global:
+ running_config: "{{ lookup('file', '_parsed.cfg') }}"
+ state: parsed
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - parsed['config'] == result['parsed']
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/rendered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/rendered.yaml
new file mode 100644
index 000000000..c613daac7
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/rendered.yaml
@@ -0,0 +1,28 @@
+---
+- ansible.builtin.debug:
+ msg: Start ios_ntp_global rendered integration tests ansible_connection={{ ansible_connection }}
+
+- block:
+ - name: Ios_ntp_global render - play
+ register: result
+ cisco.ios.ios_ntp_global:
+ config:
+ broadcast_delay: 22
+ clock_period: 5
+ logging: true
+ master:
+ stratum: 4
+ max_associations: 34
+ max_distance: 3
+ min_distance: 10
+ orphan: 4
+ panic_update: true
+ peers:
+ - peer: 192.0.2.10
+ version: 2
+ state: rendered
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - result.rendered == rendered['commands']
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/rtt.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/rtt.yaml
new file mode 100644
index 000000000..2df7a3eb1
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/tests/cli/rtt.yaml
@@ -0,0 +1,46 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_ntp_global round trip integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- block:
+ - name: Ios_ntp_global RTT - play (base config)
+ register: result
+ cisco.ios.ios_ntp_global:
+ config:
+ min_distance: 10
+ orphan: 4
+ panic_update: true
+ state: merged
+
+ - name: Ios_ntp_global RTT - gather ntp facts
+ cisco.ios.ios_facts:
+ gather_subset:
+ - "!all"
+ - "!min"
+ gather_network_resources:
+ - ntp_global
+
+ - name: Ios_ntp_global RTT - apply the provided configuration (config to be reverted)
+ cisco.ios.ios_ntp_global:
+ config:
+ max_distance: 3
+ min_distance: 10
+ orphan: 4
+ panic_update: true
+ state: replaced
+
+ - name: Ios_ntp_global RTT - revert back to base configuration using facts round trip
+ register: revert
+ cisco.ios.ios_ntp_global:
+ config: "{{ ansible_facts['network_resources']['ntp_global'] }}"
+ state: overridden
+
+ - ansible.builtin.assert:
+ that:
+ - revert.changed == true
+ - revert['commands'] == rtt['commands']
+
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/vars/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/vars/main.yaml
new file mode 100644
index 000000000..386b1520c
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ntp_global/vars/main.yaml
@@ -0,0 +1,120 @@
+---
+merged:
+ commands:
+ - ntp master 4
+ - ntp max-associations 34
+ - ntp maxdistance 3
+ - ntp mindistance 10
+ after:
+ master:
+ stratum: 4
+ max_associations: 34
+ max_distance: 3
+ min_distance: 10
+
+overridden:
+ before:
+ broadcast_delay: 22
+ logging: true
+ master:
+ stratum: 4
+ max_associations: 34
+ max_distance: 3
+ min_distance: 10
+ orphan: 4
+ panic_update: true
+ peers:
+ - peer: 192.0.2.10
+ version: 2
+ commands:
+ - ntp broadcastdelay 113
+ - no ntp logging
+ - no ntp master 4
+ - no ntp max-associations 34
+ - no ntp maxdistance 3
+ - no ntp mindistance 10
+ - ntp orphan 10
+ - no ntp panic update
+ - no ntp peer 192.0.2.10 version 2
+ - ntp server 192.0.2.15 key 2
+ after:
+ broadcast_delay: 113
+ orphan: 10
+ servers:
+ - server: 192.0.2.15
+ key_id: 2
+
+deleted:
+ before:
+ broadcast_delay: 22
+ logging: true
+ master:
+ stratum: 4
+ max_associations: 34
+ max_distance: 3
+ min_distance: 10
+ orphan: 4
+ panic_update: true
+ peers:
+ - peer: 192.0.2.10
+ version: 2
+ commands:
+ - no ntp broadcastdelay 22
+ - no ntp logging
+ - no ntp master 4
+ - no ntp max-associations 34
+ - no ntp maxdistance 3
+ - no ntp mindistance 10
+ - no ntp orphan 4
+ - no ntp panic update
+ - no ntp peer 192.0.2.10 version 2
+
+parsed:
+ config:
+ broadcast_delay: 22
+ logging: true
+ master:
+ stratum: 4
+ max_associations: 34
+ max_distance: 3
+ min_distance: 10
+ orphan: 4
+ panic_update: true
+ peers:
+ - peer: 192.0.2.10
+ version: 2
+ servers:
+ - server: 192.0.2.11
+ key_id: 2
+
+gathered:
+ config:
+ broadcast_delay: 22
+ logging: true
+ master:
+ stratum: 4
+ max_associations: 34
+ max_distance: 3
+ min_distance: 10
+ orphan: 4
+ panic_update: true
+ peers:
+ - peer: 192.0.2.10
+ version: 2
+
+rtt:
+ commands:
+ - no ntp maxdistance 3
+
+rendered:
+ commands:
+ - ntp broadcastdelay 22
+ - ntp clock-period 5
+ - ntp logging
+ - ntp master 4
+ - ntp max-associations 34
+ - ntp maxdistance 3
+ - ntp mindistance 10
+ - ntp orphan 4
+ - ntp panic update
+ - ntp peer 192.0.2.10 version 2
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/defaults/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/defaults/main.yaml
new file mode 100644
index 000000000..164afead2
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/meta/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/meta/main.yaml
new file mode 100644
index 000000000..23d65c7ef
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/meta/main.yaml
@@ -0,0 +1,2 @@
+---
+dependencies: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tasks/cli.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tasks/cli.yaml
new file mode 100644
index 000000000..6f505600c
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tasks/cli.yaml
@@ -0,0 +1,21 @@
+---
+- name: Collect all CLI test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+ delegate_to: localhost
+
+- name: Run test case (connection=ansible.netcommon.network_cli)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.network_cli
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tasks/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tasks/main.yaml
new file mode 100644
index 000000000..119141d45
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tasks/main.yaml
@@ -0,0 +1,5 @@
+---
+- name: Main task for ospf_interfaces module
+ ansible.builtin.include_tasks: cli.yaml
+ tags:
+ - network_cli
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/_initial_ipv6_setup.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/_initial_ipv6_setup.yaml
new file mode 100644
index 000000000..3726a9911
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/_initial_ipv6_setup.yaml
@@ -0,0 +1,6 @@
+---
+- name: Create and setup ipv6 configuration
+ vars:
+ lines: "interface GigabitEthernet 2\nipv6 address 2001:db8:0:1::/64\ninterface GigabitEthernet 3\nipv6 address 2001:db8:0:2::/64\n"
+ ansible.netcommon.cli_config:
+ config: "{{ lines }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/_parsed.cfg b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/_parsed.cfg
new file mode 100644
index 000000000..38f2e1d5c
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/_parsed.cfg
@@ -0,0 +1,22 @@
+interface Loopback888
+interface Loopback999
+interface GigabitEthernet1
+interface GigabitEthernet2
+ ip ospf network broadcast
+ ip ospf authentication message-digest
+ ip ospf resync-timeout 10
+ ip ospf dead-interval 5
+ ip ospf priority 25
+ ip ospf demand-circuit ignore
+ ip ospf bfd
+ ip ospf adjacency stagger disable
+ ip ospf ttl-security hops 50
+ ip ospf shutdown
+ ip ospf 10 area 30
+ ip ospf cost 5
+ ipv6 ospf priority 55
+ ipv6 ospf transmit-delay 45
+ ipv6 ospf database-filter all out
+ ipv6 ospf adjacency stagger disable
+ ipv6 ospf manet peering link-metrics 10
+interface GigabitEthernet3
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/_populate_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/_populate_config.yaml
new file mode 100644
index 000000000..8b4567e3b
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/_populate_config.yaml
@@ -0,0 +1,33 @@
+---
+- name: Populate OSPF interfaces configuration
+ cisco.ios.ios_ospf_interfaces:
+ config:
+ - name: GigabitEthernet2
+ address_family:
+ - afi: ipv4
+ authentication:
+ message_digest: true
+ process:
+ id: 10
+ area_id: 30
+ adjacency: true
+ bfd: true
+ cost:
+ interface_cost: 5
+ dead_interval:
+ time: 5
+ demand_circuit:
+ ignore: true
+ network:
+ broadcast: true
+ priority: 25
+ resync_timeout: 10
+ shutdown: true
+ ttl_security:
+ hops: 50
+ - afi: ipv6
+ adjacency: true
+ database_filter: true
+ priority: 55
+ transmit_delay: 45
+ state: replaced
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/_remove_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/_remove_config.yaml
new file mode 100644
index 000000000..2979674f4
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/_remove_config.yaml
@@ -0,0 +1,20 @@
+---
+- name: Remove OSPF interfaces configuration
+ cisco.ios.ios_ospf_interfaces:
+ state: deleted
+
+- name: Delete and clean ipv6 configuration
+ vars:
+ lines: "interface GigabitEthernet 2\nno ipv6 address 2001:DB8:0:1::/64\ninterface GigabitEthernet 3\nno ipv6 address 2001:DB8:0:2::/64\n"
+ ansible.netcommon.cli_config:
+ config: "{{ lines }}"
+
+- name: Delete attributes of all configured interfaces
+ register: result
+ cisco.ios.ios_interfaces:
+ config:
+ - name: Port-channel10
+ - name: Port-channel11
+ - name: Port-channel22
+ - name: Port-channel40
+ state: purged
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/deleted.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/deleted.yaml
new file mode 100644
index 000000000..86b5ba744
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/deleted.yaml
@@ -0,0 +1,51 @@
+---
+- ansible.builtin.debug:
+ msg: Start Deleted integration state for ios_ospf_interfaces ansible_connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+- ansible.builtin.include_tasks: _initial_ipv6_setup.yaml
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Delete provided OSPF interfaces
+ register: result
+ cisco.ios.ios_ospf_interfaces: &id001
+ config:
+ - name: GigabitEthernet2
+ state: deleted
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ deleted['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Delete provided OSPF interfaces (idempotent)
+ register: result
+ cisco.ios.ios_ospf_interfaces: *id001
+ - name: Assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+ - ansible.builtin.include_tasks: _populate_config.yaml
+
+ - name: Delete provided OSPF interfaces without any configuration
+ register: result
+ cisco.ios.ios_ospf_interfaces: &id002
+ state: deleted
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ deleted['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Delete provided OSPF interfaces without any configuration (idempotent)
+ register: result
+ cisco.ios.ios_ospf_interfaces: *id002
+ - name: Assert that the delete task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/empty_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/empty_config.yaml
new file mode 100644
index 000000000..f1877aeff
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/empty_config.yaml
@@ -0,0 +1,58 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_ospf_interfaces empty_config.yaml integration tests on connection={{ ansible_connection }}
+
+- name: Merged with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_ospf_interfaces:
+ config:
+ state: merged
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state merged'
+
+- name: Replaced with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_ospf_interfaces:
+ config:
+ state: replaced
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state replaced'
+
+- name: Overridden with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_ospf_interfaces:
+ config:
+ state: overridden
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state overridden'
+
+- name: Rendered with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_ospf_interfaces:
+ config:
+ state: rendered
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state rendered'
+
+- name: Parsed with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_ospf_interfaces:
+ running_config:
+ state: parsed
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of running_config parameter must not be empty for state parsed'
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/gathered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/gathered.yaml
new file mode 100644
index 000000000..14d1e56f5
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/gathered.yaml
@@ -0,0 +1,23 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_ospf_interfaces gathered integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+- ansible.builtin.include_tasks: _initial_ipv6_setup.yaml
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Gather the provided configuration with the existing running configuration
+ register: result
+ cisco.ios.ios_ospf_interfaces:
+ config:
+ state: gathered
+
+ - name: Assert
+ ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - "{{ gathered['config'] | symmetric_difference(result['gathered']) |length == 0 }}"
+
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/merged.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/merged.yaml
new file mode 100644
index 000000000..68ce3bde9
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/merged.yaml
@@ -0,0 +1,69 @@
+---
+- ansible.builtin.debug:
+ msg: START Merged ios_ospf_interfaces state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+- ansible.builtin.include_tasks: _initial_ipv6_setup.yaml
+
+- block:
+ - name: Merge provided configuration with device configuration
+ register: result
+ cisco.ios.ios_ospf_interfaces: &id001
+ config:
+ - name: GigabitEthernet2
+ address_family:
+ - afi: ipv4
+ authentication:
+ message_digest: true
+ process:
+ id: 10
+ area_id: 30
+ adjacency: true
+ bfd: true
+ cost:
+ interface_cost: 5
+ dead_interval:
+ time: 5
+ demand_circuit:
+ ignore: true
+ network:
+ broadcast: true
+ priority: 25
+ resync_timeout: 10
+ shutdown: true
+ ttl_security:
+ hops: 50
+ - afi: ipv6
+ adjacency: true
+ database_filter: true
+ # manet:
+ # link_metrics:
+ # cost_threshold: 10
+ priority: 55
+ transmit_delay: 45
+ state: merged
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['before'] | symmetric_difference(result['before']) | length == 0 }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['after'] | symmetric_difference(result['after']) | length == 0 }}"
+
+ - name: Merge provided configuration with device configuration (idempotent)
+ register: result
+ cisco.ios.ios_ospf_interfaces: *id001
+ - name: Assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/overridden.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/overridden.yaml
new file mode 100644
index 000000000..dd8e5b621
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/overridden.yaml
@@ -0,0 +1,58 @@
+---
+- ansible.builtin.debug:
+ msg: START Overridden ios_ospf_interfaces state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+- ansible.builtin.include_tasks: _initial_ipv6_setup.yaml
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Override provided OSPF interfaces configuration
+ register: result
+ cisco.ios.ios_ospf_interfaces: &id001
+ config:
+ - name: GigabitEthernet2
+ address_family:
+ - afi: ipv6
+ adjacency: true
+ priority: 20
+ transmit_delay: 30
+ - name: GigabitEthernet3
+ address_family:
+ - afi: ipv4
+ process:
+ id: 10
+ area_id: 20
+ adjacency: true
+ cost:
+ interface_cost: 30
+ priority: 40
+ ttl_security:
+ set: true
+ hops: 50
+ state: overridden
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ overridden['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['after'] | symmetric_difference(result['before']) | length == 0 }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ overridden['after'] | symmetric_difference(result['after']) | length == 0 }}"
+
+ - name: Override provided OSPF interfaces configuration (idempotent)
+ register: result
+ cisco.ios.ios_ospf_interfaces: *id001
+ - name: Assert that task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/parsed.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/parsed.yaml
new file mode 100644
index 000000000..bc5d07686
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/parsed.yaml
@@ -0,0 +1,14 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_ospf_interfaces parsed integration tests on connection={{ ansible_connection }}
+
+- name: Parse the commands for provided configuration
+ register: result
+ cisco.ios.ios_ospf_interfaces:
+ running_config: "{{ lookup('file', '_parsed.cfg') }}"
+ state: parsed
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - "{{ parsed['config'] | symmetric_difference(result['parsed']) |length == 0 }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/rendered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/rendered.yaml
new file mode 100644
index 000000000..f4cb02c85
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/rendered.yaml
@@ -0,0 +1,46 @@
+---
+- ansible.builtin.debug:
+ msg: Start ios_ospf_interfaces rendered integration tests ansible_connection={{ ansible_connection }}
+
+- block:
+ - name: Render the commands for provided configuration
+ register: result
+ cisco.ios.ios_ospf_interfaces:
+ config:
+ - name: GigabitEthernet2
+ address_family:
+ - afi: ipv4
+ authentication:
+ message_digest: true
+ process:
+ id: 10
+ area_id: 30
+ adjacency: true
+ bfd: true
+ cost:
+ interface_cost: 5
+ dead_interval:
+ time: 5
+ demand_circuit:
+ ignore: true
+ network:
+ broadcast: true
+ priority: 25
+ resync_timeout: 10
+ shutdown: true
+ ttl_security:
+ hops: 50
+ - afi: ipv6
+ adjacency: true
+ database_filter: true
+ manet:
+ link_metrics:
+ cost_threshold: 10
+ priority: 55
+ transmit_delay: 45
+ state: rendered
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - result.rendered|symmetric_difference(rendered.commands) == []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/replaced.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/replaced.yaml
new file mode 100644
index 000000000..854c2c3c1
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/replaced.yaml
@@ -0,0 +1,45 @@
+---
+- ansible.builtin.debug:
+ msg: START Replaced ios_ospf_interfaces state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+- ansible.builtin.include_tasks: _initial_ipv6_setup.yaml
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Replaced provided OSPF interfaces configuration
+ register: result
+ cisco.ios.ios_ospf_interfaces: &id001
+ config:
+ - name: GigabitEthernet3
+ address_family:
+ - afi: ipv6
+ adjacency: true
+ priority: 20
+ transmit_delay: 30
+ state: replaced
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ replaced['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ replaced['before'] | symmetric_difference(result['before']) | length == 0 }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ replaced['after'] | symmetric_difference(result['after']) | length == 0 }}"
+
+ - name: Replaced provided OSPF interfaces configuration (idempotent)
+ register: result
+ cisco.ios.ios_ospf_interfaces: *id001
+ - name: Assert that task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/rtt.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/rtt.yaml
new file mode 100644
index 000000000..295651750
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/tests/cli/rtt.yaml
@@ -0,0 +1,96 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_ospf_interfaces round trip integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+- ansible.builtin.include_tasks: _initial_ipv6_setup.yaml
+
+- block:
+ - name: Apply the provided configuration (base config)
+ register: base_config
+ cisco.ios.ios_ospf_interfaces:
+ config:
+ - name: GigabitEthernet2
+ address_family:
+ - afi: ipv4
+ authentication:
+ message_digest: true
+ process:
+ id: 10
+ area_id: 30
+ adjacency: true
+ bfd: true
+ cost:
+ interface_cost: 5
+ dead_interval:
+ time: 5
+ demand_circuit:
+ ignore: true
+ network:
+ broadcast: true
+ priority: 25
+ resync_timeout: 10
+ shutdown: true
+ ttl_security:
+ hops: 50
+ - afi: ipv6
+ adjacency: true
+ database_filter: true
+ # manet:
+ # link_metrics:
+ # cost_threshold: 10
+ priority: 55
+ transmit_delay: 45
+ state: merged
+
+ - name: Gather OSPF interfaces facts
+ cisco.ios.ios_facts:
+ gather_subset:
+ - "!all"
+ - "!min"
+ gather_network_resources:
+ - ospf_interfaces
+
+ - name: Apply the provided configuration (config to be reverted)
+ register: result
+ cisco.ios.ios_ospf_interfaces:
+ config:
+ - name: GigabitEthernet2
+ address_family:
+ - afi: ipv6
+ adjacency: true
+ priority: 20
+ transmit_delay: 30
+ - name: GigabitEthernet3
+ address_family:
+ - afi: ipv4
+ process:
+ id: 10
+ area_id: 20
+ adjacency: true
+ cost:
+ interface_cost: 30
+ priority: 40
+ ttl_security:
+ hops: 50
+ state: overridden
+
+ - ansible.builtin.assert:
+ that:
+ # - result.commands|length == 23
+ - result.changed == true
+ - result.commands|symmetric_difference(overridden.commands) == []
+
+ - name: Revert back to base configuration using facts round trip
+ register: revert
+ cisco.ios.ios_ospf_interfaces:
+ config: "{{ ansible_facts['network_resources']['ospf_interfaces'] }}"
+ state: overridden
+
+ - ansible.builtin.assert:
+ that:
+ # - revert.commands|length == 23
+ - revert.changed == true
+ - revert.commands|symmetric_difference(rtt.commands) == []
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/vars/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/vars/main.yaml
new file mode 100644
index 000000000..0816aae21
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospf_interfaces/vars/main.yaml
@@ -0,0 +1,327 @@
+---
+merged:
+ before:
+ - name: Loopback888
+ - name: Loopback999
+ - name: GigabitEthernet1
+ - name: GigabitEthernet2
+ - name: GigabitEthernet3
+ - name: GigabitEthernet4
+ commands:
+ - interface GigabitEthernet2
+ - ip ospf 10 area 30
+ - ip ospf adjacency stagger disable
+ - ip ospf bfd
+ - ip ospf cost 5
+ - ip ospf dead-interval 5
+ - ip ospf demand-circuit ignore
+ - ip ospf network broadcast
+ - ip ospf priority 25
+ - ip ospf resync-timeout 10
+ - ip ospf shutdown
+ - ip ospf ttl-security hops 50
+ - ipv6 ospf adjacency stagger disable
+ - ipv6 ospf database-filter all out
+ - ipv6 ospf priority 55
+ - ipv6 ospf transmit-delay 45
+ after:
+ - name: Loopback888
+ - name: Loopback999
+ - name: GigabitEthernet1
+ - address_family:
+ - adjacency: true
+ afi: ipv4
+ bfd: true
+ cost:
+ interface_cost: 5
+ dead_interval:
+ time: 5
+ demand_circuit:
+ enable: true
+ ignore: true
+ network:
+ broadcast: true
+ priority: 25
+ process:
+ area_id: "30"
+ id: 10
+ resync_timeout: 10
+ shutdown: true
+ ttl_security:
+ hops: 50
+ set: true
+ - adjacency: true
+ afi: ipv6
+ database_filter: true
+ priority: 55
+ transmit_delay: 45
+ name: GigabitEthernet2
+ - name: GigabitEthernet3
+ - name: GigabitEthernet4
+
+replaced:
+ before:
+ - name: Loopback888
+ - name: Loopback999
+ - name: GigabitEthernet1
+ - address_family:
+ - adjacency: true
+ afi: ipv4
+ bfd: true
+ cost:
+ interface_cost: 5
+ dead_interval:
+ time: 5
+ demand_circuit:
+ enable: true
+ ignore: true
+ network:
+ broadcast: true
+ priority: 25
+ process:
+ area_id: "30"
+ id: 10
+ resync_timeout: 10
+ shutdown: true
+ ttl_security:
+ hops: 50
+ set: true
+ - adjacency: true
+ afi: ipv6
+ database_filter: true
+ priority: 55
+ transmit_delay: 45
+ name: GigabitEthernet2
+ - name: GigabitEthernet3
+ - name: GigabitEthernet4
+ commands:
+ - interface GigabitEthernet3
+ - ipv6 ospf adjacency stagger disable
+ - ipv6 ospf priority 20
+ - ipv6 ospf transmit-delay 30
+ after:
+ - name: Loopback888
+ - name: Loopback999
+ - name: GigabitEthernet1
+ - address_family:
+ - adjacency: true
+ afi: ipv4
+ bfd: true
+ cost:
+ interface_cost: 5
+ dead_interval:
+ time: 5
+ demand_circuit:
+ enable: true
+ ignore: true
+ network:
+ broadcast: true
+ priority: 25
+ process:
+ area_id: "30"
+ id: 10
+ resync_timeout: 10
+ shutdown: true
+ ttl_security:
+ hops: 50
+ set: true
+ - adjacency: true
+ afi: ipv6
+ database_filter: true
+ priority: 55
+ transmit_delay: 45
+ name: GigabitEthernet2
+ - address_family:
+ - adjacency: true
+ afi: ipv6
+ priority: 20
+ transmit_delay: 30
+ name: GigabitEthernet3
+ - name: GigabitEthernet4
+
+overridden:
+ commands:
+ - interface GigabitEthernet2
+ - no ip ospf 10 area 30
+ - no ip ospf adjacency stagger disable
+ - no ip ospf bfd
+ - no ip ospf cost 5
+ - no ip ospf dead-interval 5
+ - no ip ospf demand-circuit ignore
+ - no ip ospf network broadcast
+ - no ip ospf priority 25
+ - no ip ospf resync-timeout 10
+ - no ip ospf shutdown
+ - no ip ospf ttl-security hops 50
+ - no ipv6 ospf database-filter all out
+ - ipv6 ospf priority 20
+ - ipv6 ospf transmit-delay 30
+ - interface GigabitEthernet3
+ - ip ospf 10 area 20
+ - ip ospf adjacency stagger disable
+ - ip ospf cost 30
+ - ip ospf priority 40
+ - ip ospf ttl-security hops 50
+ after:
+ - name: Loopback888
+ - name: Loopback999
+ - name: GigabitEthernet1
+ - address_family:
+ - adjacency: true
+ afi: ipv6
+ priority: 20
+ transmit_delay: 30
+ name: GigabitEthernet2
+ - address_family:
+ - adjacency: true
+ afi: ipv4
+ cost:
+ interface_cost: 30
+ priority: 40
+ process:
+ area_id: "20"
+ id: 10
+ ttl_security:
+ hops: 50
+ set: true
+ name: GigabitEthernet3
+ - name: GigabitEthernet4
+
+deleted:
+ commands:
+ - interface GigabitEthernet2
+ - no ip ospf 10 area 30
+ - no ip ospf adjacency stagger disable
+ - no ip ospf bfd
+ - no ip ospf cost 5
+ - no ip ospf dead-interval 5
+ - no ip ospf demand-circuit ignore
+ - no ip ospf network broadcast
+ - no ip ospf priority 25
+ - no ip ospf resync-timeout 10
+ - no ip ospf shutdown
+ - no ip ospf ttl-security hops 50
+ - no ipv6 ospf adjacency stagger disable
+ - no ipv6 ospf database-filter all out
+ - no ipv6 ospf priority 55
+ - no ipv6 ospf transmit-delay 45
+ after: {}
+
+gathered:
+ config:
+ - name: Loopback888
+ - name: Loopback999
+ - name: GigabitEthernet1
+ - address_family:
+ - adjacency: true
+ afi: ipv4
+ bfd: true
+ cost:
+ interface_cost: 5
+ dead_interval:
+ time: 5
+ demand_circuit:
+ enable: true
+ ignore: true
+ network:
+ broadcast: true
+ priority: 25
+ process:
+ area_id: "30"
+ id: 10
+ resync_timeout: 10
+ shutdown: true
+ ttl_security:
+ hops: 50
+ set: true
+ - adjacency: true
+ afi: ipv6
+ database_filter: true
+ priority: 55
+ transmit_delay: 45
+ name: GigabitEthernet2
+ - name: GigabitEthernet3
+ - name: GigabitEthernet4
+
+rtt:
+ commands:
+ - interface GigabitEthernet3
+ - no ip ospf 10 area 20
+ - no ip ospf adjacency stagger disable
+ - no ip ospf cost 30
+ - no ip ospf priority 40
+ - no ip ospf ttl-security hops 50
+ - interface GigabitEthernet2
+ - ip ospf 10 area 30
+ - ip ospf adjacency stagger disable
+ - ip ospf bfd
+ - ip ospf cost 5
+ - ip ospf dead-interval 5
+ - ip ospf demand-circuit ignore
+ - ip ospf network broadcast
+ - ip ospf priority 25
+ - ip ospf resync-timeout 10
+ - ip ospf shutdown
+ - ip ospf ttl-security hops 50
+ - ipv6 ospf database-filter all out
+ - ipv6 ospf priority 55
+ - ipv6 ospf transmit-delay 45
+
+parsed:
+ config:
+ - name: Loopback888
+ - name: Loopback999
+ - name: GigabitEthernet1
+ - address_family:
+ - adjacency: true
+ afi: ipv4
+ authentication:
+ message_digest: true
+ bfd: true
+ cost:
+ interface_cost: 5
+ dead_interval:
+ time: 5
+ demand_circuit:
+ enable: true
+ ignore: true
+ network:
+ broadcast: true
+ priority: 25
+ process:
+ area_id: "30"
+ id: 10
+ resync_timeout: 10
+ shutdown: true
+ ttl_security:
+ hops: 50
+ set: true
+ - adjacency: true
+ afi: ipv6
+ database_filter: true
+ manet:
+ link_metrics:
+ cost_threshold: 10
+ priority: 55
+ transmit_delay: 45
+ name: GigabitEthernet2
+ - name: GigabitEthernet3
+
+rendered:
+ commands:
+ - interface GigabitEthernet2
+ - ip ospf 10 area 30
+ - ip ospf adjacency stagger disable
+ - ip ospf bfd
+ - ip ospf cost 5
+ - ip ospf dead-interval 5
+ - ip ospf demand-circuit ignore
+ - ip ospf network broadcast
+ - ip ospf priority 25
+ - ip ospf resync-timeout 10
+ - ip ospf shutdown
+ - ip ospf ttl-security hops 50
+ - ipv6 ospf adjacency stagger disable
+ - ipv6 ospf database-filter all out
+ - ipv6 ospf priority 55
+ - ipv6 ospf transmit-delay 45
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/defaults/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/defaults/main.yaml
new file mode 100644
index 000000000..164afead2
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/meta/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/meta/main.yaml
new file mode 100644
index 000000000..23d65c7ef
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/meta/main.yaml
@@ -0,0 +1,2 @@
+---
+dependencies: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tasks/cli.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tasks/cli.yaml
new file mode 100644
index 000000000..6f505600c
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tasks/cli.yaml
@@ -0,0 +1,21 @@
+---
+- name: Collect all CLI test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+ delegate_to: localhost
+
+- name: Run test case (connection=ansible.netcommon.network_cli)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.network_cli
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tasks/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tasks/main.yaml
new file mode 100644
index 000000000..80ab652fa
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tasks/main.yaml
@@ -0,0 +1,5 @@
+---
+- name: Main task for ospfv2 module
+ ansible.builtin.include_tasks: cli.yaml
+ tags:
+ - network_cli
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/_initial_vrf_setup.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/_initial_vrf_setup.yaml
new file mode 100644
index 000000000..9c2298d9c
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/_initial_vrf_setup.yaml
@@ -0,0 +1,6 @@
+---
+- name: Create and setup VRF configuration
+ vars:
+ lines: "vrf definition ospf_vrf\naddress-family ipv4\nvrf definition blue\naddress-family ipv4\n"
+ ansible.netcommon.cli_config:
+ config: "{{ lines }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/_parsed.cfg b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/_parsed.cfg
new file mode 100644
index 000000000..c3b4affb1
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/_parsed.cfg
@@ -0,0 +1,19 @@
+router ospf 200 vrf blue
+ auto-cost reference-bandwidth 4
+ distribute-list 10 out
+ distribute-list 123 in
+ domain-id 192.0.3.1
+ max-metric router-lsa on-startup 100
+ area 10 capability default-exclusion
+router ospf 1
+ default-information originate
+ max-metric router-lsa on-startup 110
+ network 198.51.100.0 0.0.0.255 area 5
+ area 10 authentication message-digest
+ area 10 default-cost 10
+ area 10 nssa translate type7 suppress-fa
+ area 10 nssa default-information-originate metric 10
+ area 10 filter-list prefix test_prefix_in in
+ area 10 filter-list prefix test_prefix_out out
+ area 5 authentication
+ area 5 capability default-exclusion
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/_populate_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/_populate_config.yaml
new file mode 100644
index 000000000..5f69c91a9
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/_populate_config.yaml
@@ -0,0 +1,55 @@
+---
+- name: Populate OSPF configuration
+ cisco.ios.ios_ospfv2:
+ config:
+ processes:
+ - process_id: 1
+ max_metric:
+ router_lsa: true
+ on_startup:
+ time: 110
+ areas:
+ - area_id: "5"
+ capability: true
+ authentication:
+ enable: true
+ - area_id: "10"
+ authentication:
+ message_digest: true
+ nssa:
+ default_information_originate:
+ metric: 10
+ translate: suppress-fa
+ default_cost: 10
+ filter_list:
+ - name: test_prefix_in
+ direction: in
+ - name: test_prefix_out
+ direction: out
+ network:
+ - address: 198.51.100.0
+ wildcard_bits: 0.0.0.255
+ area: 5
+ default_information:
+ originate: true
+ - process_id: 200
+ vrf: blue
+ domain_id:
+ ip_address:
+ address: 192.0.3.1
+ max_metric:
+ router_lsa: true
+ on_startup:
+ time: 100
+ auto_cost:
+ reference_bandwidth: 4
+ areas:
+ - area_id: "10"
+ capability: true
+ distribute_list:
+ acls:
+ - name: 10
+ direction: out
+ - name: 123
+ direction: in
+ state: merged
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/_remove_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/_remove_config.yaml
new file mode 100644
index 000000000..24db56f22
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/_remove_config.yaml
@@ -0,0 +1,10 @@
+---
+- name: Remove ospfv2 configuration
+ cisco.ios.ios_ospfv2:
+ state: deleted
+
+- name: Delete and clean VRF configuration
+ vars:
+ lines: "no vrf definition ospf_vrf\nno vrf definition blue\n"
+ ansible.netcommon.cli_config:
+ config: "{{ lines }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/deleted.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/deleted.yaml
new file mode 100644
index 000000000..e6cea01ef
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/deleted.yaml
@@ -0,0 +1,74 @@
+---
+- ansible.builtin.debug:
+ msg: Start Deleted integration state for ios_ospfv2 ansible_connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+- ansible.builtin.include_tasks: _initial_vrf_setup.yaml
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Delete provided OSPF v2 processes
+ register: result
+ cisco.ios.ios_ospfv2: &id001
+ config:
+ processes:
+ - process_id: 1
+ - process_id: 200
+ vrf: blue
+ state: deleted
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ deleted['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['after']['processes'] | symmetric_difference(result['before']['processes']) | length == 0 }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ result['after'] == {} }}"
+
+ - name: Delete provided OSPF v2 processes (idempotent)
+ register: result
+ cisco.ios.ios_ospfv2: *id001
+ - name: Assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+ - ansible.builtin.include_tasks: _populate_config.yaml
+
+ - name: Delete provided OSPF v2 processes without any configuration
+ register: result
+ cisco.ios.ios_ospfv2: &id002
+ state: deleted
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ deleted['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['after']['processes'] | symmetric_difference(result['before']['processes']) | length == 0 }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ result['after'] == {} }}"
+
+ - name: Delete provided OSPF v2 processes without any configuration (idempotent)
+ register: result
+ cisco.ios.ios_ospfv2: *id002
+ - name: Assert that the merge task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/empty_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/empty_config.yaml
new file mode 100644
index 000000000..12fad629d
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/empty_config.yaml
@@ -0,0 +1,58 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_ospfv2 empty_config.yaml integration tests on connection={{ ansible_connection }}
+
+- name: Merged with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_ospfv2:
+ config:
+ state: merged
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state merged'
+
+- name: Replaced with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_ospfv2:
+ config:
+ state: replaced
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state replaced'
+
+- name: Overridden with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_ospfv2:
+ config:
+ state: overridden
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state overridden'
+
+- name: Rendered with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_ospfv2:
+ config:
+ state: rendered
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state rendered'
+
+- name: Parsed with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_ospfv2:
+ running_config:
+ state: parsed
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of running_config parameter must not be empty for state parsed'
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/gathered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/gathered.yaml
new file mode 100644
index 000000000..91d4afa4b
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/gathered.yaml
@@ -0,0 +1,23 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_ospfv2 gathered integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+- ansible.builtin.include_tasks: _initial_vrf_setup.yaml
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Gather the provided configuration with the existing running configuration
+ register: result
+ cisco.ios.ios_ospfv2:
+ config:
+ state: gathered
+
+ - name: Assert
+ ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - "{{ merged['after']['processes'] | symmetric_difference(result['gathered']['processes']) |length == 0 }}"
+
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/merged.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/merged.yaml
new file mode 100644
index 000000000..439a1ff5f
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/merged.yaml
@@ -0,0 +1,88 @@
+---
+- ansible.builtin.debug:
+ msg: START Merged ios_ospfv2 state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+- ansible.builtin.include_tasks: _initial_vrf_setup.yaml
+
+- block:
+ - name: Merge provided configuration with device configuration
+ register: result
+ cisco.ios.ios_ospfv2: &id001
+ config:
+ processes:
+ - process_id: 1
+ max_metric:
+ router_lsa: true
+ on_startup:
+ time: 110
+ areas:
+ - area_id: "5"
+ capability: true
+ authentication:
+ enable: true
+ - area_id: "10"
+ authentication:
+ message_digest: true
+ nssa:
+ default_information_originate:
+ metric: 10
+ translate: suppress-fa
+ default_cost: 10
+ filter_list:
+ - name: test_prefix_in
+ direction: in
+ - name: test_prefix_out
+ direction: out
+ network:
+ - address: 198.51.100.0
+ wildcard_bits: 0.0.0.255
+ area: 5
+ default_information:
+ originate: true
+ - process_id: 200
+ vrf: blue
+ domain_id:
+ ip_address:
+ address: 192.0.3.1
+ max_metric:
+ router_lsa: true
+ on_startup:
+ time: 100
+ auto_cost:
+ reference_bandwidth: 4
+ areas:
+ - area_id: "10"
+ capability: true
+ distribute_list:
+ acls:
+ - name: 10
+ direction: out
+ - name: 123
+ direction: in
+ state: merged
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['before'] == {} }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['after']['processes'] | symmetric_difference(result['after']['processes']) | length == 0 }}"
+
+ - name: Merge provided configuration with device configuration (idempotent)
+ register: result
+ cisco.ios.ios_ospfv2: *id001
+ - name: Assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/overridden.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/overridden.yaml
new file mode 100644
index 000000000..b6c739efc
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/overridden.yaml
@@ -0,0 +1,72 @@
+---
+- ansible.builtin.debug:
+ msg: START Overridden ios_ospfv2 state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+- ansible.builtin.include_tasks: _initial_vrf_setup.yaml
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Override provided OSPF v2 configuration
+ register: result
+ cisco.ios.ios_ospfv2: &id001
+ config:
+ processes:
+ - process_id: 200
+ vrf: blue
+ domain_id:
+ ip_address:
+ address: 192.0.4.1
+ max_metric:
+ router_lsa: true
+ on_startup:
+ time: 200
+ maximum_paths: 15
+ ttl_security:
+ hops: 7
+ areas:
+ - area_id: "10"
+ default_cost: 10
+ authentication:
+ message_digest: true
+ - process_id: 100
+ vrf: ospf_vrf
+ domain_id:
+ ip_address:
+ address: 192.0.5.1
+ auto_cost:
+ reference_bandwidth: 5
+ areas:
+ - area_id: "5"
+ authentication:
+ message_digest: true
+ nssa:
+ default_information_originate:
+ metric: 10
+ translate: suppress-fa
+ state: overridden
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ overridden['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['after']['processes'] | symmetric_difference(result['before']['processes']) | length == 0 }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ overridden['after']['processes'] | symmetric_difference(result['after']['processes']) | length == 0 }}"
+
+ - name: Override provided OSPF v2 configuration (idempotent)
+ register: result
+ cisco.ios.ios_ospfv2: *id001
+ - name: Assert that task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/parsed.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/parsed.yaml
new file mode 100644
index 000000000..4a77a6453
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/parsed.yaml
@@ -0,0 +1,14 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_ospfv2 parsed integration tests on connection={{ ansible_connection }}
+
+- name: Parse the commands for provided configuration
+ register: result
+ cisco.ios.ios_ospfv2:
+ running_config: "{{ lookup('file', '_parsed.cfg') }}"
+ state: parsed
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - "{{ merged['after']['processes'] | symmetric_difference(result['parsed']['processes']) |length == 0 }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/rendered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/rendered.yaml
new file mode 100644
index 000000000..03f6a3656
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/rendered.yaml
@@ -0,0 +1,65 @@
+---
+- ansible.builtin.debug:
+ msg: Start ios_ospfv2 rendered integration tests ansible_connection={{ ansible_connection }}
+
+- block:
+ - name: Render the commands for provided configuration
+ register: result
+ cisco.ios.ios_ospfv2:
+ config:
+ processes:
+ - process_id: 1
+ max_metric:
+ router_lsa: true
+ on_startup:
+ time: 110
+ areas:
+ - area_id: "5"
+ capability: true
+ authentication:
+ enable: true
+ - area_id: "10"
+ authentication:
+ message_digest: true
+ nssa:
+ default_information_originate:
+ metric: 10
+ translate: suppress-fa
+ default_cost: 10
+ filter_list:
+ - name: test_prefix_in
+ direction: in
+ - name: test_prefix_out
+ direction: out
+ network:
+ - address: 198.51.100.0
+ wildcard_bits: 0.0.0.255
+ area: 5
+ default_information:
+ originate: true
+ - process_id: 200
+ vrf: blue
+ domain_id:
+ ip_address:
+ address: 192.0.3.1
+ max_metric:
+ router_lsa: true
+ on_startup:
+ time: 100
+ auto_cost:
+ reference_bandwidth: 4
+ areas:
+ - area_id: "10"
+ capability: true
+ distribute_list:
+ acls:
+ - name: 10
+ direction: out
+ - name: 123
+ direction: in
+ state: rendered
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - result.rendered|symmetric_difference(merged.commands) == []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/replaced.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/replaced.yaml
new file mode 100644
index 000000000..b1bdade55
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/replaced.yaml
@@ -0,0 +1,72 @@
+---
+- ansible.builtin.debug:
+ msg: START Replaced ios_ospfv2 state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+- ansible.builtin.include_tasks: _initial_vrf_setup.yaml
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Replaced provided OSPF v2 configuration
+ register: result
+ cisco.ios.ios_ospfv2: &id001
+ config:
+ processes:
+ - process_id: 200
+ vrf: blue
+ domain_id:
+ ip_address:
+ address: 192.0.4.1
+ max_metric:
+ router_lsa: true
+ on_startup:
+ time: 200
+ maximum_paths: 15
+ ttl_security:
+ hops: 7
+ areas:
+ - area_id: "10"
+ default_cost: 10
+ authentication:
+ message_digest: true
+ - process_id: 100
+ vrf: ospf_vrf
+ domain_id:
+ ip_address:
+ address: 192.0.5.1
+ auto_cost:
+ reference_bandwidth: 5
+ areas:
+ - area_id: "5"
+ authentication:
+ message_digest: true
+ nssa:
+ default_information_originate:
+ metric: 10
+ translate: suppress-fa
+ state: replaced
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ replaced['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['after']['processes'] | symmetric_difference(result['before']['processes']) | length == 0 }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ replaced['after']['processes'] | symmetric_difference(result['after']['processes']) | length == 0 }}"
+
+ - name: Replaced provided OSPF v2 configuration (idempotent)
+ register: result
+ cisco.ios.ios_ospfv2: *id001
+ - name: Assert that task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/rtt.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/rtt.yaml
new file mode 100644
index 000000000..b87da54b9
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/rtt.yaml
@@ -0,0 +1,130 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_ospfv2 round trip integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+- ansible.builtin.include_tasks: _initial_vrf_setup.yaml
+
+- block:
+ - name: Apply the provided configuration (base config)
+ register: base_config
+ cisco.ios.ios_ospfv2:
+ config:
+ processes:
+ - process_id: 1
+ max_metric:
+ router_lsa: true
+ on_startup:
+ time: 110
+ areas:
+ - area_id: "5"
+ capability: true
+ authentication:
+ enable: true
+ - area_id: "10"
+ authentication:
+ message_digest: true
+ nssa:
+ default_information_originate:
+ metric: 10
+ translate: suppress-fa
+ default_cost: 10
+ filter_list:
+ - name: test_prefix_in
+ direction: in
+ - name: test_prefix_out
+ direction: out
+ network:
+ - address: 198.51.100.0
+ wildcard_bits: 0.0.0.255
+ area: 5
+ default_information:
+ originate: true
+ - process_id: 200
+ vrf: blue
+ domain_id:
+ ip_address:
+ address: 192.0.3.1
+ max_metric:
+ router_lsa: true
+ on_startup:
+ time: 100
+ auto_cost:
+ reference_bandwidth: 4
+ areas:
+ - area_id: "10"
+ capability: true
+ distribute_list:
+ acls:
+ - name: 10
+ direction: out
+ - name: 123
+ direction: in
+ state: merged
+
+ - name: Gather ospfv2 facts
+ cisco.ios.ios_facts:
+ gather_subset:
+ - "!all"
+ - "!min"
+ gather_network_resources:
+ - ospfv2
+
+ - name: Apply the provided configuration (config to be reverted)
+ register: result
+ cisco.ios.ios_ospfv2:
+ config:
+ processes:
+ - process_id: 200
+ vrf: blue
+ domain_id:
+ ip_address:
+ address: 192.0.4.1
+ max_metric:
+ router_lsa: true
+ on_startup:
+ time: 200
+ maximum_paths: 15
+ ttl_security:
+ hops: 7
+ areas:
+ - area_id: "10"
+ default_cost: 10
+ authentication:
+ message_digest: true
+ - process_id: 100
+ vrf: ospf_vrf
+ domain_id:
+ ip_address:
+ address: 192.0.5.1
+ auto_cost:
+ reference_bandwidth: 5
+ areas:
+ - area_id: "5"
+ authentication:
+ message_digest: true
+ nssa:
+ default_information_originate:
+ metric: 10
+ translate: suppress-fa
+ state: overridden
+
+ - ansible.builtin.assert:
+ that:
+ - result.commands|length == 18
+ - result.changed == true
+ - result.commands|symmetric_difference(overridden.commands) == []
+
+ - name: Revert back to base configuration using facts round trip
+ register: revert
+ cisco.ios.ios_ospfv2:
+ config: "{{ ansible_facts['network_resources']['ospfv2'] }}"
+ state: overridden
+
+ - ansible.builtin.assert:
+ that:
+ - revert.commands|length == 24
+ - revert.changed == true
+ - revert.commands|symmetric_difference(rtt.commands) == []
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/vars/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/vars/main.yaml
new file mode 100644
index 000000000..307b591e2
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/vars/main.yaml
@@ -0,0 +1,250 @@
+---
+merged:
+ before: {}
+
+ commands:
+ - router ospf 200 vrf blue
+ - auto-cost reference-bandwidth 4
+ - distribute-list 10 out
+ - distribute-list 123 in
+ - domain-id 192.0.3.1
+ - max-metric router-lsa on-startup 100
+ - area 10 capability default-exclusion
+ - router ospf 1
+ - default-information originate
+ - max-metric router-lsa on-startup 110
+ - network 198.51.100.0 0.0.0.255 area 5
+ - area 10 authentication message-digest
+ - area 10 default-cost 10
+ - area 10 nssa translate type7 suppress-fa
+ - area 10 nssa default-information-originate metric 10
+ - area 10 filter-list prefix test_prefix_out out
+ - area 10 filter-list prefix test_prefix_in in
+ - area 5 authentication
+ - area 5 capability default-exclusion
+
+ after:
+ processes:
+ - areas:
+ - area_id: "5"
+ authentication:
+ enable: true
+ capability: true
+ - area_id: "10"
+ authentication:
+ message_digest: true
+ default_cost: 10
+ filter_list:
+ - direction: in
+ name: test_prefix_in
+ - direction: out
+ name: test_prefix_out
+ nssa:
+ default_information_originate:
+ metric: 10
+ translate: suppress-fa
+ default_information:
+ originate: true
+ max_metric:
+ on_startup:
+ time: 110
+ router_lsa: true
+ network:
+ - address: 198.51.100.0
+ area: "5"
+ wildcard_bits: 0.0.0.255
+ process_id: 1
+ - areas:
+ - area_id: "10"
+ capability: true
+ auto_cost:
+ reference_bandwidth: 4
+ distribute_list:
+ acls:
+ - direction: out
+ name: "10"
+ - direction: in
+ name: "123"
+ domain_id:
+ ip_address:
+ address: 192.0.3.1
+ max_metric:
+ on_startup:
+ time: 100
+ router_lsa: true
+ process_id: 200
+ vrf: blue
+
+replaced:
+ commands:
+ - router ospf 100 vrf ospf_vrf
+ - auto-cost reference-bandwidth 5
+ - domain-id 192.0.5.1
+ - area 5 authentication message-digest
+ - area 5 nssa translate type7 suppress-fa
+ - area 5 nssa default-information-originate metric 10
+ - router ospf 200 vrf blue
+ - no auto-cost reference-bandwidth 4
+ - no distribute-list 10 out
+ - no distribute-list 123 in
+ - domain-id 192.0.4.1
+ - max-metric router-lsa on-startup 200
+ - maximum-paths 15
+ - ttl-security all-interfaces hops 7
+ - area 10 authentication message-digest
+ - no area 10 capability default-exclusion
+ - area 10 default-cost 10
+
+ after:
+ processes:
+ - areas:
+ - area_id: "5"
+ authentication:
+ enable: true
+ capability: true
+ - area_id: "10"
+ authentication:
+ message_digest: true
+ default_cost: 10
+ filter_list:
+ - direction: in
+ name: test_prefix_in
+ - direction: out
+ name: test_prefix_out
+ nssa:
+ default_information_originate:
+ metric: 10
+ translate: suppress-fa
+ default_information:
+ originate: true
+ max_metric:
+ on_startup:
+ time: 110
+ router_lsa: true
+ network:
+ - address: 198.51.100.0
+ area: "5"
+ wildcard_bits: 0.0.0.255
+ process_id: 1
+ - areas:
+ - area_id: "5"
+ authentication:
+ message_digest: true
+ nssa:
+ default_information_originate:
+ metric: 10
+ translate: suppress-fa
+ auto_cost:
+ reference_bandwidth: 5
+ domain_id:
+ ip_address:
+ address: 192.0.5.1
+ process_id: 100
+ vrf: ospf_vrf
+ - areas:
+ - area_id: "10"
+ authentication:
+ message_digest: true
+ default_cost: 10
+ domain_id:
+ ip_address:
+ address: 192.0.4.1
+ max_metric:
+ on_startup:
+ time: 200
+ router_lsa: true
+ maximum_paths: 15
+ process_id: 200
+ ttl_security:
+ hops: 7
+ vrf: blue
+
+overridden:
+ commands:
+ - no router ospf 1
+ - router ospf 100 vrf ospf_vrf
+ - auto-cost reference-bandwidth 5
+ - domain-id 192.0.5.1
+ - area 5 authentication message-digest
+ - area 5 nssa translate type7 suppress-fa
+ - area 5 nssa default-information-originate metric 10
+ - router ospf 200 vrf blue
+ - no auto-cost reference-bandwidth 4
+ - no distribute-list 10 out
+ - no distribute-list 123 in
+ - domain-id 192.0.4.1
+ - max-metric router-lsa on-startup 200
+ - maximum-paths 15
+ - ttl-security all-interfaces hops 7
+ - area 10 authentication message-digest
+ - no area 10 capability default-exclusion
+ - area 10 default-cost 10
+
+ after:
+ processes:
+ - areas:
+ - area_id: "5"
+ authentication:
+ message_digest: true
+ nssa:
+ default_information_originate:
+ metric: 10
+ translate: suppress-fa
+ auto_cost:
+ reference_bandwidth: 5
+ domain_id:
+ ip_address:
+ address: 192.0.5.1
+ process_id: 100
+ vrf: ospf_vrf
+ - areas:
+ - area_id: "10"
+ authentication:
+ message_digest: true
+ default_cost: 10
+ domain_id:
+ ip_address:
+ address: 192.0.4.1
+ max_metric:
+ on_startup:
+ time: 200
+ router_lsa: true
+ maximum_paths: 15
+ process_id: 200
+ ttl_security:
+ hops: 7
+ vrf: blue
+
+deleted:
+ commands:
+ - no router ospf 200 vrf blue
+ - no router ospf 1
+
+ after: {}
+
+rtt:
+ commands:
+ - no router ospf 100 vrf ospf_vrf
+ - router ospf 200 vrf blue
+ - auto-cost reference-bandwidth 4
+ - distribute-list 10 out
+ - distribute-list 123 in
+ - domain-id 192.0.3.1
+ - max-metric router-lsa on-startup 100
+ - no maximum-paths 15
+ - no ttl-security all-interfaces hops 7
+ - no area 10 authentication message-digest
+ - area 10 capability default-exclusion
+ - no area 10 default-cost 10
+ - router ospf 1
+ - default-information originate
+ - max-metric router-lsa on-startup 110
+ - network 198.51.100.0 0.0.0.255 area 5
+ - area 10 authentication message-digest
+ - area 10 default-cost 10
+ - area 10 nssa translate type7 suppress-fa
+ - area 10 nssa default-information-originate metric 10
+ - area 10 filter-list prefix test_prefix_out out
+ - area 10 filter-list prefix test_prefix_in in
+ - area 5 authentication
+ - area 5 capability default-exclusion
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/defaults/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/defaults/main.yaml
new file mode 100644
index 000000000..164afead2
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/meta/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/meta/main.yaml
new file mode 100644
index 000000000..23d65c7ef
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/meta/main.yaml
@@ -0,0 +1,2 @@
+---
+dependencies: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tasks/cli.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tasks/cli.yaml
new file mode 100644
index 000000000..6f505600c
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tasks/cli.yaml
@@ -0,0 +1,21 @@
+---
+- name: Collect all CLI test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+ delegate_to: localhost
+
+- name: Run test case (connection=ansible.netcommon.network_cli)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.network_cli
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tasks/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tasks/main.yaml
new file mode 100644
index 000000000..b435443c3
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tasks/main.yaml
@@ -0,0 +1,5 @@
+---
+- name: Main task for ospfv3 module
+ ansible.builtin.include_tasks: cli.yaml
+ tags:
+ - network_cli
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/_initial_vrf_setup.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/_initial_vrf_setup.yaml
new file mode 100644
index 000000000..0bfbb55fd
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/_initial_vrf_setup.yaml
@@ -0,0 +1,11 @@
+---
+- name: Enable ipv6 routing configuration
+ vars:
+ lines: "ipv6 unicast-routing\n"
+ ansible.netcommon.cli_config:
+ config: "{{ lines }}"
+- name: Create and setup VRF configuration
+ vars:
+ lines: "vrf definition ospf_vrf\naddress-family ipv4\n"
+ ansible.netcommon.cli_config:
+ config: "{{ lines }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/_parsed.cfg b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/_parsed.cfg
new file mode 100644
index 000000000..2c504a6ac
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/_parsed.cfg
@@ -0,0 +1,15 @@
+router ospfv3 1
+ max-metric router-lsa on-startup 110
+ area 10 nssa default-information-originate metric 10
+ !
+ address-family ipv4 unicast vrf ospf_vrf
+ adjacency stagger 25 25
+ area 25 nssa default-information-originate metric 25 nssa-only
+ exit-address-family
+router ospfv3 200
+ max-metric router-lsa on-startup 100
+ auto-cost reference-bandwidth 4
+ !
+ address-family ipv4 unicast
+ adjacency stagger 200 200
+ exit-address-family
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/_populate_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/_populate_config.yaml
new file mode 100644
index 000000000..ffc6a1999
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/_populate_config.yaml
@@ -0,0 +1,42 @@
+---
+- name: Populate ospfv3 configuration
+ cisco.ios.ios_ospfv3:
+ config:
+ processes:
+ - process_id: 1
+ max_metric:
+ router_lsa: true
+ on_startup:
+ time: 110
+ address_family:
+ - afi: ipv4
+ unicast: true
+ vrf: ospf_vrf
+ adjacency:
+ min_adjacency: 25
+ max_adjacency: 25
+ areas:
+ - area_id: 25
+ nssa:
+ default_information_originate:
+ metric: 25
+ nssa_only: true
+ areas:
+ - area_id: "10"
+ nssa:
+ default_information_originate:
+ metric: 10
+ - process_id: 200
+ address_family:
+ - afi: ipv4
+ unicast: true
+ adjacency:
+ min_adjacency: 200
+ max_adjacency: 200
+ max_metric:
+ router_lsa: true
+ on_startup:
+ time: 100
+ auto_cost:
+ reference_bandwidth: 4
+ state: merged
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/_remove_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/_remove_config.yaml
new file mode 100644
index 000000000..8deccb16a
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/_remove_config.yaml
@@ -0,0 +1,16 @@
+---
+- name: Remove ospfv3 configuration
+ cisco.ios.ios_ospfv3:
+ state: deleted
+
+- name: Delete and clean ipv6 routings configuration
+ vars:
+ lines: "no ipv6 unicast-routing\n"
+ ansible.netcommon.cli_config:
+ config: "{{ lines }}"
+
+- name: Delete and clean VRF configuration
+ vars:
+ lines: "no vrf definition ospf_vrf\nno vrf definition blue\n"
+ ansible.netcommon.cli_config:
+ config: "{{ lines }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/deleted.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/deleted.yaml
new file mode 100644
index 000000000..ead239a5b
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/deleted.yaml
@@ -0,0 +1,62 @@
+---
+- ansible.builtin.debug:
+ msg: Start Deleted integration state for ios_ospfv3 ansible_connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+- ansible.builtin.include_tasks: _initial_vrf_setup.yaml
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Delete provided OSPF v3 processes
+ register: result
+ cisco.ios.ios_ospfv3: &id001
+ config:
+ processes:
+ - process_id: 1
+ - process_id: 200
+ state: deleted
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ deleted['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ result['after'] == {} }}"
+
+ - name: Delete provided OSPF v3 processes (idempotent)
+ register: result
+ cisco.ios.ios_ospfv3: *id001
+ - name: Assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+ - ansible.builtin.include_tasks: _populate_config.yaml
+
+ - name: Delete provided OSPF v3 processes without any configuration
+ register: result
+ cisco.ios.ios_ospfv3: &id002
+ state: deleted
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ deleted['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ result['after'] == {} }}"
+
+ - name: Delete provided OSPF v3 processes without any configuration (idempotent)
+ register: result
+ cisco.ios.ios_ospfv3: *id002
+ - name: Assert that the merge task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result.changed == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/empty_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/empty_config.yaml
new file mode 100644
index 000000000..11f1f570c
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/empty_config.yaml
@@ -0,0 +1,59 @@
+---
+- block:
+ - ansible.builtin.debug:
+ msg: START ios_ospfv3 empty_config.yaml integration tests on connection={{ ansible_connection }}
+
+ - name: Merged with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_ospfv3:
+ config:
+ state: merged
+
+ - ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state merged'
+
+ - name: Replaced with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_ospfv3:
+ config:
+ state: replaced
+
+ - ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state replaced'
+
+ - name: Overridden with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_ospfv3:
+ config:
+ state: overridden
+
+ - ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state overridden'
+
+ - name: Rendered with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_ospfv3:
+ config:
+ state: rendered
+
+ - ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state rendered'
+
+ - name: Parsed with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_ospfv3:
+ running_config:
+ state: parsed
+
+ - ansible.builtin.assert:
+ that:
+ - result.msg == 'value of running_config parameter must not be empty for state parsed'
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/gathered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/gathered.yaml
new file mode 100644
index 000000000..7e368360c
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/gathered.yaml
@@ -0,0 +1,22 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_ospfv3 gathered integration tests on connection={{ ansible_connection }}
+
+- block:
+ - ansible.builtin.include_tasks: _remove_config.yaml
+ - ansible.builtin.include_tasks: _initial_vrf_setup.yaml
+ - ansible.builtin.include_tasks: _populate_config.yaml
+
+ - name: Gather the provided configuration with the existing running configuration
+ register: result
+ cisco.ios.ios_ospfv3:
+ config:
+ state: gathered
+
+ - name: Assert
+ ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - "{{ merged['after']['processes'] | symmetric_difference(result['gathered']['processes']) |length == 0 }}"
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/merged.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/merged.yaml
new file mode 100644
index 000000000..2f1db29b7
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/merged.yaml
@@ -0,0 +1,70 @@
+---
+- ansible.builtin.debug:
+ msg: START Merged ios_ospfv3 state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+- ansible.builtin.include_tasks: _initial_vrf_setup.yaml
+
+- block:
+ - name: Merge provided configuration with device configuration
+ register: result
+ cisco.ios.ios_ospfv3: &id001
+ config:
+ processes:
+ - process_id: 1
+ max_metric:
+ router_lsa: true
+ on_startup:
+ time: 110
+ address_family:
+ - afi: ipv4
+ unicast: true
+ vrf: ospf_vrf
+ adjacency:
+ min_adjacency: 25
+ max_adjacency: 25
+ areas:
+ - area_id: 25
+ nssa:
+ default_information_originate:
+ metric: 25
+ nssa_only: true
+ areas:
+ - area_id: "10"
+ nssa:
+ default_information_originate:
+ metric: 10
+ - process_id: 200
+ address_family:
+ - afi: ipv4
+ unicast: true
+ adjacency:
+ min_adjacency: 200
+ max_adjacency: 200
+ max_metric:
+ router_lsa: true
+ on_startup:
+ time: 100
+ auto_cost:
+ reference_bandwidth: 4
+ state: merged
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['before'] == {} }}"
+
+ - name: Merge provided configuration with device configuration (idempotent)
+ register: result
+ cisco.ios.ios_ospfv3: *id001
+ - name: Assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/overridden.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/overridden.yaml
new file mode 100644
index 000000000..bdcd09fa2
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/overridden.yaml
@@ -0,0 +1,52 @@
+---
+- ansible.builtin.debug:
+ msg: START Overridden ios_ospfv3 state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+- ansible.builtin.include_tasks: _initial_vrf_setup.yaml
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Override provided OSPF v3 configuration
+ register: result
+ cisco.ios.ios_ospfv3: &id001
+ config:
+ processes:
+ - process_id: 200
+ max_metric:
+ router_lsa: true
+ on_startup:
+ time: 200
+ address_family:
+ - afi: ipv4
+ unicast: true
+ adjacency:
+ min_adjacency: 50
+ max_adjacency: 50
+ areas:
+ - area_id: 200
+ nssa:
+ default_information_originate:
+ metric: 200
+ nssa_only: true
+ areas:
+ - area_id: "10"
+ nssa:
+ default_information_originate:
+ metric: 10
+ state: overridden
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ overridden['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Override provided OSPF v3 configuration (idempotent)
+ register: result
+ cisco.ios.ios_ospfv3: *id001
+ - name: Assert that task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/parsed.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/parsed.yaml
new file mode 100644
index 000000000..b0e9755d1
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/parsed.yaml
@@ -0,0 +1,15 @@
+---
+- block:
+ - ansible.builtin.debug:
+ msg: START ios_ospfv3 parsed integration tests on connection={{ ansible_connection }}
+
+ - name: Parse the commands for provided configuration
+ register: result
+ cisco.ios.ios_ospfv3:
+ running_config: "{{ lookup('file', '_parsed.cfg') }}"
+ state: parsed
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - "{{ merged['after']['processes'] | symmetric_difference(result['parsed']['processes']) |length == 0 }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/rendered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/rendered.yaml
new file mode 100644
index 000000000..ee244383c
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/rendered.yaml
@@ -0,0 +1,52 @@
+---
+- ansible.builtin.debug:
+ msg: Start ios_ospfv3 rendered integration tests ansible_connection={{ ansible_connection }}
+
+- block:
+ - name: Render the commands for provided configuration
+ register: result
+ cisco.ios.ios_ospfv3:
+ config:
+ processes:
+ - process_id: 1
+ max_metric:
+ router_lsa: true
+ on_startup:
+ time: 110
+ address_family:
+ - afi: ipv4
+ unicast: true
+ vrf: ospf_vrf
+ adjacency:
+ min_adjacency: 25
+ max_adjacency: 25
+ areas:
+ - area_id: 25
+ nssa:
+ default_information_originate:
+ metric: 25
+ nssa_only: true
+ areas:
+ - area_id: "10"
+ nssa:
+ default_information_originate:
+ metric: 10
+ - process_id: 200
+ address_family:
+ - afi: ipv4
+ unicast: true
+ adjacency:
+ min_adjacency: 200
+ max_adjacency: 200
+ max_metric:
+ router_lsa: true
+ on_startup:
+ time: 100
+ auto_cost:
+ reference_bandwidth: 4
+ state: rendered
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - result.rendered|symmetric_difference(merged.commands) == []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/replaced.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/replaced.yaml
new file mode 100644
index 000000000..b23c9fb74
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/replaced.yaml
@@ -0,0 +1,52 @@
+---
+- ansible.builtin.debug:
+ msg: START Replaced ios_ospfv3 state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+- ansible.builtin.include_tasks: _initial_vrf_setup.yaml
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Replaced provided OSPF v3 configuration
+ register: result
+ cisco.ios.ios_ospfv3: &id001
+ config:
+ processes:
+ - process_id: 200
+ max_metric:
+ router_lsa: true
+ on_startup:
+ time: 200
+ address_family:
+ - afi: ipv4
+ unicast: true
+ adjacency:
+ min_adjacency: 50
+ max_adjacency: 50
+ areas:
+ - area_id: 200
+ nssa:
+ default_information_originate:
+ metric: 200
+ nssa_only: true
+ areas:
+ - area_id: "10"
+ nssa:
+ default_information_originate:
+ metric: 10
+ state: replaced
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ replaced['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Replaced provided OSPF v3 configuration (idempotent)
+ register: result
+ cisco.ios.ios_ospfv3: *id001
+ - name: Assert that task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/rtt.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/rtt.yaml
new file mode 100644
index 000000000..280645d1a
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/tests/cli/rtt.yaml
@@ -0,0 +1,113 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_ospfv3 round trip integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+- ansible.builtin.include_tasks: _initial_vrf_setup.yaml
+
+- block:
+ - name: Apply the provided configuration (base config)
+ register: base_config
+ cisco.ios.ios_ospfv3:
+ config:
+ processes:
+ - process_id: 1
+ max_metric:
+ router_lsa: true
+ on_startup:
+ time: 110
+ address_family:
+ - afi: ipv4
+ unicast: true
+ vrf: ospf_vrf
+ adjacency:
+ min_adjacency: 25
+ max_adjacency: 25
+ areas:
+ - area_id: 25
+ nssa:
+ default_information_originate:
+ metric: 25
+ nssa_only: true
+ areas:
+ - area_id: "10"
+ nssa:
+ default_information_originate:
+ metric: 10
+ timers:
+ throttle:
+ lsa:
+ first_delay: 12
+ min_delay: 14
+ max_delay: 16
+ - process_id: 200
+ address_family:
+ - afi: ipv4
+ unicast: true
+ adjacency:
+ min_adjacency: 200
+ max_adjacency: 200
+ max_metric:
+ router_lsa: true
+ on_startup:
+ time: 100
+ auto_cost:
+ reference_bandwidth: 4
+ state: merged
+
+ - name: Gather ospfv3 facts
+ cisco.ios.ios_facts:
+ gather_subset:
+ - "!all"
+ - "!min"
+ gather_network_resources:
+ - ospfv3
+
+ - name: Apply the provided configuration (config to be reverted)
+ register: result
+ cisco.ios.ios_ospfv3:
+ config:
+ processes:
+ - process_id: 200
+ max_metric:
+ router_lsa: true
+ on_startup:
+ time: 200
+ address_family:
+ - afi: ipv4
+ unicast: true
+ adjacency:
+ min_adjacency: 50
+ max_adjacency: 50
+ areas:
+ - area_id: 200
+ nssa:
+ default_information_originate:
+ metric: 200
+ nssa_only: true
+ areas:
+ - area_id: "10"
+ nssa:
+ default_information_originate:
+ metric: 10
+ state: overridden
+
+ - ansible.builtin.assert:
+ that:
+ - result.commands|length == 9
+ - result.changed == true
+ - result.commands|symmetric_difference(overridden.commands) == []
+
+ - name: Revert back to base configuration using facts round trip
+ register: revert
+ cisco.ios.ios_ospfv3:
+ config: "{{ ansible_facts['network_resources']['ospfv3'] }}"
+ state: overridden
+
+ - ansible.builtin.assert:
+ that:
+ - revert.commands|length == 14
+ - revert.changed == true
+ - revert.commands|symmetric_difference(rtt.commands) == []
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/vars/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/vars/main.yaml
new file mode 100644
index 000000000..1424f4591
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv3/vars/main.yaml
@@ -0,0 +1,104 @@
+---
+merged:
+ before: {}
+
+ commands:
+ - router ospfv3 1
+ - max-metric router-lsa on-startup 110
+ - area 10 nssa default-information-originate metric 10
+ - address-family ipv4 unicast vrf ospf_vrf
+ - adjacency stagger 25 25
+ - area 25 nssa default-information-originate metric 25 nssa-only
+ - exit-address-family
+ - router ospfv3 200
+ - auto-cost reference-bandwidth 4
+ - max-metric router-lsa on-startup 100
+ - address-family ipv4 unicast
+ - adjacency stagger 200 200
+ - exit-address-family
+
+ after:
+ processes:
+ - address_family:
+ - adjacency:
+ max_adjacency: 25
+ min_adjacency: 25
+ afi: ipv4
+ areas:
+ - area_id: "25"
+ nssa:
+ default_information_originate:
+ metric: 25
+ nssa_only: true
+ unicast: true
+ vrf: ospf_vrf
+ areas:
+ - area_id: "10"
+ nssa:
+ default_information_originate:
+ metric: 10
+ max_metric:
+ on_startup:
+ time: 110
+ router_lsa: true
+ process_id: 1
+ - address_family:
+ - adjacency:
+ max_adjacency: 200
+ min_adjacency: 200
+ afi: ipv4
+ unicast: true
+ auto_cost:
+ reference_bandwidth: 4
+ max_metric:
+ on_startup:
+ time: 100
+ router_lsa: true
+ process_id: 200
+
+replaced:
+ commands:
+ - router ospfv3 200
+ - no auto-cost reference-bandwidth 4
+ - max-metric router-lsa on-startup 200
+ - area 10 nssa default-information-originate metric 10
+ - address-family ipv4 unicast
+ - adjacency stagger 50 50
+ - area 200 nssa default-information-originate metric 200 nssa-only
+ - exit-address-family
+
+overridden:
+ commands:
+ - no router ospfv3 1
+ - router ospfv3 200
+ - no auto-cost reference-bandwidth 4
+ - max-metric router-lsa on-startup 200
+ - area 10 nssa default-information-originate metric 10
+ - address-family ipv4 unicast
+ - adjacency stagger 50 50
+ - area 200 nssa default-information-originate metric 200 nssa-only
+ - exit-address-family
+
+deleted:
+ commands:
+ - no router ospfv3 1
+ - no router ospfv3 200
+
+ after: {}
+
+rtt:
+ commands:
+ - router ospfv3 1
+ - max-metric router-lsa on-startup 110
+ - area 10 nssa default-information-originate metric 10
+ - address-family ipv4 unicast vrf ospf_vrf
+ - adjacency stagger 25 25
+ - area 25 nssa default-information-originate metric 25 nssa-only
+ - exit-address-family
+ - router ospfv3 200
+ - auto-cost reference-bandwidth 4
+ - max-metric router-lsa on-startup 100
+ - no area 10 nssa default-information-originate metric 10
+ - address-family ipv4 unicast
+ - exit-address-family
+ - adjacency stagger 200 200
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ping/defaults/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ping/defaults/main.yaml
new file mode 100644
index 000000000..9ef5ba516
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ping/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "*"
+test_items: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ping/meta/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ping/meta/main.yaml
new file mode 100644
index 000000000..ab3ad91bc
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ping/meta/main.yaml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - prepare_ios_tests
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ping/tasks/cli.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ping/tasks/cli.yaml
new file mode 100644
index 000000000..cd8c04990
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ping/tasks/cli.yaml
@@ -0,0 +1,18 @@
+---
+- name: Collect all CLI test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: Run test cases (connection=ansible.netcommon.network_cli)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+ tags: network_cli
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ping/tasks/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ping/tasks/main.yaml
new file mode 100644
index 000000000..90c4263c8
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ping/tasks/main.yaml
@@ -0,0 +1,3 @@
+---
+- name: Main task for ping module
+ ansible.builtin.include_tasks: cli.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ping/tests/cli/ping.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ping/tests/cli/ping.yaml
new file mode 100644
index 000000000..bc52e5ea8
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ping/tests/cli/ping.yaml
@@ -0,0 +1,51 @@
+---
+- ansible.builtin.debug: msg="START cli/ping.yaml on connection={{ ansible_connection }}"
+
+- register: show_version_result
+ cisco.ios.ios_command:
+ commands: show version
+
+- ansible.builtin.set_fact: management_interface=GigabitEthernet0/0
+ when: "'Cisco IOS' in show_version_result.stdout[0]"
+
+- ansible.builtin.set_fact: management_interface=GigabitEthernet1
+ when: "'Cisco IOS-XE' in show_version_result.stdout[0]"
+
+- name: Get show IP management interface output
+ register: show_ip_interface_result
+ cisco.ios.ios_command:
+ commands:
+ - show ip interface {{ management_interface }} | include Internet address
+
+- name: Extract the IP address from registered output
+ ansible.builtin.set_fact: management_ip="{{ show_ip_interface_result.stdout[0].split()[-1].split('/')[0] }}"
+
+- name: Expected successful ping
+ register: esp
+ cisco.ios.ios_ping:
+ dest: "{{ management_ip }}"
+
+- name: Unexpected unsuccessful ping
+ register: uup
+ ignore_errors: true
+ cisco.ios.ios_ping:
+ dest: 10.255.255.250
+
+- name: Unexpected successful ping
+ register: usp
+ ignore_errors: true
+ cisco.ios.ios_ping:
+ dest: "{{ management_ip }}"
+ state: absent
+
+- name: Expected unsuccessful ping
+ register: eup
+ cisco.ios.ios_ping:
+ dest: 10.255.255.250
+ state: absent
+
+- name: Assert
+ ansible.builtin.assert:
+ that:
+ - esp.failed == eup.failed == false
+ - usp.failed == uup.failed == true
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/defaults/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/defaults/main.yaml
new file mode 100644
index 000000000..164afead2
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/meta/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/meta/main.yaml
new file mode 100644
index 000000000..23d65c7ef
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/meta/main.yaml
@@ -0,0 +1,2 @@
+---
+dependencies: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tasks/cli.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tasks/cli.yaml
new file mode 100644
index 000000000..6f505600c
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tasks/cli.yaml
@@ -0,0 +1,21 @@
+---
+- name: Collect all CLI test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+ delegate_to: localhost
+
+- name: Run test case (connection=ansible.netcommon.network_cli)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.network_cli
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tasks/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tasks/main.yaml
new file mode 100644
index 000000000..3415fc29d
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tasks/main.yaml
@@ -0,0 +1,5 @@
+---
+- name: Main task for prefix_lists module
+ ansible.builtin.include_tasks: cli.yaml
+ tags:
+ - network_cli
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/_parsed.cfg b/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/_parsed.cfg
new file mode 100644
index 000000000..713d24499
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/_parsed.cfg
@@ -0,0 +1,12 @@
+ip prefix-list 10 description this is test description
+ip prefix-list 10 seq 5 deny 1.0.0.0/8 le 15
+ip prefix-list 10 seq 10 deny 35.0.0.0/8 ge 10
+ip prefix-list 10 seq 15 deny 12.0.0.0/8 ge 15
+ip prefix-list 10 seq 20 deny 14.0.0.0/8 ge 20 le 21
+ip prefix-list test description this is test
+ip prefix-list test seq 50 deny 12.0.0.0/8 ge 15
+ip prefix-list test_prefix description this is for prefix-list
+ip prefix-list test_prefix seq 5 deny 35.0.0.0/8 ge 10 le 15
+ip prefix-list test_prefix seq 10 deny 35.0.0.0/8 ge 20
+ipv6 prefix-list test_ipv6 description this is ipv6 prefix-list
+ipv6 prefix-list test_ipv6 seq 10 deny 2001:DB8:0:4::/64 ge 80
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/_populate_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/_populate_config.yaml
new file mode 100644
index 000000000..d7ec650c0
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/_populate_config.yaml
@@ -0,0 +1,55 @@
+---
+- name: Populate prefix lists configuration
+ cisco.ios.ios_prefix_lists:
+ config:
+ - afi: ipv4
+ prefix_lists:
+ - name: 10
+ description: this is test description
+ entries:
+ - action: deny
+ prefix: 1.0.0.0/8
+ le: 15
+ sequence: 5
+ - action: deny
+ prefix: 35.0.0.0/8
+ ge: 10
+ sequence: 10
+ - action: deny
+ prefix: 12.0.0.0/8
+ ge: 15
+ sequence: 15
+ - action: deny
+ prefix: 14.0.0.0/8
+ ge: 20
+ le: 21
+ sequence: 20
+ - name: test
+ description: this is test
+ entries:
+ - action: deny
+ prefix: 12.0.0.0/8
+ ge: 15
+ sequence: 50
+ - name: test_prefix
+ description: this is for prefix-list
+ entries:
+ - action: deny
+ prefix: 35.0.0.0/8
+ ge: 10
+ le: 15
+ sequence: 5
+ - action: deny
+ prefix: 35.0.0.0/8
+ ge: 20
+ sequence: 10
+ - afi: ipv6
+ prefix_lists:
+ - name: test_ipv6
+ description: this is ipv6 prefix-list
+ entries:
+ - action: deny
+ prefix: 2001:DB8:0:4::/64
+ ge: 80
+ sequence: 10
+ state: merged
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/_remove_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/_remove_config.yaml
new file mode 100644
index 000000000..8d0f94c76
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/_remove_config.yaml
@@ -0,0 +1,4 @@
+---
+- name: Remove all prefix lists configuration
+ cisco.ios.ios_prefix_lists:
+ state: deleted
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/deleted.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/deleted.yaml
new file mode 100644
index 000000000..bc357edc3
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/deleted.yaml
@@ -0,0 +1,78 @@
+---
+- ansible.builtin.debug:
+ msg: Start Deleted integration state for ios_prefix_lists ansible_connection={{ ansible_connection }}
+
+- block:
+ - ansible.builtin.include_tasks: _remove_config.yaml
+ - ansible.builtin.include_tasks: _populate_config.yaml
+
+ - name: Delete prefix list based on prefix name configured
+ register: result
+ cisco.ios.ios_prefix_lists: &id001
+ config:
+ - afi: ipv4
+ prefix_lists:
+ - name: 10
+ - name: test_prefix
+ state: deleted
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ deleted_name['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Delete provided prefix lists configuration (idempotent)
+ register: result
+ cisco.ios.ios_prefix_lists: *id001
+ - name: Assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+ - ansible.builtin.include_tasks: _remove_config.yaml
+ - ansible.builtin.include_tasks: _populate_config.yaml
+
+ - name: Delete prefix list based on AFI configured
+ register: result
+ cisco.ios.ios_prefix_lists: &id002
+ config:
+ - afi: ipv4
+ state: deleted
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ deleted_afi['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Delete provided prefix lists configuration (idempotent)
+ register: result
+ cisco.ios.ios_prefix_lists: *id002
+ - name: Assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+ - ansible.builtin.include_tasks: _remove_config.yaml
+ - ansible.builtin.include_tasks: _populate_config.yaml
+
+ - name: Delete all provided prefix lists configuration
+ register: result
+ cisco.ios.ios_prefix_lists: &id003
+ state: deleted
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ deleted_all['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+ - "{{ deleted_all['before'] | symmetric_difference(result['before']) | length == 0 }}"
+ - result['after'] == {}
+
+ - name: Delete all provided prefix lists configuration (idempotent)
+ register: result
+ cisco.ios.ios_prefix_lists: *id003
+ - name: Assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result.changed == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/empty_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/empty_config.yaml
new file mode 100644
index 000000000..be198c71c
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/empty_config.yaml
@@ -0,0 +1,58 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_prefix_lists empty_config.yaml integration tests on connection={{ ansible_connection }}
+
+- name: Merged with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_prefix_lists:
+ config:
+ state: merged
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state merged'
+
+- name: Replaced with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_prefix_lists:
+ config:
+ state: replaced
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state replaced'
+
+- name: Overridden with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_prefix_lists:
+ config:
+ state: overridden
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state overridden'
+
+- name: Rendered with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_prefix_lists:
+ config:
+ state: rendered
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state rendered'
+
+- name: Parsed with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_prefix_lists:
+ running_config:
+ state: parsed
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of running_config parameter must not be empty for state parsed'
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/gathered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/gathered.yaml
new file mode 100644
index 000000000..1d16c3289
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/gathered.yaml
@@ -0,0 +1,21 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_prefix_lists gathered integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Gather the provided configuration with the existing running configuration
+ register: result
+ cisco.ios.ios_prefix_lists:
+ config:
+ state: gathered
+
+ - name: Assert
+ ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - "{{ merged['after'] | symmetric_difference(result['gathered']) |length == 0 }}"
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/merged.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/merged.yaml
new file mode 100644
index 000000000..4c8d4d528
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/merged.yaml
@@ -0,0 +1,86 @@
+---
+- ansible.builtin.debug:
+ msg: START Merged ios_prefix_lists state for integration tests on connection={{ ansible_connection }}
+
+- block:
+ - ansible.builtin.include_tasks: _remove_config.yaml
+ - name: Merge provided prefix lists configuration with device configuration
+ register: result
+ cisco.ios.ios_prefix_lists: &id001
+ config:
+ - afi: ipv4
+ prefix_lists:
+ - name: 10
+ description: this is test description
+ entries:
+ - action: deny
+ prefix: 1.0.0.0/8
+ le: 15
+ sequence: 5
+ - action: deny
+ prefix: 35.0.0.0/8
+ ge: 10
+ sequence: 10
+ - action: deny
+ prefix: 12.0.0.0/8
+ ge: 15
+ sequence: 15
+ - action: deny
+ prefix: 14.0.0.0/8
+ ge: 20
+ le: 21
+ sequence: 20
+ - name: test
+ description: this is test
+ entries:
+ - action: deny
+ prefix: 12.0.0.0/8
+ ge: 15
+ sequence: 50
+ - name: test_prefix
+ description: this is for prefix-list
+ entries:
+ - action: deny
+ prefix: 35.0.0.0/8
+ ge: 10
+ le: 15
+ sequence: 5
+ - action: deny
+ prefix: 35.0.0.0/8
+ ge: 20
+ sequence: 10
+ - afi: ipv6
+ prefix_lists:
+ - name: test_ipv6
+ description: this is ipv6 prefix-list
+ entries:
+ - action: deny
+ prefix: 2001:DB8:0:4::/64
+ ge: 80
+ sequence: 10
+ state: merged
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - merged['before'] == {}
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['after'] | symmetric_difference(result['after']) | length == 0 }}"
+
+ - name: Merge provided prefix lists configuration with device configuration (idempotent)
+ register: result
+ cisco.ios.ios_prefix_lists: *id001
+ - name: Assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/overridden.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/overridden.yaml
new file mode 100644
index 000000000..901bd9524
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/overridden.yaml
@@ -0,0 +1,64 @@
+---
+- ansible.builtin.debug:
+ msg: START Overridden ios_prefix_lists state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Override provided prefix lists configuration
+ register: result
+ cisco.ios.ios_prefix_lists: &id001
+ config:
+ - afi: ipv4
+ prefix_lists:
+ - name: 10
+ description: this is override test
+ entries:
+ - action: deny
+ prefix: 12.0.0.0/8
+ ge: 15
+ sequence: 15
+ - action: deny
+ prefix: 14.0.0.0/8
+ ge: 20
+ le: 21
+ sequence: 20
+ - name: test_override
+ description: this is override test
+ entries:
+ - action: deny
+ prefix: 35.0.0.0/8
+ ge: 20
+ sequence: 10
+ - afi: ipv6
+ prefix_lists:
+ - name: test_ipv6
+ description: this is ipv6 override test
+ entries:
+ - action: deny
+ prefix: 2001:DB8:0:4::/64
+ ge: 80
+ le: 100
+ sequence: 10
+ state: overridden
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ overridden['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ overridden['after'] | symmetric_difference(result['after']) | length == 0 }}"
+
+ - name: Override provided prefix lists configuration (idempotent)
+ register: result
+ cisco.ios.ios_prefix_lists: *id001
+ - name: Assert that task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/parsed.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/parsed.yaml
new file mode 100644
index 000000000..435aa843b
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/parsed.yaml
@@ -0,0 +1,14 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_prefix_lists parsed integration tests on connection={{ ansible_connection }}
+
+- name: Parse the commands for provided configuration
+ register: result
+ cisco.ios.ios_prefix_lists:
+ running_config: "{{ lookup('file', '_parsed.cfg') }}"
+ state: parsed
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - "{{ merged['after'] | symmetric_difference(result['parsed']) |length == 0 }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/rendered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/rendered.yaml
new file mode 100644
index 000000000..8753d3cb2
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/rendered.yaml
@@ -0,0 +1,65 @@
+---
+- ansible.builtin.debug:
+ msg: Start ios_prefix_lists rendered integration tests ansible_connection={{ ansible_connection }}
+
+- block:
+ - name: Render the commands for provided prefix lists configuration
+ register: result
+ cisco.ios.ios_prefix_lists:
+ config:
+ - afi: ipv4
+ prefix_lists:
+ - name: 10
+ description: this is test description
+ entries:
+ - action: deny
+ prefix: 1.0.0.0/8
+ le: 15
+ sequence: 5
+ - action: deny
+ prefix: 35.0.0.0/8
+ ge: 10
+ sequence: 10
+ - action: deny
+ prefix: 12.0.0.0/8
+ ge: 15
+ sequence: 15
+ - action: deny
+ prefix: 14.0.0.0/8
+ ge: 20
+ le: 21
+ sequence: 20
+ - name: test
+ description: this is test
+ entries:
+ - action: deny
+ prefix: 12.0.0.0/8
+ ge: 15
+ sequence: 50
+ - name: test_prefix
+ description: this is for prefix-list
+ entries:
+ - action: deny
+ prefix: 35.0.0.0/8
+ ge: 10
+ le: 15
+ sequence: 5
+ - action: deny
+ prefix: 35.0.0.0/8
+ ge: 20
+ sequence: 10
+ - afi: ipv6
+ prefix_lists:
+ - name: test_ipv6
+ description: this is ipv6 prefix-list
+ entries:
+ - action: deny
+ prefix: 2001:DB8:0:4::/64
+ ge: 80
+ sequence: 10
+ state: rendered
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - result.rendered|symmetric_difference(merged.commands) == []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/replaced.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/replaced.yaml
new file mode 100644
index 000000000..cbd519d9c
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/replaced.yaml
@@ -0,0 +1,68 @@
+---
+- ansible.builtin.debug:
+ msg: START Replaced ios_prefix_lists state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Replaced provided prefix lists configuration
+ register: result
+ cisco.ios.ios_prefix_lists: &id001
+ config:
+ - afi: ipv4
+ prefix_lists:
+ - name: 10
+ description: this is replace test
+ entries:
+ - action: deny
+ prefix: 12.0.0.0/8
+ ge: 15
+ sequence: 15
+ - action: deny
+ prefix: 14.0.0.0/8
+ ge: 20
+ le: 21
+ sequence: 20
+ - name: test_replace
+ description: this is replace test
+ entries:
+ - action: deny
+ prefix: 35.0.0.0/8
+ ge: 20
+ sequence: 10
+ - afi: ipv6
+ prefix_lists:
+ - name: test_ipv6
+ description: this is ipv6 replace test
+ entries:
+ - action: deny
+ prefix: 2001:DB8:0:4::/64
+ ge: 80
+ le: 100
+ sequence: 10
+ state: replaced
+
+ - name: Assert that before dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['after'] | symmetric_difference(result['before']) | length == 0 }}"
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ replaced['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ replaced['after'] | symmetric_difference(result['after']) | length == 0 }}"
+
+ - name: Replaced provided prefix lists configuration (idempotent)
+ register: result
+ cisco.ios.ios_prefix_lists: *id001
+ - name: Assert that task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/vars/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/vars/main.yaml
new file mode 100644
index 000000000..78136adc0
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/vars/main.yaml
@@ -0,0 +1,247 @@
+---
+merged:
+ before: {}
+
+ commands:
+ - ip prefix-list test description this is test
+ - ip prefix-list test seq 50 deny 12.0.0.0/8 ge 15
+ - ip prefix-list 10 seq 15 deny 12.0.0.0/8 ge 15
+ - ip prefix-list 10 seq 10 deny 35.0.0.0/8 ge 10
+ - ip prefix-list 10 seq 5 deny 1.0.0.0/8 le 15
+ - ip prefix-list 10 description this is test description
+ - ip prefix-list 10 seq 20 deny 14.0.0.0/8 ge 20 le 21
+ - ip prefix-list test_prefix seq 10 deny 35.0.0.0/8 ge 20
+ - ip prefix-list test_prefix seq 5 deny 35.0.0.0/8 ge 10 le 15
+ - ip prefix-list test_prefix description this is for prefix-list
+ - ipv6 prefix-list test_ipv6 seq 10 deny 2001:DB8:0:4::/64 ge 80
+ - ipv6 prefix-list test_ipv6 description this is ipv6 prefix-list
+
+ after:
+ - afi: ipv4
+ prefix_lists:
+ - description: this is test description
+ entries:
+ - action: deny
+ le: 15
+ prefix: 1.0.0.0/8
+ sequence: 5
+ - action: deny
+ ge: 10
+ prefix: 35.0.0.0/8
+ sequence: 10
+ - action: deny
+ ge: 15
+ prefix: 12.0.0.0/8
+ sequence: 15
+ - action: deny
+ ge: 20
+ le: 21
+ prefix: 14.0.0.0/8
+ sequence: 20
+ name: "10"
+ - description: this is test
+ entries:
+ - action: deny
+ ge: 15
+ prefix: 12.0.0.0/8
+ sequence: 50
+ name: test
+ - description: this is for prefix-list
+ entries:
+ - action: deny
+ ge: 10
+ le: 15
+ prefix: 35.0.0.0/8
+ sequence: 5
+ - action: deny
+ ge: 20
+ prefix: 35.0.0.0/8
+ sequence: 10
+ name: test_prefix
+ - afi: ipv6
+ prefix_lists:
+ - description: this is ipv6 prefix-list
+ entries:
+ - action: deny
+ ge: 80
+ prefix: 2001:DB8:0:4::/64
+ sequence: 10
+ name: test_ipv6
+
+overridden:
+ commands:
+ - no ip prefix-list test
+ - no ip prefix-list test_prefix
+ - ip prefix-list 10 description this is override test
+ - no ip prefix-list 10 seq 10 deny 35.0.0.0/8 ge 10
+ - no ip prefix-list 10 seq 5 deny 1.0.0.0/8 le 15
+ - ip prefix-list test_override seq 10 deny 35.0.0.0/8 ge 20
+ - ip prefix-list test_override description this is override test
+ - no ipv6 prefix-list test_ipv6 seq 10 deny 2001:DB8:0:4::/64 ge 80
+ - ipv6 prefix-list test_ipv6 seq 10 deny 2001:DB8:0:4::/64 ge 80 le 100
+ - ipv6 prefix-list test_ipv6 description this is ipv6 override test
+
+ after:
+ - afi: ipv4
+ prefix_lists:
+ - description: this is override test
+ entries:
+ - action: deny
+ ge: 15
+ prefix: 12.0.0.0/8
+ sequence: 15
+ - action: deny
+ ge: 20
+ le: 21
+ prefix: 14.0.0.0/8
+ sequence: 20
+ name: "10"
+ - description: this is override test
+ entries:
+ - action: deny
+ ge: 20
+ prefix: 35.0.0.0/8
+ sequence: 10
+ name: test_override
+ - afi: ipv6
+ prefix_lists:
+ - description: this is ipv6 override test
+ entries:
+ - action: deny
+ ge: 80
+ le: 100
+ prefix: 2001:DB8:0:4::/64
+ sequence: 10
+ name: test_ipv6
+
+replaced:
+ commands:
+ - ip prefix-list 10 description this is replace test
+ - no ip prefix-list 10 seq 10 deny 35.0.0.0/8 ge 10
+ - no ip prefix-list 10 seq 5 deny 1.0.0.0/8 le 15
+ - ip prefix-list test_replace seq 10 deny 35.0.0.0/8 ge 20
+ - ip prefix-list test_replace description this is replace test
+ - no ipv6 prefix-list test_ipv6 seq 10 deny 2001:DB8:0:4::/64 ge 80
+ - ipv6 prefix-list test_ipv6 seq 10 deny 2001:DB8:0:4::/64 ge 80 le 100
+ - ipv6 prefix-list test_ipv6 description this is ipv6 replace test
+
+ after:
+ - afi: ipv4
+ prefix_lists:
+ - description: this is replace test
+ entries:
+ - action: deny
+ ge: 15
+ prefix: 12.0.0.0/8
+ sequence: 15
+ - action: deny
+ ge: 20
+ le: 21
+ prefix: 14.0.0.0/8
+ sequence: 20
+ name: "10"
+ - description: this is test
+ entries:
+ - action: deny
+ ge: 15
+ prefix: 12.0.0.0/8
+ sequence: 50
+ name: test
+ - description: this is for prefix-list
+ entries:
+ - action: deny
+ ge: 10
+ le: 15
+ prefix: 35.0.0.0/8
+ sequence: 5
+ - action: deny
+ ge: 20
+ prefix: 35.0.0.0/8
+ sequence: 10
+ name: test_prefix
+ - description: this is replace test
+ entries:
+ - action: deny
+ ge: 20
+ prefix: 35.0.0.0/8
+ sequence: 10
+ name: test_replace
+ - afi: ipv6
+ prefix_lists:
+ - description: this is ipv6 replace test
+ entries:
+ - action: deny
+ ge: 80
+ le: 100
+ prefix: 2001:DB8:0:4::/64
+ sequence: 10
+ name: test_ipv6
+
+deleted_name:
+ commands:
+ - no ip prefix-list 10
+ - no ip prefix-list test_prefix
+
+deleted_afi:
+ commands:
+ - no ip prefix-list test
+ - no ip prefix-list 10
+ - no ip prefix-list test_prefix
+
+deleted_all:
+ commands:
+ - no ip prefix-list test
+ - no ip prefix-list 10
+ - no ip prefix-list test_prefix
+ - no ipv6 prefix-list test_ipv6
+ before:
+ - afi: ipv4
+ prefix_lists:
+ - description: this is test description
+ entries:
+ - action: deny
+ le: 15
+ prefix: 1.0.0.0/8
+ sequence: 5
+ - action: deny
+ ge: 10
+ prefix: 35.0.0.0/8
+ sequence: 10
+ - action: deny
+ ge: 15
+ prefix: 12.0.0.0/8
+ sequence: 15
+ - action: deny
+ ge: 20
+ le: 21
+ prefix: 14.0.0.0/8
+ sequence: 20
+ name: "10"
+ - description: this is test
+ entries:
+ - action: deny
+ ge: 15
+ prefix: 12.0.0.0/8
+ sequence: 50
+ name: test
+ - description: this is for prefix-list
+ entries:
+ - action: deny
+ ge: 10
+ le: 15
+ prefix: 35.0.0.0/8
+ sequence: 5
+ - action: deny
+ ge: 20
+ prefix: 35.0.0.0/8
+ sequence: 10
+ name: test_prefix
+ - afi: ipv6
+ prefix_lists:
+ - description: this is ipv6 prefix-list
+ entries:
+ - action: deny
+ ge: 80
+ prefix: 2001:DB8:0:4::/64
+ sequence: 10
+ name: test_ipv6
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/defaults/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/defaults/main.yaml
new file mode 100644
index 000000000..164afead2
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/meta/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/meta/main.yaml
new file mode 100644
index 000000000..23d65c7ef
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/meta/main.yaml
@@ -0,0 +1,2 @@
+---
+dependencies: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tasks/cli.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tasks/cli.yaml
new file mode 100644
index 000000000..6f505600c
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tasks/cli.yaml
@@ -0,0 +1,21 @@
+---
+- name: Collect all CLI test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+ delegate_to: localhost
+
+- name: Run test case (connection=ansible.netcommon.network_cli)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.network_cli
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tasks/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tasks/main.yaml
new file mode 100644
index 000000000..447e7938d
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tasks/main.yaml
@@ -0,0 +1,5 @@
+---
+- name: Main task for route_maps module
+ ansible.builtin.include_tasks: cli.yaml
+ tags:
+ - network_cli
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/_parsed.cfg b/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/_parsed.cfg
new file mode 100644
index 000000000..eb438eac0
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/_parsed.cfg
@@ -0,0 +1,34 @@
+route-map test_1 deny 10
+ description this is test route
+ match ip next-hop prefix-list test_1_new test_2_new
+ match ip route-source 10
+ match security-group source tag 10 20
+ match local-preference 100 50
+ match mpls-label
+ match community test_comm
+ set as-path prepend 64512
+ set community 65000:100 65000:200
+route-map test_1 deny 20
+ match track 105
+ match tag list test_match_tag
+ match route-type level-1
+ match additional-paths advertise-set all group-best
+ match as-path 100 200
+ match ipv6 address test_acl_20
+ continue 100
+route-map test_2 deny 10
+ match security-group source tag 10 20
+ match local-preference 105 55
+ match mpls-label
+ match ipv6 address test_ip_acl
+ match ipv6 next-hop prefix-list test_new
+ match ipv6 route-source route_src_acl
+ set automatic-tag
+ set ip precedence critical
+ set ip address prefix-list 192.0.2.1
+ set aigp-metric 100
+ set as-path prepend 65111 65111
+ set extcommunity cost pre-bestpath 10 100
+ set ip df 1
+ set ip next-hop verify-availability 198.51.111.1 100 track 10
+ set ip next-hop recursive global 198.51.110.1
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/_populate_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/_populate_config.yaml
new file mode 100644
index 000000000..b751c5128
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/_populate_config.yaml
@@ -0,0 +1,107 @@
+---
+- name: Populate route maps configuration
+ cisco.ios.ios_route_maps:
+ config:
+ - route_map: test_1
+ entries:
+ - sequence: 10
+ action: deny
+ description: this is test route
+ set:
+ as_path:
+ prepend:
+ as_number:
+ - "64512"
+ community:
+ number: 65000:100 65000:200
+ match:
+ community:
+ name:
+ - test_comm
+ ip:
+ next_hop:
+ prefix_lists:
+ - test_1_new
+ - test_2_new
+ route_source:
+ acls:
+ - 10
+ security_group:
+ source:
+ - 10
+ - 20
+ local_preference:
+ value:
+ - 50
+ - 100
+ mpls_label: true
+ - sequence: 20
+ action: deny
+ continue_entry:
+ entry_sequence: 100
+ match:
+ additional_paths:
+ all: true
+ group_best: true
+ as_path:
+ acls:
+ - 100
+ - 200
+ ipv6:
+ address:
+ acl: test_acl_20
+ route_type:
+ level_1: true
+ tag:
+ tag_list:
+ - test_match_tag
+ track: 105
+ - route_map: test_2
+ entries:
+ - sequence: 10
+ action: deny
+ match:
+ ipv6:
+ address:
+ acl: test_ip_acl
+ next_hop:
+ prefix_list: test_new
+ route_source:
+ acl: route_src_acl
+ security_group:
+ source:
+ - 10
+ - 20
+ local_preference:
+ value:
+ - 55
+ - 105
+ mpls_label: true
+ set:
+ aigp_metric:
+ value: 100
+ as_path:
+ prepend:
+ as_number:
+ - 65111
+ - 65111
+ automatic_tag: true
+ extcommunity:
+ cost:
+ id: 10
+ cost_value: 100
+ pre_bestpath: true
+ ip:
+ address: 192.0.2.1
+ df: 1
+ next_hop:
+ recursive:
+ global_route: true
+ address: 198.51.110.1
+ verify_availability:
+ address: 198.51.111.1
+ sequence: 100
+ track: 10
+ precedence:
+ critical: true
+ state: merged
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/_remove_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/_remove_config.yaml
new file mode 100644
index 000000000..f07e81160
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/_remove_config.yaml
@@ -0,0 +1,4 @@
+---
+- name: Remove all route maps configuration
+ cisco.ios.ios_route_maps:
+ state: deleted
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/deleted.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/deleted.yaml
new file mode 100644
index 000000000..0facc8624
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/deleted.yaml
@@ -0,0 +1,50 @@
+---
+- ansible.builtin.debug:
+ msg: Start Deleted integration state for ios_route_maps ansible_connection={{ ansible_connection }}
+
+- block:
+ - ansible.builtin.include_tasks: _remove_config.yaml
+ - ansible.builtin.include_tasks: _populate_config.yaml
+
+ - name: Delete provided route maps configuration
+ register: result
+ cisco.ios.ios_route_maps: &id001
+ config:
+ - route_map: test_1
+ state: deleted
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ deleted['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Delete provided route maps configuration (idempotent)
+ register: result
+ cisco.ios.ios_route_maps: *id001
+ - name: Assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+ - ansible.builtin.include_tasks: _remove_config.yaml
+ - ansible.builtin.include_tasks: _populate_config.yaml
+
+ - name: Delete all provided route maps configuration
+ register: result
+ cisco.ios.ios_route_maps: &id002
+ state: deleted
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ deleted_all['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Delete all provided route maps configuration (idempotent)
+ register: result
+ cisco.ios.ios_route_maps: *id002
+ - name: Assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result.changed == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/empty_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/empty_config.yaml
new file mode 100644
index 000000000..21d07f55f
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/empty_config.yaml
@@ -0,0 +1,58 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_route_maps empty_config.yaml integration tests on connection={{ ansible_connection }}
+
+- name: Merged with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_route_maps:
+ config:
+ state: merged
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state merged'
+
+- name: Replaced with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_route_maps:
+ config:
+ state: replaced
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state replaced'
+
+- name: Overridden with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_route_maps:
+ config:
+ state: overridden
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state overridden'
+
+- name: Rendered with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_route_maps:
+ config:
+ state: rendered
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state rendered'
+
+- name: Parsed with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_route_maps:
+ running_config:
+ state: parsed
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of running_config parameter must not be empty for state parsed'
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/gathered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/gathered.yaml
new file mode 100644
index 000000000..ad25d4051
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/gathered.yaml
@@ -0,0 +1,21 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_route_maps gathered integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Gather the provided configuration with the existing running configuration
+ register: result
+ cisco.ios.ios_route_maps:
+ config:
+ state: gathered
+
+ - name: Assert
+ ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - "{{ merged['after'] | symmetric_difference(result['gathered']) |length == 0 }}"
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/merged.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/merged.yaml
new file mode 100644
index 000000000..4201a6afa
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/merged.yaml
@@ -0,0 +1,141 @@
+---
+- ansible.builtin.debug:
+ msg: START Merged ios_route_maps state for integration tests on connection={{ ansible_connection }}
+
+- block:
+ - ansible.builtin.include_tasks: _remove_config.yaml
+ - name: Merge provided route maps configuration with device configuration
+ register: result
+ cisco.ios.ios_route_maps: &id001
+ config:
+ - route_map: test_1
+ entries:
+ - sequence: 10
+ action: deny
+ description: this is test route
+ set:
+ as_path:
+ prepend:
+ as_number:
+ - 64512
+ community:
+ number: 65000:100 65000:200
+ match:
+ community:
+ name:
+ - test_comm
+ ip:
+ next_hop:
+ prefix_lists:
+ - test_1_new
+ - test_2_new
+ route_source:
+ acls:
+ - 10
+ security_group:
+ source:
+ - 10
+ - 20
+ local_preference:
+ value:
+ - 50
+ - 100
+ mpls_label: true
+ - sequence: 20
+ action: deny
+ continue_entry:
+ entry_sequence: 100
+ match:
+ additional_paths:
+ all: true
+ group_best: true
+ as_path:
+ acls:
+ - 100
+ - 200
+ ipv6:
+ address:
+ acl: test_acl_20
+ route_type:
+ level_1: true
+ tag:
+ tag_list:
+ - test_match_tag
+ track: 105
+ - route_map: test_2
+ entries:
+ - sequence: 10
+ action: deny
+ match:
+ ipv6:
+ address:
+ acl: test_ip_acl
+ next_hop:
+ prefix_list: test_new
+ route_source:
+ acl: route_src_acl
+ security_group:
+ source:
+ - 10
+ - 20
+ local_preference:
+ value:
+ - 55
+ - 105
+ mpls_label: true
+ set:
+ aigp_metric:
+ value: 100
+ as_path:
+ prepend:
+ as_number:
+ - 65111
+ - 65111
+ automatic_tag: true
+ extcommunity:
+ cost:
+ id: 10
+ cost_value: 100
+ pre_bestpath: true
+ ip:
+ address: 192.0.2.1
+ df: 1
+ next_hop:
+ recursive:
+ global_route: true
+ address: 198.51.110.1
+ verify_availability:
+ address: 198.51.111.1
+ sequence: 100
+ track: 10
+ precedence:
+ critical: true
+ state: merged
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - merged['before'] == {}
+
+ - name: debug
+ debug:
+ msg: "{{ merged['after'] | symmetric_difference(result['after']) }}"
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['after'] | symmetric_difference(result['after']) | length == 0 }}"
+
+ - name: Merge provided route maps configuration with device configuration (idempotent)
+ register: result
+ cisco.ios.ios_route_maps: *id001
+ - name: Assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/overridden.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/overridden.yaml
new file mode 100644
index 000000000..b4aba6aa6
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/overridden.yaml
@@ -0,0 +1,138 @@
+---
+- ansible.builtin.debug:
+ msg: START Overridden ios_route_maps state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Override provided route maps configuration
+ register: result
+ cisco.ios.ios_route_maps: &id001
+ config:
+ - route_map: test_1
+ entries:
+ - sequence: 10
+ action: deny
+ description: this is override route
+ match:
+ community:
+ name:
+ - test_comm_overridden
+ ip:
+ next_hop:
+ acls:
+ - 10
+ - test1_acl
+ flowspec:
+ dest_pfx: true
+ acls:
+ - test_acl_1
+ - test_acl_2
+ length:
+ minimum: 10
+ maximum: 100
+ metric:
+ value: 10
+ external: true
+ security_group:
+ source:
+ - 10
+ - 20
+ mpls_label: true
+ set:
+ as_path:
+ prepend:
+ as_number:
+ - 64512
+ - 64512
+ community:
+ additive: true
+ internet: true
+ gshut: true
+ no_export: true
+ no_advertise: true
+ local_as: true
+ extcommunity:
+ vpn_distinguisher:
+ address: 192.0.2.1:12
+ additive: true
+ metric:
+ metric_value: 100
+ deviation: plus
+ eigrp_delay: 100
+ metric_reliability: 10
+ metric_bandwidth: 20
+ mtu: 30
+ - route_map: test_override
+ entries:
+ - sequence: 10
+ action: deny
+ match:
+ ipv6:
+ address:
+ acl: test_acl
+ next_hop:
+ prefix_list: test_new
+ route_source:
+ acl: route_src_acl
+ security_group:
+ source:
+ - 15
+ - 20
+ local_preference:
+ value:
+ - 105
+ - 110
+ mpls_label: true
+ set:
+ aigp_metric:
+ value: 100
+ as_path:
+ prepend:
+ last_as: 2
+ automatic_tag: true
+ extcommunity:
+ cost:
+ id: 10
+ cost_value: 100
+ pre_bestpath: true
+ ip:
+ address: 192.0.2.1
+ df: 1
+ next_hop:
+ recursive:
+ global_route: true
+ address: 198.110.51.1
+ verify_availability:
+ address: 198.110.51.2
+ sequence: 100
+ track: 10
+ precedence:
+ critical: true
+ state: overridden
+
+ - name: Assert that before dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['after'] | symmetric_difference(result['before']) | length == 0 }}"
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ overridden['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ overridden['after'] | symmetric_difference(result['after']) | length == 0 }}"
+
+ - name: Override provided route maps configuration (idempotent)
+ register: result
+ cisco.ios.ios_route_maps: *id001
+ - name: Assert that task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/parsed.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/parsed.yaml
new file mode 100644
index 000000000..a24c1f40e
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/parsed.yaml
@@ -0,0 +1,14 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_route_maps parsed integration tests on connection={{ ansible_connection }}
+
+- name: Parse the commands for provided configuration
+ register: result
+ cisco.ios.ios_route_maps:
+ running_config: "{{ lookup('file', '_parsed.cfg') }}"
+ state: parsed
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - "{{ parsed['config'] | symmetric_difference(result['parsed']) |length == 0 }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/rendered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/rendered.yaml
new file mode 100644
index 000000000..710e382f7
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/rendered.yaml
@@ -0,0 +1,117 @@
+---
+- ansible.builtin.debug:
+ msg: Start ios_route_maps rendered integration tests ansible_connection={{ ansible_connection }}
+
+- block:
+ - name: Render the commands for provided route map configuration
+ register: result
+ cisco.ios.ios_route_maps:
+ config:
+ - route_map: test_1
+ entries:
+ - sequence: 10
+ action: deny
+ description: this is test route
+ set:
+ as_path:
+ prepend:
+ as_number:
+ - 64512
+ community:
+ number: 65000:100 65000:200
+ match:
+ community:
+ name:
+ - test_comm
+ ip:
+ next_hop:
+ prefix_lists:
+ - test_1_new
+ - test_2_new
+ route_source:
+ acls:
+ - 10
+ security_group:
+ source:
+ - 10
+ - 20
+ local_preference:
+ value:
+ - 50
+ - 100
+ mpls_label: true
+ - sequence: 20
+ action: deny
+ continue_entry:
+ entry_sequence: 100
+ match:
+ additional_paths:
+ all: true
+ group_best: true
+ as_path:
+ acls:
+ - 100
+ - 200
+ ipv6:
+ address:
+ acl: test_acl_20
+ route_type:
+ level_1: true
+ tag:
+ tag_list:
+ - test_match_tag
+ track: 105
+ - route_map: test_2
+ entries:
+ - sequence: 10
+ action: deny
+ match:
+ ipv6:
+ address:
+ acl: test_ip_acl
+ next_hop:
+ prefix_list: test_new
+ route_source:
+ acl: route_src_acl
+ security_group:
+ source:
+ - 10
+ - 20
+ local_preference:
+ value:
+ - 55
+ - 105
+ mpls_label: true
+ set:
+ aigp_metric:
+ value: 100
+ as_path:
+ prepend:
+ as_number:
+ - 65111
+ - 65111
+ automatic_tag: true
+ extcommunity:
+ cost:
+ id: 10
+ cost_value: 100
+ pre_bestpath: true
+ ip:
+ address: 192.0.2.1
+ df: 1
+ next_hop:
+ recursive:
+ global_route: true
+ address: 198.51.110.1
+ verify_availability:
+ address: 198.51.111.1
+ sequence: 100
+ track: 10
+ precedence:
+ critical: true
+ state: rendered
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - result.rendered|symmetric_difference(merged.commands) == []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/replaced.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/replaced.yaml
new file mode 100644
index 000000000..da319f713
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/tests/cli/replaced.yaml
@@ -0,0 +1,134 @@
+---
+- ansible.builtin.debug:
+ msg: START Replaced ios_route_maps state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Replaced provided route maps configuration
+ register: result
+ cisco.ios.ios_route_maps: &id001
+ config:
+ - route_map: test_1
+ entries:
+ - sequence: 10
+ action: deny
+ description: this is replaced route
+ match:
+ community:
+ name:
+ - test_comm_replaced
+ ip:
+ next_hop:
+ acls:
+ - 10
+ - test1_acl
+ flowspec:
+ dest_pfx: true
+ acls:
+ - test_acl_1
+ - test_acl_2
+ length:
+ minimum: 10
+ maximum: 100
+ metric:
+ value: 10
+ external: true
+ security_group:
+ source:
+ - 10
+ - 20
+ mpls_label: true
+ set:
+ extcommunity:
+ vpn_distinguisher:
+ address: 192.0.2.1:12
+ additive: true
+ as_path:
+ prepend:
+ as_number:
+ - "64512"
+ - "64512"
+ community:
+ number: 65000:300
+ metric:
+ metric_value: 100
+ deviation: plus
+ eigrp_delay: 100
+ metric_reliability: 10
+ metric_bandwidth: 20
+ mtu: 30
+ - route_map: test_replaced
+ entries:
+ - sequence: 10
+ action: deny
+ match:
+ ipv6:
+ address:
+ acl: test_acl
+ next_hop:
+ prefix_list: test_new
+ route_source:
+ acl: route_src_acl
+ security_group:
+ source:
+ - 15
+ - 20
+ local_preference:
+ value:
+ - 105
+ - 110
+ mpls_label: true
+ set:
+ aigp_metric:
+ value: 100
+ as_path:
+ prepend:
+ as_number:
+ - 65111
+ - 65111
+ automatic_tag: true
+ extcommunity:
+ cost:
+ id: 10
+ cost_value: 100
+ pre_bestpath: true
+ ip:
+ address: 192.0.2.1
+ df: 1
+ next_hop:
+ recursive:
+ global_route: true
+ address: 198.110.51.1
+ verify_availability:
+ address: 198.110.51.2
+ sequence: 100
+ track: 10
+ precedence:
+ critical: true
+ state: replaced
+
+ - name: Assert that before dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['after'] | symmetric_difference(result['before']) | length == 0 }}"
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ replaced['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ replaced['after'] | symmetric_difference(result['after']) | length == 0 }}"
+
+ - name: Replaced provided route maps configuration (idempotent)
+ register: result
+ cisco.ios.ios_route_maps: *id001
+ - name: Assert that task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/vars/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/vars/main.yaml
new file mode 100644
index 000000000..5bb8d5957
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_route_maps/vars/main.yaml
@@ -0,0 +1,592 @@
+---
+merged:
+ before: {}
+
+ commands:
+ - route-map test_2 deny 10
+ - match security-group source tag 10 20
+ - match local-preference 105 55
+ - match mpls-label
+ - match ipv6 next-hop prefix-list test_new
+ - match ipv6 route-source route_src_acl
+ - match ipv6 address test_ip_acl
+ - set extcommunity cost pre-bestpath 10 100
+ - set ip df 1
+ - set ip next-hop recursive global 198.51.110.1
+ - set ip next-hop verify-availability 198.51.111.1 100 track 10
+ - set ip precedence critical
+ - set ip address prefix-list 192.0.2.1
+ - set automatic-tag
+ - set aigp-metric 100
+ - set as-path prepend 65111 65111
+ - route-map test_1 deny 20
+ - continue 100
+ - match track 105
+ - match tag list test_match_tag
+ - match ipv6 address test_acl_20
+ - match route-type level-1
+ - match as-path 100 200
+ - match additional-paths advertise-set all group-best
+ - route-map test_1 deny 10
+ - description this is test route
+ - set as-path prepend 64512
+ - set community 4259840100 4259840200
+ - match community test_comm
+ - match security-group source tag 10 20
+ - match ip next-hop prefix-list test_1_new test_2_new
+ - match ip route-source 10
+ - match local-preference 100 50
+ - match mpls-label
+
+ after:
+ - entries:
+ - action: deny
+ description: this is test route
+ match:
+ community:
+ name:
+ - test_comm
+ ip:
+ next_hop:
+ prefix_lists:
+ - test_1_new
+ - test_2_new
+ route_source:
+ acls:
+ - "10"
+ local_preference:
+ value:
+ - "100"
+ - "50"
+ mpls_label: true
+ security_group:
+ source:
+ - 10
+ - 20
+ sequence: 10
+ set:
+ as_path:
+ prepend:
+ as_number:
+ - "64512"
+ community:
+ number: 4259840100 4259840200
+ - action: deny
+ continue_entry:
+ entry_sequence: 100
+ match:
+ additional_paths:
+ all: true
+ group_best: true
+ as_path:
+ acls:
+ - 100
+ - 200
+ ipv6:
+ address:
+ acl: test_acl_20
+ route_type:
+ external:
+ set: true
+ level_1: true
+ nssa_external:
+ set: true
+ tag:
+ tag_list:
+ - test_match_tag
+ track: 105
+ sequence: 20
+ route_map: test_1
+ - entries:
+ - action: deny
+ match:
+ ipv6:
+ address:
+ acl: test_ip_acl
+ next_hop:
+ prefix_list: test_new
+ route_source:
+ acl: route_src_acl
+ local_preference:
+ value:
+ - "105"
+ - "55"
+ mpls_label: true
+ security_group:
+ source:
+ - 10
+ - 20
+ sequence: 10
+ set:
+ aigp_metric:
+ value: 100
+ as_path:
+ prepend:
+ as_number:
+ - "65111"
+ - "65111"
+ automatic_tag: true
+ extcommunity:
+ cost:
+ cost_value: 100
+ id: "10"
+ pre_bestpath: true
+ ip:
+ address: 192.0.2.1
+ df: 1
+ next_hop:
+ recursive:
+ address: 198.51.110.1
+ global_route: true
+ verify_availability:
+ address: 198.51.111.1
+ sequence: 100
+ track: 10
+ precedence:
+ critical: true
+ route_map: test_2
+
+overridden:
+ commands:
+ - no route-map test_2
+ - route-map test_override deny 10
+ - match security-group source tag 15 20
+ - match local-preference 105 110
+ - match mpls-label
+ - match ipv6 next-hop prefix-list test_new
+ - match ipv6 route-source route_src_acl
+ - match ipv6 address test_acl
+ - set extcommunity cost pre-bestpath 10 100
+ - set ip df 1
+ - set ip next-hop recursive global 198.110.51.1
+ - set ip next-hop verify-availability 198.110.51.2 100 track 10
+ - set ip precedence critical
+ - set ip address prefix-list 192.0.2.1
+ - set automatic-tag
+ - set aigp-metric 100
+ - set as-path prepend last-as 2
+ - route-map test_1 deny 10
+ - no description this is test route
+ - description this is override route
+ - match ip flowspec dest-pfx test_acl_1 test_acl_2
+ - no match ip next-hop prefix-list test_1_new test_2_new
+ - match ip next-hop 10 test1_acl
+ - no match ip route-source 10
+ - match metric external 10
+ - match length 10 100
+ - no match local-preference 100 50
+ - set extcommunity vpn-distinguisher 192.0.2.1:12 additive
+ - set metric 100 +100 10 20 30
+ - set as-path prepend 64512 64512
+ - no match community test_comm
+ - match community test_comm_overridden
+ - no set community 4259840100 4259840200
+ - set community gshut internet local-as no-advertise no-export additive
+ - no route-map test_1 deny 20
+
+ after:
+ - entries:
+ - action: deny
+ description: this is override route
+ match:
+ community:
+ name:
+ - test_comm_overridden
+ ip:
+ flowspec:
+ acls:
+ - test_acl_1
+ - test_acl_2
+ dest_pfx: true
+ next_hop:
+ acls:
+ - "10"
+ - "test1_acl"
+ length:
+ maximum: 100
+ minimum: 10
+ metric:
+ external: true
+ value: 10
+ mpls_label: true
+ security_group:
+ source:
+ - 10
+ - 20
+ sequence: 10
+ set:
+ extcommunity:
+ vpn_distinguisher:
+ additive: true
+ address: "192.0.2.1:12"
+ as_path:
+ prepend:
+ as_number:
+ - "64512"
+ - "64512"
+ community:
+ additive: true
+ internet: true
+ gshut: true
+ no_export: true
+ no_advertise: true
+ local_as: true
+ metric:
+ deviation: plus
+ eigrp_delay: 100
+ metric_bandwidth: 20
+ metric_reliability: 10
+ metric_value: 100
+ mtu: 30
+ route_map: test_1
+ - entries:
+ - action: deny
+ match:
+ ipv6:
+ address:
+ acl: test_acl
+ next_hop:
+ prefix_list: test_new
+ route_source:
+ acl: route_src_acl
+ local_preference:
+ value:
+ - "105"
+ - "110"
+ mpls_label: true
+ security_group:
+ source:
+ - 15
+ - 20
+ sequence: 10
+ set:
+ aigp_metric:
+ value: 100
+ as_path:
+ prepend:
+ last_as: 2
+ automatic_tag: true
+ extcommunity:
+ cost:
+ cost_value: 100
+ id: "10"
+ pre_bestpath: true
+ ip:
+ address: "192.0.2.1"
+ df: 1
+ next_hop:
+ recursive:
+ address: "198.110.51.1"
+ global_route: true
+ verify_availability:
+ address: "198.110.51.2"
+ sequence: 100
+ track: 10
+ precedence:
+ critical: true
+ route_map: test_override
+
+replaced:
+ commands:
+ - route-map test_replaced deny 10
+ - match security-group source tag 15 20
+ - match local-preference 105 110
+ - match mpls-label
+ - match ipv6 next-hop prefix-list test_new
+ - match ipv6 route-source route_src_acl
+ - match ipv6 address test_acl
+ - set extcommunity cost pre-bestpath 10 100
+ - set ip df 1
+ - set ip next-hop recursive global 198.110.51.1
+ - set ip next-hop verify-availability 198.110.51.2 100 track 10
+ - set ip precedence critical
+ - set ip address prefix-list 192.0.2.1
+ - set automatic-tag
+ - set aigp-metric 100
+ - set as-path prepend 65111 65111
+ - route-map test_1 deny 10
+ - no description this is test route
+ - description this is replaced route
+ - match ip flowspec dest-pfx test_acl_1 test_acl_2
+ - no match ip next-hop prefix-list test_1_new test_2_new
+ - match ip next-hop 10 test1_acl
+ - no match ip route-source 10
+ - match metric external 10
+ - match length 10 100
+ - no match local-preference 100 50
+ - set extcommunity vpn-distinguisher 192.0.2.1:12 additive
+ - set as-path prepend 64512 64512
+ - no match community test_comm
+ - match community test_comm_replaced
+ - no set community 4259840100 4259840200
+ - set community 4259840300
+ - set metric 100 +100 10 20 30
+ - no route-map test_1 deny 20
+
+ after:
+ - entries:
+ - action: deny
+ description: this is replaced route
+ match:
+ community:
+ name:
+ - test_comm_replaced
+ ip:
+ flowspec:
+ acls:
+ - test_acl_1
+ - test_acl_2
+ dest_pfx: true
+ next_hop:
+ acls:
+ - "10"
+ - test1_acl
+ length:
+ maximum: 100
+ minimum: 10
+ metric:
+ external: true
+ value: 10
+ mpls_label: true
+ security_group:
+ source:
+ - 10
+ - 20
+ sequence: 10
+ set:
+ as_path:
+ prepend:
+ as_number:
+ - "64512"
+ - "64512"
+ community:
+ number: "4259840300"
+ extcommunity:
+ vpn_distinguisher:
+ additive: true
+ address: 192.0.2.1:12
+ metric:
+ deviation: plus
+ eigrp_delay: 100
+ metric_bandwidth: 20
+ metric_reliability: 10
+ metric_value: 100
+ mtu: 30
+ route_map: test_1
+ - entries:
+ - action: deny
+ match:
+ ipv6:
+ address:
+ acl: test_ip_acl
+ next_hop:
+ prefix_list: test_new
+ route_source:
+ acl: route_src_acl
+ local_preference:
+ value:
+ - "105"
+ - "55"
+ mpls_label: true
+ security_group:
+ source:
+ - 10
+ - 20
+ sequence: 10
+ set:
+ aigp_metric:
+ value: 100
+ as_path:
+ prepend:
+ as_number:
+ - "65111"
+ - "65111"
+ automatic_tag: true
+ extcommunity:
+ cost:
+ cost_value: 100
+ id: "10"
+ pre_bestpath: true
+ ip:
+ address: 192.0.2.1
+ df: 1
+ next_hop:
+ recursive:
+ address: 198.51.110.1
+ global_route: true
+ verify_availability:
+ address: 198.51.111.1
+ sequence: 100
+ track: 10
+ precedence:
+ critical: true
+ route_map: test_2
+ - entries:
+ - action: deny
+ match:
+ ipv6:
+ address:
+ acl: test_acl
+ next_hop:
+ prefix_list: test_new
+ route_source:
+ acl: route_src_acl
+ local_preference:
+ value:
+ - "105"
+ - "110"
+ mpls_label: true
+ security_group:
+ source:
+ - 15
+ - 20
+ sequence: 10
+ set:
+ aigp_metric:
+ value: 100
+ as_path:
+ prepend:
+ as_number:
+ - "65111"
+ - "65111"
+ automatic_tag: true
+ extcommunity:
+ cost:
+ cost_value: 100
+ id: "10"
+ pre_bestpath: true
+ ip:
+ address: 192.0.2.1
+ df: 1
+ next_hop:
+ recursive:
+ address: 198.110.51.1
+ global_route: true
+ verify_availability:
+ address: 198.110.51.2
+ sequence: 100
+ track: 10
+ precedence:
+ critical: true
+ route_map: test_replaced
+
+deleted:
+ commands:
+ - no route-map test_1
+
+deleted_all:
+ commands:
+ - no route-map test_1
+ - no route-map test_2
+
+ after:
+ as_number: "65000"
+
+parsed:
+ config:
+ - entries:
+ - action: deny
+ description: this is test route
+ match:
+ community:
+ name:
+ - test_comm
+ ip:
+ next_hop:
+ prefix_lists:
+ - test_1_new
+ - test_2_new
+ route_source:
+ acls:
+ - "10"
+ local_preference:
+ value:
+ - "100"
+ - "50"
+ mpls_label: true
+ security_group:
+ source:
+ - 10
+ - 20
+ sequence: 10
+ set:
+ as_path:
+ prepend:
+ as_number:
+ - "64512"
+ community:
+ number: "65000:100 65000:200"
+ - action: deny
+ continue_entry:
+ entry_sequence: 100
+ match:
+ additional_paths:
+ all: true
+ group_best: true
+ as_path:
+ acls:
+ - 100
+ - 200
+ ipv6:
+ address:
+ acl: test_acl_20
+ route_type:
+ external:
+ set: true
+ level_1: true
+ nssa_external:
+ set: true
+ tag:
+ tag_list:
+ - test_match_tag
+ track: 105
+ sequence: 20
+ route_map: test_1
+ - entries:
+ - action: deny
+ match:
+ ipv6:
+ address:
+ acl: test_ip_acl
+ next_hop:
+ prefix_list: test_new
+ route_source:
+ acl: route_src_acl
+ local_preference:
+ value:
+ - "105"
+ - "55"
+ mpls_label: true
+ security_group:
+ source:
+ - 10
+ - 20
+ sequence: 10
+ set:
+ aigp_metric:
+ value: 100
+ as_path:
+ prepend:
+ as_number:
+ - "65111"
+ - "65111"
+ automatic_tag: true
+ extcommunity:
+ cost:
+ cost_value: 100
+ id: "10"
+ pre_bestpath: true
+ ip:
+ address: 192.0.2.1
+ df: 1
+ next_hop:
+ recursive:
+ address: 198.51.110.1
+ global_route: true
+ verify_availability:
+ address: 198.51.111.1
+ sequence: 100
+ track: 10
+ precedence:
+ critical: true
+ route_map: test_2
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_smoke/defaults/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_smoke/defaults/main.yaml
new file mode 100644
index 000000000..9ef5ba516
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_smoke/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "*"
+test_items: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_smoke/meta/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_smoke/meta/main.yaml
new file mode 100644
index 000000000..ab3ad91bc
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_smoke/meta/main.yaml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - prepare_ios_tests
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_smoke/tasks/cli.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_smoke/tasks/cli.yaml
new file mode 100644
index 000000000..e068b1664
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_smoke/tasks/cli.yaml
@@ -0,0 +1,18 @@
+---
+- name: Collect all CLI test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: Run test cases (connection=network_cli)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+ tags: network_cli
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_smoke/tasks/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_smoke/tasks/main.yaml
new file mode 100644
index 000000000..f8a9977d3
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_smoke/tasks/main.yaml
@@ -0,0 +1,5 @@
+---
+- name: Main task for smoke module
+ ansible.builtin.include_tasks: cli.yaml
+ tags:
+ - "network_cli"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_smoke/templates/defaults/config.j2 b/ansible_collections/cisco/ios/tests/integration/targets/ios_smoke/templates/defaults/config.j2
new file mode 100644
index 000000000..92f35da87
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_smoke/templates/defaults/config.j2
@@ -0,0 +1,3 @@
+interface Loopback999
+ description this is a test
+ no shutdown
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_smoke/tests/cli/caching.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_smoke/tests/cli/caching.yaml
new file mode 100644
index 000000000..ce5be43b6
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_smoke/tests/cli/caching.yaml
@@ -0,0 +1,92 @@
+---
+- block:
+ - ansible.builtin.debug: msg="START connection={{ ansible_connection }} common/caching.yaml"
+
+ - ansible.builtin.set_fact:
+ interfaces:
+ - interface GigabitEthernet2
+ - interface GigabitEthernet3
+
+ - name: Setup
+ cisco.ios.ios_config: &rem
+ lines:
+ - "no description"
+ - "no speed"
+ - "shutdown"
+ - "no ip address"
+ - "no ipv6 address"
+ parents:
+ - "{{ intf }}"
+ with_items: "{{ interfaces }}"
+ loop_control:
+ loop_var: intf
+
+ - name: Merge base interfaces configuration
+ register: result
+ cisco.ios.ios_interfaces: &merged
+ config:
+ - name: GigabitEthernet2
+ description: Configured by Ansible (L3)
+ enabled: true
+ - name: GigabitEthernet3
+ description: Configured by Ansible (L3)
+ enabled: true
+ state: merged
+
+ - ansible.builtin.assert:
+ that:
+ - '"interface GigabitEthernet2" in result.commands'
+ - '"description Configured by Ansible (L3)" in result.commands'
+ - '"no shutdown" in result.commands'
+ - '"interface GigabitEthernet3" in result.commands'
+ - '"description Configured by Ansible (L3)" in result.commands'
+ - '"no shutdown" in result.commands'
+ - result.commands|length == 7
+
+ - name: Merge base interfaces configuration (idempotent)
+ register: result
+ cisco.ios.ios_interfaces: *merged
+ - ansible.builtin.assert:
+ that:
+ - result.changed == False
+
+ - name: Merge layer 3 interfaces configuration
+ cisco.ios.ios_l3_interfaces: &merged_l3
+ config:
+ - name: GigabitEthernet2
+ ipv4:
+ - address: dhcp
+ - name: GigabitEthernet3
+ ipv4:
+ - address: 198.51.100.1/24
+ secondary: true
+ - address: 198.51.100.2/24
+ ipv6:
+ - address: 2001:db8:0:3::/64
+ state: merged
+ register: result
+
+ - ansible.builtin.assert:
+ that:
+ - '"interface GigabitEthernet2" in result.commands'
+ - '"ip address dhcp" in result.commands'
+ - '"interface GigabitEthernet3" in result.commands'
+ - '"ip address 198.51.100.1 255.255.255.0 secondary" in result.commands'
+ - '"ip address 198.51.100.2 255.255.255.0" in result.commands'
+ - '"ipv6 address 2001:db8:0:3::/64" in result.commands'
+ - result.commands|length == 6
+
+ - name: Merge layer 3 interfaces configuration (idempotent)
+ cisco.ios.ios_l3_interfaces: *merged_l3
+ register: result
+
+ - ansible.builtin.assert:
+ that: result.changed == False
+
+ always:
+ - name: Cleanup
+ cisco.ios.ios_config: *rem
+ with_items: "{{ interfaces }}"
+ loop_control:
+ loop_var: intf
+ when: ansible_connection == "ansible.netcommon.network_cli" and ansible_network_single_user_mode|d(False)
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_smoke/tests/cli/common_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_smoke/tests/cli/common_config.yaml
new file mode 100644
index 000000000..80e251c54
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_smoke/tests/cli/common_config.yaml
@@ -0,0 +1,207 @@
+---
+# ios_linkagg -> CustomNetworkConfig
+# cisco.ios.ios_config -> dumps, NetworkConfig
+
+- ansible.builtin.debug: msg="START cli/common_config.yaml on connection={{ ansible_connection }}"
+
+# Hit NetworkConfig
+
+- name: Set hostname
+ cisco.ios.ios_config:
+ lines:
+ - "hostname ios-smoke"
+ match: none
+
+- name: Hit diff_ignore_lines
+ cisco.ios.ios_config:
+ lines:
+ - "hostname ios-smoke-diff"
+ diff_ignore_lines:
+ - hostname ios-smoke
+ save_when: modified
+
+- name: Return hostname
+ cisco.ios.ios_config:
+ lines:
+ - "hostname {{ shorter_hostname }}"
+ match: none
+
+- name: Hit items with parents
+ cisco.ios.ios_config:
+ lines:
+ - "permit ip any any log"
+ parents:
+ - "ip access-list extended test"
+ match: exact
+ register: result
+
+- name: Teardown
+ cisco.ios.ios_config:
+ lines:
+ - "no ip access-list extended test"
+ match: none
+
+- name: Setup test networkconfig.difference, replace=block
+ cisco.ios.ios_config:
+ lines:
+ - permit ip host 192.0.2.1 any log
+ - permit ip host 192.0.2.2 any log
+ - permit ip host 192.0.2.3 any log
+ parents:
+ - "ip access-list extended test"
+ before:
+ - "no ip access-list extended test"
+ after:
+ - "exit"
+ match: none
+
+- name: Test networkconfig.difference, replace=block
+ cisco.ios.ios_config:
+ lines:
+ - permit ip host 192.0.2.1 any log
+ - permit ip host 192.0.2.2 any log
+ - permit ip host 192.0.2.3 any log
+ - permit ip host 192.0.2.4 any log
+ parents:
+ - "ip access-list extended test"
+ replace: block
+ after:
+ - "exit"
+ register: result
+
+- ansible.builtin.assert:
+ that:
+ - "result.changed == true"
+ - "'ip access-list extended test' in result.updates"
+ - "'permit ip host 192.0.2.1 any log' in result.updates"
+ - "'permit ip host 192.0.2.2 any log' in result.updates"
+ - "'permit ip host 192.0.2.3 any log' in result.updates"
+ - "'permit ip host 192.0.2.4 any log' in result.updates"
+
+- name: Teardown- networkconfig.difference, replace=block
+ cisco.ios.ios_config:
+ lines:
+ - no ip access-list extended test
+ match: none
+
+# CustomNetworkConfig
+# currently gets skipped because switch_type != 'L2'
+- ansible.builtin.set_fact: switch_type="{{ switch_type }}"
+
+- block:
+ - name: Setup - remove configuration used in test(part1)
+ cisco.ios.ios_config:
+ lines:
+ - no interface port-channel 20
+ ignore_errors: true
+
+ - name: Setup - remove configuration used in test(part2)
+ cisco.ios.ios_config:
+ lines:
+ - no interface port-channel 5
+ ignore_errors: true
+
+ - name: Setup - remove configuration used in test(part3)
+ cisco.ios.ios_config:
+ lines:
+ - no channel-group 20 mode active
+ parents: "{{ item }}"
+ loop:
+ - interface GigabitEthernet2
+ - interface GigabitEthernet3
+
+ - name: Create linkagg
+ ios_linkagg:
+ group: 20
+ state: present
+ register: result
+
+ - ansible.builtin.assert:
+ that:
+ - "result.changed == true"
+ - "'interface port-channel 20' in result.commands"
+
+ - name: Set link aggregation group to members
+ ios_linkagg:
+ group: 20
+ mode: active
+ members:
+ - GigabitEthernet2
+ - GigabitEthernet3
+ register: result
+
+ - ansible.builtin.assert:
+ that:
+ - "result.changed == true"
+ - "'interface GigabitEthernet2' in result.commands"
+ - "'channel-group 20 mode active' in result.commands"
+ - "'interface GigabitEthernet3' in result.commands"
+ - "'channel-group 20 mode active' in result.commands"
+
+ - name: Remove link aggregation group from member
+ ios_linkagg:
+ group: 20
+ mode: active
+ members:
+ - GigabitEthernet3
+ register: result
+
+ - ansible.builtin.assert:
+ that:
+ - "result.changed == true"
+ - "'interface GigabitEthernet2' in result.commands"
+ - "'no channel-group 20 mode active' in result.commands"
+
+ - name: Remove linkagg
+ ios_linkagg:
+ group: 20
+ state: absent
+ register: result
+
+ - ansible.builtin.assert:
+ that:
+ - "result.changed == true"
+ - "'no interface port-channel 20' in result.commands"
+
+ - name: Create aggregate of linkagg definitions
+ ios_linkagg:
+ aggregate:
+ - group: 5
+ - group: 20
+ mode: active
+ members:
+ - "GigabitEthernet2"
+ register: result
+
+ - ansible.builtin.assert:
+ that:
+ - "result.changed == true"
+ - "'interface port-channel 5' in result.commands"
+ - "'interface port-channel 20' in result.commands"
+ - "'interface GigabitEthernet2' in result.commands"
+ - "'channel-group 20 mode active' in result.commands"
+
+ - name: Teardown(part1)
+ cisco.ios.ios_config:
+ lines:
+ - no interface port-channel 20
+ ignore_errors: true
+
+ - name: Teardown(part2)
+ cisco.ios.ios_config:
+ lines:
+ - no interface port-channel 5
+ ignore_errors: true
+
+ - name: Teardown(part3)
+ cisco.ios.ios_config:
+ lines:
+ - no channel-group 20 mode active
+ parents: "{{ item }}"
+ loop:
+ - interface GigabitEthernet2
+ - interface GigabitEthernet3
+
+ when: switch_type == 'L2'
+
+- ansible.builtin.debug: msg="END cli/common_config.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_smoke/tests/cli/misc_tests.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_smoke/tests/cli/misc_tests.yaml
new file mode 100644
index 000000000..26cb60e2d
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_smoke/tests/cli/misc_tests.yaml
@@ -0,0 +1,42 @@
+---
+- ansible.builtin.debug: msg="START ios_smoke cli/misc_tests.yaml on connection={{ ansible_connection }}"
+
+# hit network.ios.ios- get_defaults_flag()
+- name: Setup
+ cisco.ios.ios_config:
+ commands:
+ - no description
+ - shutdown
+ parents:
+ - interface Loopback999
+ match: none
+
+- name: Configure device with defaults included
+ cisco.ios.ios_config:
+ src: defaults/config.j2
+ defaults: true
+ register: result
+
+- name: Run IOS commands to test command_timeout
+ cisco.ios.ios_command:
+ commands:
+ - show running-config all
+ - show interfaces
+ - show running-config all
+ vars:
+ ansible_command_timeout: 1
+ ansible_buffer_read_timeout: 2
+ ignore_errors: true
+ register: result
+ when: ansible_connection == 'ansible.netcommon.network_cli'
+
+- ansible.builtin.assert:
+ that:
+ - "result.failed == true"
+ - "'timeout value is 1 secs' in result.msg"
+ when: ansible_connection == 'ansible.netcommon.network_cli'
+
+- name: Reset ssh connection to allow user changes to affect 'current login user'
+ ansible.builtin.meta: reset_connection
+
+- ansible.builtin.debug: msg="END ios_smoke cli/misc_tests.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/defaults/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/defaults/main.yaml
new file mode 100644
index 000000000..164afead2
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/meta/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/meta/main.yaml
new file mode 100644
index 000000000..23d65c7ef
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/meta/main.yaml
@@ -0,0 +1,2 @@
+---
+dependencies: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tasks/cli.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tasks/cli.yaml
new file mode 100644
index 000000000..6f505600c
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tasks/cli.yaml
@@ -0,0 +1,21 @@
+---
+- name: Collect all CLI test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+ delegate_to: localhost
+
+- name: Run test case (connection=ansible.netcommon.network_cli)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.network_cli
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tasks/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tasks/main.yaml
new file mode 100644
index 000000000..23a7aab01
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tasks/main.yaml
@@ -0,0 +1,5 @@
+---
+- name: Main task for snmp_server module
+ ansible.builtin.include_tasks: cli.yaml
+ tags:
+ - network_cli
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tests/cli/_parsed.cfg b/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tests/cli/_parsed.cfg
new file mode 100644
index 000000000..35274d8e2
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tests/cli/_parsed.cfg
@@ -0,0 +1 @@
+snmp-server engineID remote 192.0.2.1 udp-port 22 AB0C5342FAAA
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tests/cli/_populate_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tests/cli/_populate_config.yaml
new file mode 100644
index 000000000..379052459
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tests/cli/_populate_config.yaml
@@ -0,0 +1,22 @@
+---
+- name: Pre post task populate snmp-server configuration
+ cisco.ios.ios_snmp_server:
+ config:
+ communities:
+ - acl_v4: test_Acl
+ name: integrationComm
+ rw: true
+ contact: "contact updated using play"
+ inform:
+ pending: 2
+ ip:
+ dscp: 2
+ location: "location entry for snmp"
+ packet_size: 500
+ system_shutdown: true
+ engine_id:
+ - id: AB0C5342FF0F
+ remote:
+ host: 192.0.2.12
+ udp_port: 25
+ state: merged
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tests/cli/_remove_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tests/cli/_remove_config.yaml
new file mode 100644
index 000000000..af1a8ac61
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tests/cli/_remove_config.yaml
@@ -0,0 +1,5 @@
+---
+- name: Pre post task remove snmp-server configuration
+ cisco.ios.ios_snmp_server:
+ config:
+ state: deleted
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tests/cli/deleted.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tests/cli/deleted.yaml
new file mode 100644
index 000000000..8aa0812bb
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tests/cli/deleted.yaml
@@ -0,0 +1,34 @@
+---
+- ansible.builtin.debug:
+ msg: Start Deleted integration state for ios_snmp_server ansible_connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Ios_snmp_server deleted - play
+ register: result
+ cisco.ios.ios_snmp_server: &id001
+ config:
+ state: deleted
+
+ - name: Ios_snmp_server deleted - assert commands
+ ansible.builtin.assert:
+ that:
+ - deleted['commands'] == result['commands']
+
+ - name: Ios_snmp_server deleted - assert before
+ ansible.builtin.assert:
+ that:
+ - deleted['before'] == result['before']
+
+ - name: Ios_snmp_server deleted - play (idempotent)
+ register: result
+ cisco.ios.ios_snmp_server: *id001
+ - name: Ios_snmp_server deleted - assert above task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result.changed == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tests/cli/empty_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tests/cli/empty_config.yaml
new file mode 100644
index 000000000..2822614db
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tests/cli/empty_config.yaml
@@ -0,0 +1,58 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_snmp_server empty_config.yaml integration tests on connection={{ ansible_connection }}
+
+- name: Merged with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_snmp_server:
+ config:
+ state: merged
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state merged'
+
+- name: Replaced with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_snmp_server:
+ config:
+ state: replaced
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state replaced'
+
+- name: Overridden with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_snmp_server:
+ config:
+ state: overridden
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state overridden'
+
+- name: Rendered with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_snmp_server:
+ config:
+ state: rendered
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state rendered'
+
+- name: Parsed with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_snmp_server:
+ running_config:
+ state: parsed
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of running_config parameter must not be empty for state parsed'
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tests/cli/gathered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tests/cli/gathered.yaml
new file mode 100644
index 000000000..502535187
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tests/cli/gathered.yaml
@@ -0,0 +1,20 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_snmp_server gathered integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Ios_snmp_server gather - play
+ register: result
+ cisco.ios.ios_snmp_server:
+ config:
+ state: gathered
+
+ - name: Ios_snmp_server gather - assert
+ ansible.builtin.assert:
+ that:
+ - gathered['config'] == result['gathered']
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tests/cli/merged.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tests/cli/merged.yaml
new file mode 100644
index 000000000..f520971d0
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tests/cli/merged.yaml
@@ -0,0 +1,41 @@
+---
+- ansible.builtin.debug:
+ msg: START Merged ios_snmp_server state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Ios_snmp_server merged - play
+ register: result
+ cisco.ios.ios_snmp_server: &id001
+ config:
+ hosts:
+ - community_string: integrationComm
+ host: 192.0.2.10
+ informs: true
+ traps:
+ - isis
+ version: 2c
+ state: merged
+
+ - name: Ios_snmp_server merged - assert commands
+ ansible.builtin.assert:
+ that:
+ - merged['commands'] == result['commands']
+
+ - name: Ios_snmp_server merged - assert after
+ ansible.builtin.assert:
+ that:
+ - merged['after'] == result['after']
+
+ - name: Ios_snmp_server merged - play (idempotent)
+ register: result
+ cisco.ios.ios_snmp_server: *id001
+ - name: Ios_snmp_server merged - assert above task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tests/cli/overridden.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tests/cli/overridden.yaml
new file mode 100644
index 000000000..8cc665da8
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tests/cli/overridden.yaml
@@ -0,0 +1,45 @@
+---
+- ansible.builtin.debug:
+ msg: START Overridden ios_snmp_server state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- ansible.builtin.include_tasks: _populate_config.yaml
+
+- block:
+ - name: Ios_snmp_server overridden - play
+ register: result
+ cisco.ios.ios_snmp_server: &id001
+ config:
+ location: "location entry for snmp"
+ packet_size: 500
+ communities:
+ - acl_v4: acl_uq
+ name: communityOvverriden
+ rw: true
+ state: overridden
+
+ - name: Ios_snmp_server overridden - assert commands
+ ansible.builtin.assert:
+ that:
+ - overridden['commands'] == result['commands']
+
+ - name: Ios_snmp_server overridden - assert before
+ ansible.builtin.assert:
+ that:
+ - overridden['before'] == result['before']
+
+ - name: Ios_snmp_server overridden - assert after
+ ansible.builtin.assert:
+ that:
+ - overridden['after'] == result['after']
+
+ - name: Ios_snmp_server overridden - play (idempotent)
+ register: result
+ cisco.ios.ios_snmp_server: *id001
+ - name: Ios_snmp_server overridden - assert above task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tests/cli/parsed.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tests/cli/parsed.yaml
new file mode 100644
index 000000000..acf3de2b1
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tests/cli/parsed.yaml
@@ -0,0 +1,14 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_snmp_server parsed integration tests on connection={{ ansible_connection }}
+
+- name: Ios_snmp_server parsed - play
+ register: result
+ cisco.ios.ios_snmp_server:
+ running_config: "{{ lookup('file', '_parsed.cfg') }}"
+ state: parsed
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - parsed['config'] == result['parsed']
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tests/cli/rendered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tests/cli/rendered.yaml
new file mode 100644
index 000000000..f260033ea
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/tests/cli/rendered.yaml
@@ -0,0 +1,32 @@
+---
+- ansible.builtin.debug:
+ msg: Start ios_snmp_server rendered integration tests ansible_connection={{ ansible_connection }}
+
+- block:
+ - name: Ios_snmp_server render - play
+ register: result
+ cisco.ios.ios_snmp_server:
+ config:
+ communities:
+ - acl_v4: test_Acl
+ name: integrationComm
+ rw: true
+ contact: "contact updated using play"
+ inform:
+ pending: 2
+ ip:
+ dscp: 2
+ location: "location entry for snmp"
+ packet_size: 500
+ system_shutdown: true
+ engine_id:
+ - id: AB0C5342FF0F
+ remote:
+ host: 192.0.2.12
+ udp_port: 25
+ state: rendered
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - result.rendered == rendered['commands']
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/vars/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/vars/main.yaml
new file mode 100644
index 000000000..8d3e4739b
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_snmp_server/vars/main.yaml
@@ -0,0 +1,132 @@
+---
+merged:
+ commands:
+ - snmp-server host 192.0.2.10 informs version 2c integrationComm isis
+ after:
+ communities:
+ - acl_v4: test_Acl
+ name: integrationComm
+ rw: true
+ contact: "contact updated using play"
+ inform:
+ pending: 2
+ ip:
+ dscp: 2
+ location: "location entry for snmp"
+ packet_size: 500
+ system_shutdown: true
+ engine_id:
+ - id: AB0C5342FF0F
+ remote:
+ host: 192.0.2.12
+ udp_port: 25
+ hosts:
+ - community_string: integrationComm
+ host: 192.0.2.10
+ informs: true
+ traps:
+ - isis
+ version: 2c
+
+overridden:
+ before:
+ communities:
+ - acl_v4: test_Acl
+ name: integrationComm
+ rw: true
+ contact: "contact updated using play"
+ inform:
+ pending: 2
+ ip:
+ dscp: 2
+ location: "location entry for snmp"
+ packet_size: 500
+ system_shutdown: true
+ engine_id:
+ - id: AB0C5342FF0F
+ remote:
+ host: 192.0.2.12
+ udp_port: 25
+ commands:
+ - no snmp-server contact contact updated using play
+ - no snmp-server inform pending 2
+ - no snmp-server ip dscp 2
+ - no snmp-server system-shutdown
+ - no snmp-server engineID remote 192.0.2.12 udp-port 25 AB0C5342FF0F
+ - snmp-server community communityOvverriden rw acl_uq
+ - no snmp-server community integrationComm rw test_Acl
+ after:
+ location: "location entry for snmp"
+ packet_size: 500
+ communities:
+ - acl_v4: acl_uq
+ name: communityOvverriden
+ rw: true
+
+deleted:
+ before:
+ communities:
+ - acl_v4: test_Acl
+ name: integrationComm
+ rw: true
+ contact: "contact updated using play"
+ inform:
+ pending: 2
+ ip:
+ dscp: 2
+ location: "location entry for snmp"
+ packet_size: 500
+ system_shutdown: true
+ engine_id:
+ - id: AB0C5342FF0F
+ remote:
+ host: 192.0.2.12
+ udp_port: 25
+ commands:
+ - no snmp-server contact contact updated using play
+ - no snmp-server inform pending 2
+ - no snmp-server ip dscp 2
+ - no snmp-server location location entry for snmp
+ - no snmp-server packetsize 500
+ - no snmp-server system-shutdown
+ - no snmp-server engineID remote 192.0.2.12 udp-port 25 AB0C5342FF0F
+ - no snmp-server community integrationComm rw test_Acl
+
+parsed:
+ config:
+ engine_id:
+ - id: AB0C5342FAAA
+ remote:
+ host: 192.0.2.1
+ udp_port: 22
+
+gathered:
+ config:
+ communities:
+ - acl_v4: test_Acl
+ name: integrationComm
+ rw: true
+ contact: "contact updated using play"
+ inform:
+ pending: 2
+ ip:
+ dscp: 2
+ location: "location entry for snmp"
+ packet_size: 500
+ system_shutdown: true
+ engine_id:
+ - id: AB0C5342FF0F
+ remote:
+ host: 192.0.2.12
+ udp_port: 25
+
+rendered:
+ commands:
+ - snmp-server contact contact updated using play
+ - snmp-server inform pending 2
+ - snmp-server ip dscp 2
+ - snmp-server location location entry for snmp
+ - snmp-server packetsize 500
+ - snmp-server system-shutdown
+ - snmp-server engineID remote 192.0.2.12 udp-port 25 AB0C5342FF0F
+ - snmp-server community integrationComm rw test_Acl
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/defaults/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/defaults/main.yaml
new file mode 100644
index 000000000..164afead2
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/meta/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/meta/main.yaml
new file mode 100644
index 000000000..23d65c7ef
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/meta/main.yaml
@@ -0,0 +1,2 @@
+---
+dependencies: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tasks/cli.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tasks/cli.yaml
new file mode 100644
index 000000000..6f505600c
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tasks/cli.yaml
@@ -0,0 +1,21 @@
+---
+- name: Collect all CLI test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+ delegate_to: localhost
+
+- name: Run test case (connection=ansible.netcommon.network_cli)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.network_cli
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tasks/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tasks/main.yaml
new file mode 100644
index 000000000..6a03f1915
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tasks/main.yaml
@@ -0,0 +1,5 @@
+---
+- name: Main task for static_routes module
+ ansible.builtin.include_tasks: cli.yaml
+ tags:
+ - network_cli
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/_add_extra_ipv6_data.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/_add_extra_ipv6_data.yaml
new file mode 100644
index 000000000..73e3d8d38
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/_add_extra_ipv6_data.yaml
@@ -0,0 +1,6 @@
+---
+- name: Add ipv6 extra data
+ vars:
+ lines: "ipv6 unicast-routing\nipv6 router eigrp 10\n"
+ ansible.netcommon.cli_config:
+ config: "{{ lines }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/_initial_setup_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/_initial_setup_config.yaml
new file mode 100644
index 000000000..a20c027ff
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/_initial_setup_config.yaml
@@ -0,0 +1,9 @@
+---
+- name: Initial setup configuration
+ vars:
+ lines:
+ "vrf definition ansible_temp_vrf\naddress-family ipv4\naddress-family ipv6\nip route vrf ansible_temp_vrf 192.0.2.0 255.255.255.0 192.0.2.1 tag 50 name test_vrf track 150\n\
+ ip route 198.51.100.0 255.255.255.0 198.51.101.3 name route_3\nip route 198.51.100.0 255.255.255.0 198.51.101.2 30 name route_2\nip route 198.51.100.0 255.255.255.0\
+ \ 198.51.101.1 110 tag 40 name route_1 multicast\nipv6 route 2001:DB8:0:3::/64 2001:DB8:0:3::2 tag 105 name test_v6\nipv6 route vrf ansible_temp_vrf 2001:DB8:0:4::/64 2001:DB8:0:4::2 name test_v6_vrf tag 115"
+ ansible.netcommon.cli_config:
+ config: "{{ lines }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/_populate_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/_populate_config.yaml
new file mode 100644
index 000000000..f81c5c6c7
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/_populate_config.yaml
@@ -0,0 +1,9 @@
+---
+- name: Populate configuration
+ vars:
+ lines:
+ "ip route vrf ansible_temp_vrf 192.0.2.0 255.255.255.0 192.0.2.1 tag 50 name test_vrf track 150\nip route 198.51.100.0 255.255.255.0 198.51.101.3 name\
+ \ route_3\nip route 198.51.100.0 255.255.255.0 198.51.101.2 30 name route_2\nip route 198.51.100.0 255.255.255.0 198.51.101.1 110 tag 40 name route_1 multicast\n\
+ ipv6 route 2001:DB8:0:3::/64 2001:DB8:0:3::2 tag 105 name test_v6\nipv6 route vrf ansible_temp_vrf 2001:DB8:0:4::/64 2001:DB8:0:4::2 name test_v6_vrf tag 115"
+ ansible.netcommon.cli_config:
+ config: "{{ lines }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/_remove_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/_remove_config.yaml
new file mode 100644
index 000000000..dabc804ff
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/_remove_config.yaml
@@ -0,0 +1,9 @@
+---
+- name: Remove configuration
+ vars:
+ lines:
+ "no ip route vrf ansible_temp_vrf 192.0.2.0 255.255.255.0 192.0.2.1 tag 50 name test_vrf track 150\nno ip route 198.51.100.0 255.255.255.0 198.51.101.3\
+ \ name route_3\nno ip route 198.51.100.0 255.255.255.0 198.51.101.2 30 name route_2\nno ip route 198.51.100.0 255.255.255.0 198.51.101.1 110 tag 40 name route_1\
+ \ multicast\nno ipv6 route 2001:DB8:0:3::/64 2001:DB8:0:3::2 tag 105 name test_v6\nno ipv6 route vrf ansible_temp_vrf 2001:DB8:0:4::/64 2001:DB8:0:4::2 name test_v6_vrf tag 115\nno vrf definition ansible_temp_vrf\n"
+ ansible.netcommon.cli_config:
+ config: "{{ lines }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/_remove_extra_ipv6_data.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/_remove_extra_ipv6_data.yaml
new file mode 100644
index 000000000..c79257fca
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/_remove_extra_ipv6_data.yaml
@@ -0,0 +1,6 @@
+---
+- name: Remove ipv6 extra data
+ vars:
+ lines: "no ipv6 router eigrp 10\nno ipv6 unicast-routing\n"
+ ansible.netcommon.cli_config:
+ config: "{{ lines }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/deleted.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/deleted.yaml
new file mode 100644
index 000000000..819daf00f
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/deleted.yaml
@@ -0,0 +1,72 @@
+---
+- ansible.builtin.debug:
+ msg: Start Deleted integration state for ios_static_routes ansible_connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+- ansible.builtin.include_tasks: _initial_setup_config.yaml
+
+- block:
+ - name: Delete attributes of provided configured interfaces
+ register: result
+ cisco.ios.ios_static_routes: &id001
+ config:
+ - vrf: ansible_temp_vrf
+ address_families:
+ - afi: ipv4
+ routes:
+ - dest: 192.0.2.0/24
+ next_hops:
+ - forward_router_address: 192.0.2.1
+ name: test_vrf
+ tag: 50
+ track: 150
+ - afi: ipv6
+ routes:
+ - dest: 2001:DB8:0:4::/64
+ next_hops:
+ - forward_router_address: 2001:DB8:0:4::2
+ name: test_v6_vrf
+ tag: 115
+ - address_families:
+ - afi: ipv4
+ routes:
+ - dest: 198.51.100.0/24
+ next_hops:
+ - forward_router_address: 198.51.101.1
+ name: route_1
+ distance_metric: 110
+ tag: 40
+ multicast: true
+ - forward_router_address: 198.51.101.2
+ name: route_2
+ distance_metric: 30
+ - forward_router_address: 198.51.101.3
+ name: route_3
+ - afi: ipv6
+ routes:
+ - dest: 2001:DB8:0:3::/64
+ next_hops:
+ - forward_router_address: 2001:DB8:0:3::2
+ name: test_v6
+ tag: 105
+ state: deleted
+
+ - ansible.builtin.assert:
+ that:
+ - result.commands|length == 6
+ - result.changed == true
+ - result.commands|symmetric_difference(deleted.commands) == []
+
+ - name: Delete attributes of all configured interfaces (idempotent)
+ register: result
+ cisco.ios.ios_static_routes: *id001
+
+ - name: Assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result.commands|length == 0
+ - result.changed == false
+
+ always:
+ - ansible.builtin.include_tasks: _populate_config.yaml
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/empty_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/empty_config.yaml
new file mode 100644
index 000000000..453dfa549
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/empty_config.yaml
@@ -0,0 +1,58 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_static_routes empty_config.yaml integration tests on connection={{ ansible_connection }}
+
+- name: Merged with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_static_routes:
+ config:
+ state: merged
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state merged'
+
+- name: Replaced with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_static_routes:
+ config:
+ state: replaced
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state replaced'
+
+- name: Overridden with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_static_routes:
+ config:
+ state: overridden
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state overridden'
+
+- name: Rendered with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_static_routes:
+ config:
+ state: rendered
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state rendered'
+
+- name: Parsed with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_static_routes:
+ running_config:
+ state: parsed
+
+- ansible.builtin.assert:
+ that:
+ - result.msg == 'value of running_config parameter must not be empty for state parsed'
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/gathered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/gathered.yaml
new file mode 100644
index 000000000..311d25330
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/gathered.yaml
@@ -0,0 +1,21 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_static_routes gathered integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- ansible.builtin.include_tasks: _initial_setup_config.yaml
+
+- block:
+ - name: Gather the provided configuration with the existing running configuration
+ register: result
+ cisco.ios.ios_static_routes:
+ config:
+ state: gathered
+
+ - name: Assert that gathered dicts was correctly generated
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/merged.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/merged.yaml
new file mode 100644
index 000000000..9ab38002c
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/merged.yaml
@@ -0,0 +1,82 @@
+---
+- ansible.builtin.debug:
+ msg: START Merged ios_static_routes state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+- ansible.builtin.include_tasks: _initial_setup_config.yaml
+- ansible.builtin.include_tasks: _add_extra_ipv6_data.yaml
+
+- block:
+ - name: Merge provided configuration with device configuration
+ register: result
+ cisco.ios.ios_static_routes: &id001
+ config:
+ - vrf: ansible_temp_vrf
+ address_families:
+ - afi: ipv4
+ routes:
+ - dest: 192.0.2.0/24
+ next_hops:
+ - forward_router_address: 192.0.2.1
+ name: merged_vrf
+ tag: 50
+ track: 150
+ - dest: 192.51.110.0/32
+ next_hops:
+ - distance_metric: 10
+ forward_router_address: 192.51.111.1
+ interface: GigabitEthernet3
+ name: partner_vrf
+ - afi: ipv6
+ routes:
+ - dest: 2001:DB8:0:4::/64
+ next_hops:
+ - forward_router_address: 2001:DB8:0:4::2
+ name: merged_v6_vrf
+ tag: 115
+
+ - address_families:
+ - afi: ipv4
+ routes:
+ - dest: 198.51.100.0/24
+ next_hops:
+ - forward_router_address: 198.51.101.1
+ name: merged_route_1
+ distance_metric: 110
+ tag: 40
+ multicast: true
+
+ - forward_router_address: 198.51.101.2
+ name: merged_route_2
+ distance_metric: 30
+
+ - forward_router_address: 198.51.101.3
+ name: merged_route_3
+
+ - afi: ipv6
+ routes:
+ - dest: 2001:DB8:0:3::/64
+ next_hops:
+ - forward_router_address: 2001:DB8:0:3::2
+ name: merged_v6
+ tag: 105
+ state: merged
+
+ - ansible.builtin.assert:
+ that:
+ - result.commands|length == 7
+ - result.changed == true
+ - result.commands|symmetric_difference(merged.commands) == []
+
+ - name: Merge provided configuration with device configuration (idempotent)
+ register: result
+ cisco.ios.ios_static_routes: *id001
+ - name: Assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result.commands|length == 0
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _populate_config.yaml
+ - ansible.builtin.include_tasks: _remove_config.yaml
+ - ansible.builtin.include_tasks: _remove_extra_ipv6_data.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/overridden.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/overridden.yaml
new file mode 100644
index 000000000..2fbba47d1
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/overridden.yaml
@@ -0,0 +1,65 @@
+---
+- ansible.builtin.debug:
+ msg: START Overridden ios_static_routes state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- ansible.builtin.include_tasks: _initial_setup_config.yaml
+
+- block:
+ - name: Override device configuration of all interfaces with provided configuration
+ register: result
+ cisco.ios.ios_static_routes: &id001
+ config:
+ - vrf: ansible_temp_vrf
+ address_families:
+ - afi: ipv4
+ routes:
+ - dest: 192.0.2.0/24
+ next_hops:
+ - forward_router_address: 192.0.2.1
+ name: override_vrf
+ tag: 50
+ track: 150
+ - afi: ipv6
+ routes:
+ - dest: 2001:DB8:0:4::/64
+ next_hops:
+ - forward_router_address: 2001:DB8:0:4::2
+ name: override_v6_vrf
+ tag: 135
+
+ - address_families:
+ - afi: ipv4
+ routes:
+ - dest: 198.51.100.0/24
+ next_hops:
+ - forward_router_address: 198.51.101.3
+ name: override_route
+
+ - afi: ipv6
+ routes:
+ - dest: 2001:DB8:0:3::/64
+ next_hops:
+ - forward_router_address: 2001:DB8:0:3::2
+ name: override_v6
+ tag: 175
+ state: overridden
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - result.commands|symmetric_difference(overridden.commands) == []
+
+ - name: Override device configuration of all interfaces with provided configuration (idempotent)
+ register: result
+ cisco.ios.ios_static_routes: *id001
+ - name: Assert that task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result.commands|length == 0
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _populate_config.yaml
+
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/rendered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/rendered.yaml
new file mode 100644
index 000000000..e511a2ce0
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/rendered.yaml
@@ -0,0 +1,63 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_static_routes rendered integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- ansible.builtin.include_tasks: _initial_setup_config.yaml
+
+- block:
+ - name: Rendered the provided configuration with the existing running configuration
+ register: result
+ cisco.ios.ios_static_routes:
+ config:
+ - vrf: ansible_temp_vrf
+ address_families:
+ - afi: ipv4
+ routes:
+ - dest: 192.0.2.0/24
+ next_hops:
+ - forward_router_address: 192.0.2.1
+ name: test_vrf
+ tag: 50
+ track: 150
+ - afi: ipv6
+ routes:
+ - dest: 2001:DB8:0:4::/64
+ next_hops:
+ - forward_router_address: 2001:DB8:0:4::2
+ name: test_v6_vrf
+ tag: 115
+ - address_families:
+ - afi: ipv4
+ routes:
+ - dest: 198.51.100.0/24
+ next_hops:
+ - forward_router_address: 198.51.101.1
+ name: route_1
+ distance_metric: 110
+ tag: 40
+ multicast: true
+
+ - forward_router_address: 198.51.101.2
+ name: route_2
+ distance_metric: 30
+
+ - forward_router_address: 198.51.101.3
+ name: route_3
+
+ - afi: ipv6
+ routes:
+ - dest: 2001:DB8:0:3::/64
+ next_hops:
+ - forward_router_address: 2001:DB8:0:3::2
+ name: test_v6
+ tag: 105
+ state: rendered
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - result.rendered|symmetric_difference(rendered.commands) == []
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/replaced.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/replaced.yaml
new file mode 100644
index 000000000..329ac4aa7
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/replaced.yaml
@@ -0,0 +1,67 @@
+---
+- ansible.builtin.debug:
+ msg: START Replaced ios_static_routes state for integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- ansible.builtin.include_tasks: _initial_setup_config.yaml
+
+- block:
+ - name: Replaces device configuration of listed interfaces with provided configuration
+ register: result
+ cisco.ios.ios_static_routes: &id001
+ config:
+ - vrf: ansible_temp_vrf
+ address_families:
+ - afi: ipv4
+ routes:
+ - dest: 192.0.2.0/24
+ next_hops:
+ - forward_router_address: 192.0.2.1
+ name: replaced_vrf
+ tag: 75
+ track: 155
+ - afi: ipv6
+ routes:
+ - dest: 2001:DB8:0:4::/64
+ next_hops:
+ - forward_router_address: 2001:DB8:0:4::2
+ name: replaced_v6_vrf
+ tag: 115
+ - address_families:
+ - afi: ipv4
+ routes:
+ - dest: 198.51.100.0/24
+ next_hops:
+ - forward_router_address: 198.51.101.1
+ name: replaced_route
+ distance_metric: 175
+ tag: 70
+ multicast: true
+
+ - afi: ipv6
+ routes:
+ - dest: 2001:DB8:0:3::/64
+ next_hops:
+ - forward_router_address: 2001:DB8:0:3::2
+ name: replaced_v6
+ tag: 110
+ state: replaced
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - result.commands|symmetric_difference(replaced.commands) == []
+
+ - name: Replaces device configuration of listed interfaces with provided configuration (idempotent)
+ register: result
+ cisco.ios.ios_static_routes: *id001
+ - name: Assert that task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result.commands|length == 0
+ - result['changed'] == false
+ always:
+ - ansible.builtin.include_tasks: _populate_config.yaml
+
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/rtt.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/rtt.yaml
new file mode 100644
index 000000000..6a99e7d35
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/tests/cli/rtt.yaml
@@ -0,0 +1,79 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_static_routes round trip integration tests on connection={{ ansible_connection }}
+
+- ansible.builtin.include_tasks: _remove_config.yaml
+
+- block:
+ - name: Apply the provided configuration (base config)
+ register: base_config
+ cisco.ios.ios_static_routes:
+ config:
+ - vrf: ansible_temp_vrf
+ address_families:
+ - afi: ipv4
+ routes:
+ - dest: 192.0.2.0/24
+ next_hops:
+ - forward_router_address: 192.0.2.1
+ name: rtt_vrf
+ tag: 50
+ track: 150
+
+ - address_families:
+ - afi: ipv4
+ routes:
+ - dest: 198.51.100.0/24
+ next_hops:
+ - forward_router_address: 198.51.101.1
+ name: rtt_route_1
+ distance_metric: 110
+ tag: 40
+ multicast: true
+ state: merged
+
+ - name: Gather static routes facts
+ cisco.ios.ios_facts:
+ gather_subset:
+ - "!all"
+ - "!min"
+ gather_network_resources:
+ - static_routes
+
+ - name: Apply the configuration which need to be reverted
+ register: result
+ cisco.ios.ios_static_routes:
+ config:
+ - vrf: ansible_temp_vrf
+ address_families:
+ - afi: ipv4
+ routes:
+ - dest: 192.0.2.0/24
+ next_hops:
+ - forward_router_address: 192.0.2.12
+ name: new_rtt_vrf
+ tag: 10
+ track: 150
+ state: overridden
+
+ - ansible.builtin.assert:
+ that:
+ - result.commands|length == 2
+ - result.changed == true
+ - result.commands|symmetric_difference(rtt.override_commands) == []
+
+ - name: Revert back to base configuration using facts round trip
+ register: revert
+ cisco.ios.ios_static_routes:
+ config: "{{ ansible_facts['network_resources']['static_routes'] }}"
+ state: overridden
+
+ - ansible.builtin.assert:
+ that:
+ - revert.commands|length == 1
+ - revert.changed == true
+ - revert.commands|symmetric_difference(rtt.override_revert_commands) == []
+ always:
+ - ansible.builtin.include_tasks: _populate_config.yaml
+
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/vars/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/vars/main.yaml
new file mode 100644
index 000000000..b682a6eea
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_static_routes/vars/main.yaml
@@ -0,0 +1,89 @@
+---
+deleted:
+ commands:
+ - no ip route vrf ansible_temp_vrf 192.0.2.0 255.255.255.0 192.0.2.1 tag 50 name test_vrf track 150
+ - no ipv6 route vrf ansible_temp_vrf 2001:DB8:0:4::/64 2001:DB8:0:4::2 tag 115 name test_v6_vrf
+ - no ip route 198.51.100.0 255.255.255.0 198.51.101.1 110 tag 40 name route_1 multicast
+ - no ip route 198.51.100.0 255.255.255.0 198.51.101.3 name route_3
+ - no ip route 198.51.100.0 255.255.255.0 198.51.101.2 30 name route_2
+ - no ipv6 route 2001:DB8:0:3::/64 2001:DB8:0:3::2 tag 105 name test_v6
+merged:
+ commands:
+ - ip route 198.51.100.0 255.255.255.0 198.51.101.3 name merged_route_3
+ - ip route 198.51.100.0 255.255.255.0 198.51.101.2 30 name merged_route_2
+ - ip route 198.51.100.0 255.255.255.0 198.51.101.1 110 tag 40 name merged_route_1 multicast
+ - ipv6 route 2001:DB8:0:3::/64 2001:DB8:0:3::2 tag 105 name merged_v6
+ - ip route vrf ansible_temp_vrf 192.0.2.0 255.255.255.0 192.0.2.1 tag 50 name merged_vrf track 150
+ - ip route vrf ansible_temp_vrf 192.51.110.0 255.255.255.255 GigabitEthernet3 192.51.111.1 10 name partner_vrf
+ - ipv6 route vrf ansible_temp_vrf 2001:DB8:0:4::/64 2001:DB8:0:4::2 tag 115 name merged_v6_vrf
+replaced:
+ commands:
+ - ip route vrf ansible_temp_vrf 192.0.2.0 255.255.255.0 192.0.2.1 tag 75 name replaced_vrf track 155
+ - ipv6 route vrf ansible_temp_vrf 2001:DB8:0:4::/64 2001:DB8:0:4::2 tag 115 name replaced_v6_vrf
+ - ip route 198.51.100.0 255.255.255.0 198.51.101.1 175 tag 70 name replaced_route multicast
+ - no ip route 198.51.100.0 255.255.255.0 198.51.101.3 name route_3
+ - no ip route 198.51.100.0 255.255.255.0 198.51.101.2 30 name route_2
+ - ipv6 route 2001:DB8:0:3::/64 2001:DB8:0:3::2 tag 110 name replaced_v6
+overridden:
+ commands:
+ - ip route vrf ansible_temp_vrf 192.0.2.0 255.255.255.0 192.0.2.1 tag 50 name override_vrf track 150
+ - ipv6 route vrf ansible_temp_vrf 2001:DB8:0:4::/64 2001:DB8:0:4::2 tag 135 name override_v6_vrf
+ - ip route 198.51.100.0 255.255.255.0 198.51.101.3 name override_route
+ - no ip route 198.51.100.0 255.255.255.0 198.51.101.2 30 name route_2
+ - no ip route 198.51.100.0 255.255.255.0 198.51.101.1 110 tag 40 name route_1 multicast
+ - ipv6 route 2001:DB8:0:3::/64 2001:DB8:0:3::2 tag 175 name override_v6
+rendered:
+ commands:
+ - ip route vrf ansible_temp_vrf 192.0.2.0 255.255.255.0 192.0.2.1 tag 50 name test_vrf track 150
+ - ipv6 route vrf ansible_temp_vrf 2001:DB8:0:4::/64 2001:DB8:0:4::2 tag 115 name test_v6_vrf
+ - ip route 198.51.100.0 255.255.255.0 198.51.101.1 110 tag 40 name route_1 multicast
+ - ip route 198.51.100.0 255.255.255.0 198.51.101.2 30 name route_2
+ - ip route 198.51.100.0 255.255.255.0 198.51.101.3 name route_3
+ - ipv6 route 2001:DB8:0:3::/64 2001:DB8:0:3::2 tag 105 name test_v6
+gathered:
+ config:
+ - address_families:
+ - afi: ipv4
+ routes:
+ - dest: 192.0.2.0/24
+ next_hops:
+ - forward_router_address: 192.0.2.1
+ name: test_vrf
+ tag: 50
+ track: 150
+ - afi: ipv6
+ routes:
+ - dest: 2001:DB8:0:4::/64
+ next_hops:
+ - forward_router_address: 2001:DB8:0:4::2
+ name: test_v6_vrf
+ tag: 115
+ vrf: ansible_temp_vrf
+ - address_families:
+ - afi: ipv6
+ routes:
+ - dest: 2001:DB8:0:3::/64
+ next_hops:
+ - forward_router_address: 2001:DB8:0:3::2
+ name: test_v6
+ tag: 105
+ - afi: ipv4
+ routes:
+ - dest: 198.51.100.0/24
+ next_hops:
+ - distance_metric: 110
+ forward_router_address: 198.51.101.1
+ multicast: true
+ name: route_1
+ tag: 40
+ - distance_metric: 30
+ forward_router_address: 198.51.101.2
+ name: route_2
+ - forward_router_address: 198.51.101.3
+ name: route_3
+rtt:
+ override_commands:
+ - ip route vrf ansible_temp_vrf 192.0.2.0 255.255.255.0 192.0.2.12 tag 10 name new_rtt_vrf track 150
+ - no ip route 198.51.100.0 255.255.255.0 198.51.101.1 110 tag 40 name rtt_route_1 multicast
+ override_revert_commands:
+ - ip route 198.51.100.0 255.255.255.0 198.51.101.1 110 tag 40 name rtt_route_1 multicast
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_system/defaults/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_system/defaults/main.yaml
new file mode 100644
index 000000000..5f709c5aa
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_system/defaults/main.yaml
@@ -0,0 +1,2 @@
+---
+testcase: "*"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_system/meta/main.yml b/ansible_collections/cisco/ios/tests/integration/targets/ios_system/meta/main.yml
new file mode 100644
index 000000000..ab3ad91bc
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_system/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - prepare_ios_tests
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_system/tasks/cli.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_system/tasks/cli.yaml
new file mode 100644
index 000000000..cd8c04990
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_system/tasks/cli.yaml
@@ -0,0 +1,18 @@
+---
+- name: Collect all CLI test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: Run test cases (connection=ansible.netcommon.network_cli)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+ tags: network_cli
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_system/tasks/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_system/tasks/main.yaml
new file mode 100644
index 000000000..faed4bfaf
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_system/tasks/main.yaml
@@ -0,0 +1,3 @@
+---
+- name: Main task for systems module
+ ansible.builtin.include_tasks: cli.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_system/tests/cli/set_domain_list.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_system/tests/cli/set_domain_list.yaml
new file mode 100644
index 000000000..b966db84d
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_system/tests/cli/set_domain_list.yaml
@@ -0,0 +1,111 @@
+---
+- ansible.builtin.debug: msg="START cli/set_domain_search.yaml on connection={{ ansible_connection }}"
+
+- name: Setup
+ cisco.ios.ios_config:
+ lines:
+ - no ip domain list ansible.com
+ - no ip domain list redhat.com
+ match: none
+
+- name: Configure domain_search
+ register: result
+ cisco.ios.ios_system:
+ domain_search:
+ - ansible.com
+ - redhat.com
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - "'ip domain list ansible.com' in result.commands"
+ - "'ip domain list redhat.com' in result.commands"
+
+- name: Verify domain_search
+ register: result
+ cisco.ios.ios_system:
+ domain_search:
+ - ansible.com
+ - redhat.com
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+- name: Remove one entry
+ register: result
+ cisco.ios.ios_system:
+ domain_search:
+ - ansible.com
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - "'no ip domain list redhat.com' in result.commands"
+
+- name: Verify remove one entry
+ register: result
+ cisco.ios.ios_system:
+ domain_search:
+ - ansible.com
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+- name: Add one entry
+ register: result
+ cisco.ios.ios_system:
+ domain_search:
+ - ansible.com
+ - redhat.com
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - "'ip domain list redhat.com' in result.commands"
+
+- name: Verify add one entry
+ register: result
+ cisco.ios.ios_system:
+ domain_search:
+ - ansible.com
+ - redhat.com
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+- name: Add and remove one entry
+ register: result
+ cisco.ios.ios_system:
+ domain_search:
+ - ansible.com
+ - eng.ansible.com
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - "'no ip domain list redhat.com' in result.commands"
+ - "'ip domain list eng.ansible.com' in result.commands"
+ - result.commands|length == 2
+
+- name: Verify add and remove one entry
+ register: result
+ cisco.ios.ios_system:
+ domain_search:
+ - ansible.com
+ - eng.ansible.com
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+- name: Teardown
+ cisco.ios.ios_config:
+ lines:
+ - no ip domain list ansible.com
+ - no ip domain list redhat.com
+ - no ip domain list eng.ansible.com
+ match: none
+- ansible.builtin.debug: msg="END cli/set_domain_search.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_system/tests/cli/set_domain_name.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_system/tests/cli/set_domain_name.yaml
new file mode 100644
index 000000000..9bc8db2a6
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_system/tests/cli/set_domain_name.yaml
@@ -0,0 +1,32 @@
+---
+- ansible.builtin.debug: msg="START cli/set_domain_name.yaml on connection={{ ansible_connection }}"
+
+- name: Setup
+ cisco.ios.ios_config:
+ lines: no ip domain name
+ match: none
+
+- name: Configure domain_name
+ register: result
+ cisco.ios.ios_system:
+ domain_name: eng.ansible.com
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+
+- name: Verify domain_name
+ register: result
+ cisco.ios.ios_system:
+ domain_name: eng.ansible.com
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+- name: Teardown
+ cisco.ios.ios_config:
+ lines: no ip domain name
+ match: none
+
+- ansible.builtin.debug: msg="END cli/set_domain_name.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_system/tests/cli/set_hostname.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_system/tests/cli/set_hostname.yaml
new file mode 100644
index 000000000..563a67d55
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_system/tests/cli/set_hostname.yaml
@@ -0,0 +1,32 @@
+---
+- ansible.builtin.debug: msg="START cli/set_hostname.yaml on connection={{ ansible_connection }}"
+
+- name: Setup
+ cisco.ios.ios_config:
+ lines: hostname switch
+ match: none
+
+- name: Configure hostname
+ register: result
+ cisco.ios.ios_system:
+ hostname: foo
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+
+- name: Verify hostname
+ register: result
+ cisco.ios.ios_system:
+ hostname: foo
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+- name: Teardown
+ cisco.ios.ios_config:
+ lines: hostname {{ inventory_hostname }}
+ match: none
+
+- ansible.builtin.debug: msg="END cli/set_hostname.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_system/tests/cli/set_lookup_source.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_system/tests/cli/set_lookup_source.yaml
new file mode 100644
index 000000000..6c01b30ab
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_system/tests/cli/set_lookup_source.yaml
@@ -0,0 +1,58 @@
+---
+- ansible.builtin.debug: msg="START cli/set_lookup_source.yaml on connection={{ ansible_connection }}"
+
+- name: Setup
+ cisco.ios.ios_config:
+ lines:
+ - no ip domain lookup source-interface Loopback888
+ - vrf definition ansible
+ match: none
+
+- name: Configure lookup_source
+ register: result
+ cisco.ios.ios_system:
+ lookup_source: Loopback888
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - "'ip domain lookup source-interface Loopback888' in result.commands"
+
+- name: Verify lookup_source
+ register: result
+ cisco.ios.ios_system:
+ lookup_source: Loopback888
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+- name: Disable lookup_source
+ register: result
+ cisco.ios.ios_system:
+ lookup_enabled: false
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - "'no ip domain lookup' in result.commands"
+
+- name: Disable lookup_source
+ register: result
+ cisco.ios.ios_system:
+ lookup_enabled: true
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - "'ip domain lookup' in result.commands"
+
+- name: Teardown
+ ignore_errors: true
+ cisco.ios.ios_config:
+ lines:
+ - no ip domain lookup source-interface Loopback888
+ - no vrf definition ansible
+ match: none
+
+- ansible.builtin.debug: msg="END cli/set_lookup_source.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_system/tests/cli/set_name_servers.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_system/tests/cli/set_name_servers.yaml
new file mode 100644
index 000000000..56f169ad5
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_system/tests/cli/set_name_servers.yaml
@@ -0,0 +1,57 @@
+---
+- ansible.builtin.debug: msg="START cli/set_name_servers.yaml on connection={{ ansible_connection }}"
+
+- name: Setup
+ cisco.ios.ios_config:
+ lines:
+ - no ip name-server
+ match: none
+
+- name: Configure name_servers
+ register: result
+ cisco.ios.ios_system:
+ name_servers:
+ - 192.0.2.1
+ - 192.0.2.2
+ - 192.0.2.3
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - result.commands|length == 3
+ - "'ip name-server 192.0.2.1' in result.commands"
+ - "'ip name-server 192.0.2.2' in result.commands"
+ - "'ip name-server 192.0.2.3' in result.commands"
+
+- name: Verify name_servers
+ register: result
+ cisco.ios.ios_system:
+ name_servers:
+ - 192.0.2.1
+ - 192.0.2.2
+ - 192.0.2.3
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+
+- name: Remove one
+ register: result
+ cisco.ios.ios_system:
+ name_servers:
+ - 192.0.2.1
+ - 192.0.2.2
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - result.commands|length == 1
+ - "'no ip name-server 192.0.2.3' in result.commands"
+
+- name: Teardown
+ cisco.ios.ios_config:
+ lines:
+ - no ip name-server
+ match: none
+
+- ansible.builtin.debug: msg="END cli/set_name_servers.yaml on connection={{ ansible_connection }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_user/defaults/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_user/defaults/main.yaml
new file mode 100644
index 000000000..5f709c5aa
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_user/defaults/main.yaml
@@ -0,0 +1,2 @@
+---
+testcase: "*"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_user/files/test_rsa b/ansible_collections/cisco/ios/tests/integration/targets/ios_user/files/test_rsa
new file mode 100644
index 000000000..9fdc8c3af
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_user/files/test_rsa
@@ -0,0 +1,27 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIEpAIBAAKCAQEAseTsv6oTMJbsRgOSaNEVBlsqE4tKI2MBEOHzTlUnE3GBRtZi
+xlUlF9rZcjtk+hTIz3N3UrLtxMnWqv0YGM8tXZTcz50M9ANDE/oNXrXkkMKX5WWr
+OcgDCAAZYSVJ/vIt/xZkYteax6zMZQqEBIc/rKo8KuxKZTUMqj0GHkCQbA/o7lBQ
+hpdUZxtU/Y2uc9tXVhav3jVzTFUOdwZrCAJghdCCweJfwAj1DdHODip+/hNu+3Sk
+DNl0bdhWoNNnUFCYPOUK2B79OMg2+r5bwH7xgURIoTuc54HlGectJpIzI7GB6VfL
+UCsJn0uQ7HwX7XAtZjhJWP8dKPd1FuUgg5M8MwIDAQABAoIBACfBVz9GDN/Q+qBy
+7+dIwoAXI4IWoMzjtTtGo48f7Iml1hQ0mQJlyNJZ8DpdF6XjuzTRQxtSLVzLFpRD
+13zD4AmH2Qj0ug5WJEl0mkRONfQ76KI1ZFyXXEYPb5yMLssw6CKXqHuGX2q8LTlv
+bi1s5Ef8C1I0WDPh9SCeXp2oJB5h2G+HtCXDyxASK2nAKqhkpQqPhg5Rd50mBOpD
+WE/lor358hU0Aj/qhzjeWKNNK8pgeahXz5anEQZ69TUH102B6bNh8Ao4ZL2j3tr0
+6FbE3ooQT7+zOLm5xOFJ9OnJ2yDVW6Dj1Czllx2vJUcxKsKxaGF76xNCIPiSUUfS
+mnOnEfECgYEA2bBFc9Pb8AI0bZZ8Q6XE7Jqa6BOaLbzyjK6IzdyAV/LKdk3yRfEZ
+Rb2iNy8poBUYBqBUMfRsRVq5dabjYkz9X5e+75S8Lm/qiktlhTpQYWk5q+eBZdPm
+I+dG64Tdyv+Y/NwN4enIsw8LGllY472iUf37ms2+uOA8/BysQ2n7ss0CgYEA0TPD
+IhmLqNhQGkS2GU6tM8G7LyGOaIH3mmyCviYgEauWWw3bn/Hhiq/6tLtQc6pv2nIa
+ifbACnI+GiIoBFwz8ofuFA8dm76uro7o6eWP5iUizoGISYSewCFpcCpp0xn7/FNR
+3RT4YRBMt3yL8J1cVBpPRRbIwp/bZ+pRb0Ggqv8CgYEAoNAFHqHdkhou3N4UgmzN
+YvR7hwIkHbG9hIvS6DECZvYm9upyFZUcVFbYpOekWmv6ybpbOGQWL83rv6w/wfia
+HKofFSHNOojWvL8iCh+gDbYMMp/dCXpWQyOxUn9e0X2saO+vGbr41r5AN4DVl7gZ
+V3THD/75691Lb/tGjq6Wj+kCgYB6ZhadNOUJfMYhGGKSm/2qcobaJH/1lVUQ/Lvi
+FNxeek4WKB1/jz2urxe39oAzrFyVKn1sivoBIqZDFAjlxCyAkhcxlUZ1gTMi3mpX
+rwBqXv/mYtMicH2RW/scrTQNVv6fuwACoepQoADCuhQGS4thiaMngRUlCfKM8gOD
+XJpscQKBgQDIMURtVIV/2ZcGqHv/3G5jsPJPsTycv6YR4gTs5GUBy5If2Rs7DMWE
+pJLIcU+SJhMeVKTZPrePibzCp2+rMSI5pc6T+9LC79RKsfie3UybWfLZrSmtnxJx
+MgC49TR4NFP6yoYJPYiTdRJ/1Bu68WfVafFK86i9MKAI5OU2ba3/Bg==
+-----END RSA PRIVATE KEY-----
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_user/files/test_rsa.pub b/ansible_collections/cisco/ios/tests/integration/targets/ios_user/files/test_rsa.pub
new file mode 100644
index 000000000..e6939a295
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_user/files/test_rsa.pub
@@ -0,0 +1 @@
+ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCx5Oy/qhMwluxGA5Jo0RUGWyoTi0ojYwEQ4fNOVScTcYFG1mLGVSUX2tlyO2T6FMjPc3dSsu3Eydaq/RgYzy1dlNzPnQz0A0MT+g1eteSQwpflZas5yAMIABlhJUn+8i3/FmRi15rHrMxlCoQEhz+sqjwq7EplNQyqPQYeQJBsD+juUFCGl1RnG1T9ja5z21dWFq/eNXNMVQ53BmsIAmCF0ILB4l/ACPUN0c4OKn7+E277dKQM2XRt2Fag02dQUJg85QrYHv04yDb6vlvAfvGBREihO5zngeUZ5y0mkjMjsYHpV8tQKwmfS5DsfBftcC1mOElY/x0o93UW5SCDkzwz ansible_ios_user_test
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_user/meta/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_user/meta/main.yaml
new file mode 100644
index 000000000..ab3ad91bc
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_user/meta/main.yaml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - prepare_ios_tests
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_user/tasks/cli.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_user/tasks/cli.yaml
new file mode 100644
index 000000000..cd8c04990
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_user/tasks/cli.yaml
@@ -0,0 +1,18 @@
+---
+- name: Collect all CLI test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+
+- name: Run test cases (connection=ansible.netcommon.network_cli)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
+ tags: network_cli
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_user/tasks/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_user/tasks/main.yaml
new file mode 100644
index 000000000..5fd964fdf
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_user/tasks/main.yaml
@@ -0,0 +1,3 @@
+---
+- name: Main task for user module
+ ansible.builtin.include_tasks: cli.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_user/tests/cli/auth.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_user/tests/cli/auth.yaml
new file mode 100644
index 000000000..5d42f498e
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_user/tests/cli/auth.yaml
@@ -0,0 +1,100 @@
+---
+- block:
+ - name: Create user with password
+ cisco.ios.ios_user:
+ name: auth_user
+ privilege: 15
+ role: network-operator
+ state: present
+ configured_password: pass123
+
+ - name: Reset connection with {{ ansible_user }}
+ ansible.builtin.meta: reset_connection
+
+ - name: Test login for {{ ansible_user }} user with password
+ ansible.builtin.expect:
+ command:
+ ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_ssh_port|default(22) }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PubkeyAuthentication=no
+ show version
+ responses:
+ (?i)password: pass123
+
+ - name: Reset connection with {{ ansible_user }}
+ ansible.builtin.meta: reset_connection
+
+ - name: Test login with invalid password (should fail)
+ cisco.ios.ios_command:
+ commands:
+ - show version
+ ignore_errors: true
+ register: results
+ vars:
+ ansible_user: auth_user
+ ansible_ssh_password: badpass
+ ansible_private_key_file: ""
+
+ - name: Check that attempt failed
+ ansible.builtin.assert:
+ that:
+ - results.failed
+ always:
+ - name: Reset connection with {{ ansible_user }}
+ ansible.builtin.meta: reset_connection
+
+ - name: Delete user
+ register: result
+ cisco.ios.ios_user:
+ name: auth_user
+ state: absent
+
+- block:
+ - name: Ensure SSH key is not world readable
+ ansible.builtin.file:
+ path: "{{ role_path }}/files/test_rsa"
+ mode: 384
+
+ - name: Create user with sshkey
+ cisco.ios.ios_user:
+ name: ssh_user
+ privilege: 15
+ role: network-operator
+ state: present
+ sshkey: "{{ lookup('file', 'files/test_rsa.pub') }}"
+
+ - name: Reset connection with {{ ansible_user }}
+ ansible.builtin.meta: reset_connection
+
+ - name: Test sshkey login for {{ ansible_user }} user
+ cisco.ios.ios_command:
+ commands:
+ - show version
+ vars:
+ ansible_ssh_user: ssh_user
+ ansible_ssh_private_key_file: "{{ role_path }}/files/test_rsa"
+
+ - name: Reset connection with {{ ansible_user }}
+ ansible.builtin.meta: reset_connection
+
+ - name: Test with {{ ansible_user }} user without keys
+ cisco.ios.ios_command:
+ commands:
+ - show version
+ ignore_errors: true
+ register: results
+ vars:
+ ansible_user: ssh_user
+ ansible_private_key_file: ""
+
+ - name: Check that attempt failed
+ ansible.builtin.assert:
+ that:
+ - results.failed
+ always:
+ - name: Reset connection with {{ ansible_user }}
+ ansible.builtin.meta: reset_connection
+
+ - name: Delete user
+ register: result
+ cisco.ios.ios_user:
+ name: ssh_user
+ state: absent
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_user/tests/cli/basic.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_user/tests/cli/basic.yaml
new file mode 100644
index 000000000..7d5606c1e
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_user/tests/cli/basic.yaml
@@ -0,0 +1,145 @@
+---
+- name: Tear down old users if they exist (setup)
+ become: true
+ cisco.ios.ios_user:
+ aggregate:
+ - name: ansibletest1
+
+ - name: ansibletest2
+
+ - name: ansibletest3
+
+ - name: ansibletest4
+
+ - name: ansibletest5
+
+ - name: ansibletest6
+ state: absent
+
+- name: Create user (setup)
+ become: true
+ register: result
+ cisco.ios.ios_user:
+ name: ansibletest1
+ privilege: 15
+ role: network-operator
+ state: present
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - result.commands == ["username ansibletest1 view network-operator", "username ansibletest1 privilege 15"]
+
+- name: Collection of users (setup)
+ become: true
+ register: result
+ cisco.ios.ios_user:
+ aggregate:
+ - name: ansibletest2
+
+ - name: ansibletest3
+ state: present
+ view: network-admin
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - result.commands == ["username ansibletest2 view network-admin", "username ansibletest3 view network-admin"]
+
+- name: Add user again (idempotent)
+ become: true
+ register: result
+ cisco.ios.ios_user:
+ name: ansibletest1
+ privilege: 15
+ role: network-operator
+ state: present
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - result.commands | length == 0
+
+- name: Add collection of users again (idempotent)
+ become: true
+ register: result
+ cisco.ios.ios_user:
+ aggregate:
+ - name: ansibletest2
+
+ - name: ansibletest3
+ state: present
+ view: network-admin
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - result.commands | length == 0
+
+- name: Create user with password_type (password)
+ become: true
+ register: result
+ cisco.ios.ios_user:
+ name: ansibleuser4
+ password_type: password
+ configured_password: testpass
+ state: present
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - "'username ansibleuser4 password' in result.commands[0]"
+
+- name: Create user with password_type (secret)
+ become: true
+ register: result
+ cisco.ios.ios_user:
+ name: ansibleuser5
+ password_type: secret
+ configured_password: testpass
+ state: present
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - "'username ansibleuser5 secret' in result.commands[0]"
+
+- name: Create user with hashed_password
+ become: true
+ register: result
+ cisco.ios.ios_user:
+ name: ansibleuser6
+ hashed_password:
+ type: 5
+ value: $3$8JcDilcYgFZi.yz4ApaqkHG2.8/
+ state: present
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - "'username ansibleuser6 secret' in result.commands[0]"
+
+- name: Teardown
+ become: true
+ register: result
+ cisco.ios.ios_user:
+ aggregate:
+ - name: ansibletest1
+
+ - name: ansibletest2
+
+ - name: ansibletest3
+
+ - name: ansibletest4
+
+ - name: ansibletest5
+
+ - name: ansibletest6
+ state: absent
+
+- ansible.builtin.assert:
+ that:
+ - result.changed == true
+ - '"no username ansibletest1" in result.commands[0]["command"]'
+ - '"no username ansibletest2" in result.commands[1]["command"]'
+ - '"no username ansibletest3" in result.commands[2]["command"]'
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/defaults/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/defaults/main.yaml
new file mode 100644
index 000000000..164afead2
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+testcase: "[^_].*"
+test_items: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/meta/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/meta/main.yaml
new file mode 100644
index 000000000..23d65c7ef
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/meta/main.yaml
@@ -0,0 +1,2 @@
+---
+dependencies: []
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tasks/cli.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tasks/cli.yaml
new file mode 100644
index 000000000..25c50045a
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tasks/cli.yaml
@@ -0,0 +1,25 @@
+---
+- name: Collect all CLI test cases
+ ansible.builtin.find:
+ paths: "{{ role_path }}/tests/cli"
+ patterns: "{{ testcase }}.yaml"
+ use_regex: true
+ register: test_cases
+ delegate_to: localhost
+
+- name: Set test_items
+ ansible.builtin.set_fact:
+ test_items: "{{ test_cases.files | map(attribute='path') | list }}"
+ delegate_to: localhost
+
+- name: Get the IOS version
+ cisco.ios.ios_facts:
+ gather_subset: all
+
+- name: Run test case (connection=ansible.netcommon.network_cli)
+ ansible.builtin.include_tasks: "{{ test_case_to_run }}"
+ vars:
+ ansible_connection: ansible.netcommon.network_cli
+ with_items: "{{ test_items }}"
+ loop_control:
+ loop_var: test_case_to_run
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tasks/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tasks/main.yaml
new file mode 100644
index 000000000..0bf380edb
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tasks/main.yaml
@@ -0,0 +1,5 @@
+---
+- name: Main task for vlans module
+ ansible.builtin.include_tasks: cli.yaml
+ tags:
+ - network_cli
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/_parsed.cfg b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/_parsed.cfg
new file mode 100644
index 000000000..409931d24
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/_parsed.cfg
@@ -0,0 +1,21 @@
+VLAN Name Status Ports
+---- -------------------------------- --------- -------------------------------
+1 default active Gi0/1, Gi0/2
+10 vlan_10 active
+20 vlan_20 act/lshut
+30 vlan_30 sus/lshut
+1002 fddi-default act/unsup
+1003 token-ring-default act/unsup
+1004 fddinet-default act/unsup
+1005 trnet-default act/unsup
+
+VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2
+---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
+1 enet 100001 1500 - - - - - 0 0
+10 enet 100010 1500 - - - - - 0 0
+20 enet 100020 1500 - - - - - 0 0
+30 enet 100030 1500 - - - - - 0 0
+1002 fddi 101002 1500 - - - - - 0 0
+1003 tr 101003 1500 - - - - - 0 0
+1004 fdnet 101004 1500 - - - ieee - 0 0
+1005 trnet 101005 1500 - - - ibm - 0 0
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/_populate_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/_populate_config.yaml
new file mode 100644
index 000000000..51164853a
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/_populate_config.yaml
@@ -0,0 +1,7 @@
+---
+- name: Setup
+ vars:
+ lines: "vlan 10\nvlan 20\nvlan 30\n"
+ when: ansible_net_version != "15.6(2)T"
+ ansible.netcommon.cli_config:
+ config: "{{ lines }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/_remove_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/_remove_config.yaml
new file mode 100644
index 000000000..87f66de5a
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/_remove_config.yaml
@@ -0,0 +1,7 @@
+---
+- name: Remove configuration
+ vars:
+ lines: "no vlan 10\nno vlan 20\nno vlan 30\nno vlan 40\n"
+ when: ansible_net_version != "15.6(2)T"
+ ansible.netcommon.cli_config:
+ config: "{{ lines }}"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/deleted.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/deleted.yaml
new file mode 100644
index 000000000..da8244c53
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/deleted.yaml
@@ -0,0 +1,40 @@
+---
+- ansible.builtin.debug:
+ msg: Start Deleted integration state for ios_vlans ansible_connection={{ ansible_connection }}
+
+- block:
+ - ansible.builtin.include_tasks: _remove_config.yaml
+ - ansible.builtin.include_tasks: _populate_config.yaml
+ when: ansible_net_version == "15.6(2)T"
+
+- block:
+ - name: Delete vlans attributes for all configured vlans
+ register: result
+ cisco.ios.ios_vlans: &id001
+ state: deleted
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ deleted['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ deleted['before'] | symmetric_difference(result['before']) | length == 0 }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ deleted['after'] | symmetric_difference(result['after']) | length == 0 }}"
+
+ - name: Delete vlans attributes for all configured vlans (idempotent)
+ register: result
+ cisco.ios.ios_vlans: *id001
+ - name: Assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result.changed == false
+ when: ansible_net_version == "15.6(2)T"
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/empty_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/empty_config.yaml
new file mode 100644
index 000000000..f59d55507
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/empty_config.yaml
@@ -0,0 +1,60 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_vlans empty_config.yaml integration tests on connection={{ ansible_connection }}
+
+- block:
+ - name: Merged with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_vlans:
+ config:
+ state: merged
+
+ - ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state merged'
+
+ - name: Replaced with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_vlans:
+ config:
+ state: replaced
+
+ - ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state replaced'
+
+ - name: Overridden with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_vlans:
+ config:
+ state: overridden
+
+ - ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state overridden'
+
+ - name: Rendered with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_vlans:
+ config:
+ state: rendered
+
+ - ansible.builtin.assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state rendered'
+
+ - name: Parsed with empty configuration should give appropriate error message
+ register: result
+ ignore_errors: true
+ cisco.ios.ios_vlans:
+ running_config:
+ state: parsed
+
+ - ansible.builtin.assert:
+ that:
+ - result.msg == 'value of running_config parameter must not be empty for state parsed'
+ when: ansible_net_version != "15.6(2)T"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/gathered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/gathered.yaml
new file mode 100644
index 000000000..3c52d178a
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/gathered.yaml
@@ -0,0 +1,23 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_vlans gathered integration tests on connection={{ ansible_connection }}
+
+- block:
+ - ansible.builtin.include_tasks: _populate_config.yaml
+ when: ansible_net_version == "15.6(2)T"
+
+- block:
+ - name: Gather the provided configuration with the existing running configuration
+ register: result
+ cisco.ios.ios_vlans:
+ config:
+ state: gathered
+
+ - name: Assert
+ ansible.builtin.assert:
+ that:
+ - gathered['config'] | symmetric_difference(result.gathered) == []
+ - result['changed'] == false
+ when: ansible_net_version == "15.6(2)T"
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/merged.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/merged.yaml
new file mode 100644
index 000000000..184a0317e
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/merged.yaml
@@ -0,0 +1,62 @@
+---
+- ansible.builtin.debug:
+ msg: START Merged ios_vlans state for integration tests on connection={{ ansible_connection }}
+
+- block:
+ - ansible.builtin.include_tasks: _remove_config.yaml
+ when: ansible_net_version == "15.6(2)T"
+
+- block:
+ - name: Merge provided configuration with device configuration
+ register: result
+ cisco.ios.ios_vlans: &id001
+ config:
+ - name: Vlan_10
+ vlan_id: 10
+ state: active
+ shutdown: disabled
+ remote_span: true
+
+ - name: Vlan_20
+ vlan_id: 20
+ mtu: 610
+ state: active
+ shutdown: enabled
+
+ - name: Vlan_30
+ vlan_id: 30
+ state: suspend
+ shutdown: enabled
+
+ - name: pvlan-primary
+ vlan_id: 100
+ private_vlan:
+ type: primary
+
+ state: merged
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['before'] | symmetric_difference(result['before']) | length == 0 }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ merged['after'] | symmetric_difference(result['after']) | length == 0 }}"
+
+ - name: Merge provided configuration with device configuration (idempotent)
+ register: result
+ cisco.ios.ios_vlans: *id001
+ - name: Assert that the previous task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ when: ansible_net_version == "15.6(2)T"
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/overridden.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/overridden.yaml
new file mode 100644
index 000000000..4e5468f95
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/overridden.yaml
@@ -0,0 +1,48 @@
+---
+- ansible.builtin.debug:
+ msg: START Overridden ios_vlans state for integration tests on connection={{ ansible_connection }}
+
+- block:
+ - ansible.builtin.include_tasks: _remove_config.yaml
+ - ansible.builtin.include_tasks: _populate_config.yaml
+ when: ansible_net_version == "15.6(2)T"
+
+- block:
+ - name: Override device configuration of all vlans with provided configuration
+ register: result
+ cisco.ios.ios_vlans: &id001
+ config:
+ - name: VLAN_10
+ vlan_id: 10
+ mtu: 1000
+
+ - name: VLAN_40
+ vlan_id: 40
+ mtu: 850
+ state: overridden
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ overridden['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ overridden['before'] | symmetric_difference(result['before']) | length == 0 }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ overridden['after'] | symmetric_difference(result['after']) | length == 0 }}"
+
+ - name: Override device configuration of all interfaces with provided configuration (idempotent)
+ register: result
+ cisco.ios.ios_vlans: *id001
+ - name: Assert that task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ when: ansible_net_version == "15.6(2)T"
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/parsed.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/parsed.yaml
new file mode 100644
index 000000000..042fef68b
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/parsed.yaml
@@ -0,0 +1,17 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_vlans parsed integration tests on connection={{ ansible_connection }}
+
+- block:
+ - name: Parse the commands for provided configuration
+ become: true
+ register: result
+ cisco.ios.ios_vlans:
+ running_config: "{{ lookup('file', '_parsed.cfg') }}"
+ state: parsed
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - parsed['config']|symmetric_difference(result.parsed) == []
+ when: ansible_net_version != "15.6(2)T"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/rendered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/rendered.yaml
new file mode 100644
index 000000000..38b0304c8
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/rendered.yaml
@@ -0,0 +1,31 @@
+---
+- ansible.builtin.debug:
+ msg: Start ios_vlans rendered integration tests ansible_connection={{ ansible_connection }}
+
+- block:
+ - name: Render the commands for provided configuration
+ become: true
+ register: result
+ cisco.ios.ios_vlans:
+ config:
+ - name: Vlan_10
+ vlan_id: 10
+ state: active
+ shutdown: disabled
+ remote_span: true
+ - name: Vlan_20
+ vlan_id: 20
+ mtu: 610
+ state: active
+ shutdown: enabled
+ - name: Vlan_30
+ vlan_id: 30
+ state: suspend
+ shutdown: enabled
+ state: rendered
+
+ - ansible.builtin.assert:
+ that:
+ - result.changed == false
+ - result.rendered|symmetric_difference(rendered.commands) == []
+ when: ansible_net_version != "15.6(2)T"
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/replaced.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/replaced.yaml
new file mode 100644
index 000000000..04f0c91f4
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/replaced.yaml
@@ -0,0 +1,53 @@
+---
+- ansible.builtin.debug:
+ msg: START Replaced ios_vlans state for integration tests on connection={{ ansible_connection }}
+
+- block:
+ - ansible.builtin.include_tasks: _remove_config.yaml
+ - ansible.builtin.include_tasks: _populate_config.yaml
+ when: ansible_net_version == "15.6(2)T"
+
+- block:
+ - name: Replaces device configuration of listed vlans with provided configuration
+ register: result
+ cisco.ios.ios_vlans: &id001
+ config:
+ - vlan_id: 20
+ name: Test_VLAN20
+ mtu: 700
+ shutdown: disabled
+
+ - vlan_id: 30
+ name: Test_VLAN30
+ mtu: 1000
+
+ - vlan_id: 40
+ name: Test_new_VLAN40
+ state: suspend
+ state: replaced
+
+ - name: Assert that correct set of commands were generated
+ ansible.builtin.assert:
+ that:
+ - "{{ replaced['commands'] | symmetric_difference(result['commands']) | length == 0 }}"
+
+ - name: Assert that before dicts are correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ replaced['before'] | symmetric_difference(result['before']) | length == 0 }}"
+
+ - name: Assert that after dict is correctly generated
+ ansible.builtin.assert:
+ that:
+ - "{{ replaced['after'] | symmetric_difference(result['after']) | length == 0 }}"
+
+ - name: Replaces device configuration of listed interfaces with provided configuration (idempotent)
+ register: result
+ cisco.ios.ios_vlans: *id001
+ - name: Assert that task was idempotent
+ ansible.builtin.assert:
+ that:
+ - result['changed'] == false
+ when: ansible_net_version == "15.6(2)T"
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/rtt.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/rtt.yaml
new file mode 100644
index 000000000..a6944cb1b
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/rtt.yaml
@@ -0,0 +1,72 @@
+---
+- ansible.builtin.debug:
+ msg: START ios_vlans round trip integration tests on connection={{ ansible_connection }}
+
+- block:
+ - ansible.builtin.include_tasks: _remove_config.yaml
+ when: ansible_net_version == "15.6(2)T"
+
+- block:
+ - name: Apply the provided configuration (base config)
+ register: base_config
+ cisco.ios.ios_vlans:
+ config:
+ - name: Vlan_10
+ vlan_id: 10
+ state: active
+ shutdown: disabled
+ remote_span: true
+
+ - name: Vlan_20
+ vlan_id: 20
+ mtu: 610
+ state: active
+ shutdown: enabled
+
+ - name: Vlan_30
+ vlan_id: 30
+ state: suspend
+ shutdown: enabled
+ state: merged
+
+ - name: Gather vlans interfaces facts
+ cisco.ios.ios_facts:
+ gather_subset:
+ - "!all"
+ - "!min"
+ gather_network_resources:
+ - vlans
+
+ - name: Apply the provided configuration (config to be reverted)
+ register: result
+ cisco.ios.ios_vlans:
+ config:
+ - name: VLAN_10
+ vlan_id: 10
+ mtu: 1000
+
+ - name: VLAN_40
+ vlan_id: 40
+ mtu: 850
+ state: overridden
+
+ - ansible.builtin.assert:
+ that:
+ - result.commands|length == 8
+ - result.changed == true
+ - result.commands|symmetric_difference(overridden.commands) == []
+
+ - name: Revert back to base configuration using facts round trip
+ register: revert
+ cisco.ios.ios_vlans:
+ config: "{{ ansible_facts['network_resources']['vlans'] }}"
+ state: overridden
+
+ - ansible.builtin.assert:
+ that:
+ - revert.commands|length == 14
+ - revert.changed == true
+ - revert.commands|symmetric_difference(rtt.commands) == []
+ when: ansible_net_version == "15.6(2)T"
+ always:
+ - ansible.builtin.include_tasks: _remove_config.yaml
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/vars/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/vars/main.yaml
new file mode 100644
index 000000000..72400621d
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/vars/main.yaml
@@ -0,0 +1,470 @@
+---
+merged:
+ before:
+ - mtu: 1500
+ name: default
+ shutdown: disabled
+ state: active
+ vlan_id: 1
+ - mtu: 1500
+ name: fddi-default
+ shutdown: enabled
+ state: active
+ vlan_id: 1002
+ - mtu: 1500
+ name: token-ring-default
+ shutdown: enabled
+ state: active
+ vlan_id: 1003
+ - mtu: 1500
+ name: fddinet-default
+ shutdown: enabled
+ state: active
+ vlan_id: 1004
+ - mtu: 1500
+ name: trnet-default
+ shutdown: enabled
+ state: active
+ vlan_id: 1005
+ commands:
+ - vlan 10
+ - name Vlan_10
+ - state active
+ - remote-span
+ - no shutdown
+ - vlan 20
+ - name Vlan_20
+ - state active
+ - mtu 610
+ - shutdown
+ - vlan 30
+ - name Vlan_30
+ - state suspend
+ - shutdown
+ - vlan 100
+ - name pvlan-primary
+ - private-vlan primary
+ after:
+ - mtu: 1500
+ name: default
+ shutdown: disabled
+ state: active
+ vlan_id: 1
+ - mtu: 1500
+ name: Vlan_10
+ remote_span: true
+ shutdown: disabled
+ state: active
+ vlan_id: 10
+ - mtu: 610
+ name: Vlan_20
+ shutdown: enabled
+ state: active
+ vlan_id: 20
+ - mtu: 1500
+ name: Vlan_30
+ shutdown: enabled
+ state: suspend
+ vlan_id: 30
+ - mtu: 1500
+ name: pvlan-primary
+ shutdown: disabled
+ state: active
+ vlan_id: 100
+ private_vlan:
+ type: primary
+ - mtu: 1500
+ name: fddi-default
+ shutdown: enabled
+ state: active
+ vlan_id: 1002
+ - mtu: 1500
+ name: token-ring-default
+ shutdown: enabled
+ state: active
+ vlan_id: 1003
+ - mtu: 1500
+ name: fddinet-default
+ shutdown: enabled
+ state: active
+ vlan_id: 1004
+ - mtu: 1500
+ name: trnet-default
+ shutdown: enabled
+ state: active
+ vlan_id: 1005
+replaced:
+ before:
+ - mtu: 1500
+ name: default
+ shutdown: disabled
+ state: active
+ vlan_id: 1
+ - mtu: 1500
+ name: VLAN0010
+ shutdown: disabled
+ state: active
+ vlan_id: 10
+ - mtu: 1500
+ name: VLAN0020
+ shutdown: disabled
+ state: active
+ vlan_id: 20
+ - mtu: 1500
+ name: VLAN0030
+ shutdown: disabled
+ state: active
+ vlan_id: 30
+ - mtu: 1500
+ name: fddi-default
+ shutdown: enabled
+ state: active
+ vlan_id: 1002
+ - mtu: 1500
+ name: token-ring-default
+ shutdown: enabled
+ state: active
+ vlan_id: 1003
+ - mtu: 1500
+ name: fddinet-default
+ shutdown: enabled
+ state: active
+ vlan_id: 1004
+ - mtu: 1500
+ name: trnet-default
+ shutdown: enabled
+ state: active
+ vlan_id: 1005
+ commands:
+ - vlan 20
+ - name Test_VLAN20
+ - mtu 700
+ - vlan 30
+ - name Test_VLAN30
+ - mtu 1000
+ - vlan 40
+ - name Test_new_VLAN40
+ - state suspend
+ after:
+ - mtu: 1500
+ name: default
+ shutdown: disabled
+ state: active
+ vlan_id: 1
+ - mtu: 1500
+ name: VLAN0010
+ shutdown: disabled
+ state: active
+ vlan_id: 10
+ - mtu: 700
+ name: Test_VLAN20
+ shutdown: disabled
+ state: active
+ vlan_id: 20
+ - mtu: 1000
+ name: Test_VLAN30
+ shutdown: disabled
+ state: active
+ vlan_id: 30
+ - mtu: 1500
+ name: Test_new_VLAN40
+ shutdown: disabled
+ state: suspend
+ vlan_id: 40
+ - mtu: 1500
+ name: fddi-default
+ shutdown: enabled
+ state: active
+ vlan_id: 1002
+ - mtu: 1500
+ name: token-ring-default
+ shutdown: enabled
+ state: active
+ vlan_id: 1003
+ - mtu: 1500
+ name: fddinet-default
+ shutdown: enabled
+ state: active
+ vlan_id: 1004
+ - mtu: 1500
+ name: trnet-default
+ shutdown: enabled
+ state: active
+ vlan_id: 1005
+overridden:
+ before:
+ - mtu: 1500
+ name: default
+ shutdown: disabled
+ state: active
+ vlan_id: 1
+ - mtu: 1500
+ name: VLAN0010
+ shutdown: disabled
+ state: active
+ vlan_id: 10
+ - mtu: 1500
+ name: VLAN0020
+ shutdown: disabled
+ state: active
+ vlan_id: 20
+ - mtu: 1500
+ name: VLAN0030
+ shutdown: disabled
+ state: active
+ vlan_id: 30
+ - mtu: 1500
+ name: fddi-default
+ shutdown: enabled
+ state: active
+ vlan_id: 1002
+ - mtu: 1500
+ name: token-ring-default
+ shutdown: enabled
+ state: active
+ vlan_id: 1003
+ - mtu: 1500
+ name: fddinet-default
+ shutdown: enabled
+ state: active
+ vlan_id: 1004
+ - mtu: 1500
+ name: trnet-default
+ shutdown: enabled
+ state: active
+ vlan_id: 1005
+ commands:
+ - vlan 10
+ - name VLAN_10
+ - mtu 1000
+ - no vlan 20
+ - no vlan 30
+ - vlan 40
+ - name VLAN_40
+ - mtu 850
+ after:
+ - mtu: 1500
+ name: default
+ shutdown: disabled
+ state: active
+ vlan_id: 1
+ - mtu: 1000
+ name: VLAN_10
+ shutdown: disabled
+ state: active
+ vlan_id: 10
+ - mtu: 850
+ name: VLAN_40
+ shutdown: disabled
+ state: active
+ vlan_id: 40
+ - mtu: 1500
+ name: fddi-default
+ shutdown: enabled
+ state: active
+ vlan_id: 1002
+ - mtu: 1500
+ name: token-ring-default
+ shutdown: enabled
+ state: active
+ vlan_id: 1003
+ - mtu: 1500
+ name: fddinet-default
+ shutdown: enabled
+ state: active
+ vlan_id: 1004
+ - mtu: 1500
+ name: trnet-default
+ shutdown: enabled
+ state: active
+ vlan_id: 1005
+deleted:
+ before:
+ - mtu: 1500
+ name: default
+ shutdown: disabled
+ state: active
+ vlan_id: 1
+ - mtu: 1500
+ name: VLAN0010
+ shutdown: disabled
+ state: active
+ vlan_id: 10
+ - mtu: 1500
+ name: VLAN0020
+ shutdown: disabled
+ state: active
+ vlan_id: 20
+ - mtu: 1500
+ name: VLAN0030
+ shutdown: disabled
+ state: active
+ vlan_id: 30
+ - mtu: 1500
+ name: fddi-default
+ shutdown: enabled
+ state: active
+ vlan_id: 1002
+ - mtu: 1500
+ name: token-ring-default
+ shutdown: enabled
+ state: active
+ vlan_id: 1003
+ - mtu: 1500
+ name: fddinet-default
+ shutdown: enabled
+ state: active
+ vlan_id: 1004
+ - mtu: 1500
+ name: trnet-default
+ shutdown: enabled
+ state: active
+ vlan_id: 1005
+ commands:
+ - no vlan 10
+ - no vlan 20
+ - no vlan 30
+ after:
+ - mtu: 1500
+ name: default
+ shutdown: disabled
+ state: active
+ vlan_id: 1
+ - mtu: 1500
+ name: fddi-default
+ shutdown: enabled
+ state: active
+ vlan_id: 1002
+ - mtu: 1500
+ name: token-ring-default
+ shutdown: enabled
+ state: active
+ vlan_id: 1003
+ - mtu: 1500
+ name: fddinet-default
+ shutdown: enabled
+ state: active
+ vlan_id: 1004
+ - mtu: 1500
+ name: trnet-default
+ shutdown: enabled
+ state: active
+ vlan_id: 1005
+gathered:
+ config:
+ - mtu: 1500
+ name: default
+ shutdown: disabled
+ state: active
+ vlan_id: 1
+ - mtu: 1500
+ name: VLAN0010
+ shutdown: disabled
+ state: active
+ vlan_id: 10
+ - mtu: 1500
+ name: VLAN0020
+ shutdown: disabled
+ state: active
+ vlan_id: 20
+ - mtu: 1500
+ name: VLAN0030
+ shutdown: disabled
+ state: active
+ vlan_id: 30
+ - mtu: 1500
+ name: fddi-default
+ shutdown: enabled
+ state: active
+ vlan_id: 1002
+ - mtu: 1500
+ name: token-ring-default
+ shutdown: enabled
+ state: active
+ vlan_id: 1003
+ - mtu: 1500
+ name: fddinet-default
+ shutdown: enabled
+ state: active
+ vlan_id: 1004
+ - mtu: 1500
+ name: trnet-default
+ shutdown: enabled
+ state: active
+ vlan_id: 1005
+parsed:
+ config:
+ - mtu: 1500
+ name: default
+ shutdown: disabled
+ state: active
+ vlan_id: 1
+ - mtu: 1500
+ name: vlan_10
+ shutdown: disabled
+ state: active
+ vlan_id: 10
+ - mtu: 1500
+ name: vlan_20
+ shutdown: enabled
+ state: active
+ vlan_id: 20
+ - mtu: 1500
+ name: vlan_30
+ shutdown: enabled
+ state: suspend
+ vlan_id: 30
+ - mtu: 1500
+ name: fddi-default
+ shutdown: enabled
+ state: active
+ vlan_id: 1002
+ - mtu: 1500
+ name: token-ring-default
+ shutdown: enabled
+ state: active
+ vlan_id: 1003
+ - mtu: 1500
+ name: fddinet-default
+ shutdown: enabled
+ state: active
+ vlan_id: 1004
+ - mtu: 1500
+ name: trnet-default
+ shutdown: enabled
+ state: active
+ vlan_id: 1005
+
+rendered:
+ commands:
+ - vlan 10
+ - name Vlan_10
+ - state active
+ - remote-span
+ - no shutdown
+ - vlan 20
+ - name Vlan_20
+ - state active
+ - mtu 610
+ - shutdown
+ - vlan 30
+ - name Vlan_30
+ - state suspend
+ - shutdown
+
+rtt:
+ commands:
+ - vlan 10
+ - name Vlan_10
+ - mtu 1500
+ - no vlan 40
+ - vlan 20
+ - name Vlan_20
+ - state active
+ - mtu 610
+ - shutdown
+ - vlan 30
+ - name Vlan_30
+ - state suspend
+ - mtu 1500
+ - shutdown
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/prepare_ios_tests/meta/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/prepare_ios_tests/meta/main.yaml
new file mode 100644
index 000000000..61d3ffe4f
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/prepare_ios_tests/meta/main.yaml
@@ -0,0 +1,2 @@
+---
+allow_duplicates: true
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/prepare_ios_tests/tasks/main.yml b/ansible_collections/cisco/ios/tests/integration/targets/prepare_ios_tests/tasks/main.yml
new file mode 100644
index 000000000..5bcb120e3
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/prepare_ios_tests/tasks/main.yml
@@ -0,0 +1,63 @@
+---
+- name: Ensure we have loopback 888 for testing
+ connection: ansible.netcommon.network_cli
+ become: true
+ cisco.ios.ios_config:
+ src: config.j2
+
+- name: Set test facts shorter_hostname
+ ansible.builtin.set_fact:
+ shorter_hostname: '{{ inventory_hostname_short | truncate(10, True, "") }}'
+
+- name: Discover IOS l2/l3 switch type
+ connection: ansible.netcommon.network_cli
+ become: true
+ register: result
+ cisco.ios.ios_command:
+ commands:
+ - show version
+
+- name: Set test facts
+ ansible.builtin.set_fact:
+ switch_type: ""
+
+- name: Set test facts to layer 2
+ ansible.builtin.set_fact:
+ switch_type: "L2"
+ when: '"l2" in result.stdout[0]'
+
+- name: Block to set facts
+ when: "'Cisco IOS' in result.stdout[0]"
+ block:
+ - name: Set test interface to gigabitethernet0/1 as we are on cisco IOS
+ ansible.builtin.set_fact:
+ test_interface: GigabitEthernet2
+
+ - name: Set test interface 2 to gigabitethernet0/2 as we are on cisco IOS
+ ansible.builtin.set_fact:
+ test_interface2: GigabitEthernet3
+
+- name: Block to fix configuration
+ when: "'Cisco IOS-XE' in result.stdout[0]"
+ block:
+ - name: Set test interface to gigabitethernet2 as we are on cisco ios-xe
+ ansible.builtin.set_fact:
+ test_interface: GigabitEthernet2
+
+ - name: Disable autonegotiation on gigabitethernet2
+ cisco.ios.ios_config:
+ lines:
+ - no negotiation auto
+ parents: int GigabitEthernet2
+ become: true
+
+ - name: Set test interface 2 to gigabitethernet3 as we are on cisco ios-xe
+ ansible.builtin.set_fact:
+ test_interface2: GigabitEthernet3
+
+ - name: Disable autonegotiation on gigabitethernet3
+ cisco.ios.ios_config:
+ lines:
+ - no negotiation auto
+ parents: int GigabitEthernet3
+ become: true
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/prepare_ios_tests/templates/config.j2 b/ansible_collections/cisco/ios/tests/integration/targets/prepare_ios_tests/templates/config.j2
new file mode 100644
index 000000000..cc89171c7
--- /dev/null
+++ b/ansible_collections/cisco/ios/tests/integration/targets/prepare_ios_tests/templates/config.j2
@@ -0,0 +1,3 @@
+interface Loopback888
+ description test for ansible
+ shutdown