mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 21:00:22 -07:00
ios integration tests to network_cli (#33920)
* Preliminary steps * Fix Python3 network_cli ios * Add connection to debug strings * Fix ios confirm prompt by way of optional newline Also update ios_user delete tests
This commit is contained in:
parent
8d5c8b252d
commit
cb1b705218
56 changed files with 358 additions and 102 deletions
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
- debug: msg="START cli/backup.yaml"
|
||||
- debug: msg="START cli/backup.yaml on connection={{ ansible_connection }}"
|
||||
|
||||
- name: setup
|
||||
ios_config:
|
||||
|
@ -10,13 +10,14 @@
|
|||
- interface Loopback999
|
||||
match: none
|
||||
authorize: yes
|
||||
become: yes
|
||||
|
||||
- name: collect any backup files
|
||||
find:
|
||||
paths: "{{ role_path }}/backup"
|
||||
pattern: "{{ inventory_hostname_short }}_config*"
|
||||
register: backup_files
|
||||
delegate_to: localhost
|
||||
connection: local
|
||||
|
||||
- name: delete backup files
|
||||
file:
|
||||
|
@ -29,6 +30,7 @@
|
|||
src: basic/config.j2
|
||||
backup: yes
|
||||
authorize: yes
|
||||
become: yes
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
|
@ -42,10 +44,10 @@
|
|||
paths: "{{ role_path }}/backup"
|
||||
pattern: "{{ inventory_hostname_short }}_config*"
|
||||
register: backup_files
|
||||
delegate_to: localhost
|
||||
connection: local
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "backup_files.files is defined"
|
||||
|
||||
- debug: msg="END cli/backup.yaml"
|
||||
- debug: msg="END cli/backup.yaml on connection={{ ansible_connection }}"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
- debug: msg="START cli/defaults.yaml"
|
||||
- debug: msg="START cli/defaults.yaml on connection={{ ansible_connection }}"
|
||||
|
||||
- name: setup
|
||||
ios_config:
|
||||
|
@ -10,12 +10,14 @@
|
|||
- interface Loopback999
|
||||
match: none
|
||||
authorize: yes
|
||||
become: yes
|
||||
|
||||
- name: configure device with defaults included
|
||||
ios_config:
|
||||
src: defaults/config.j2
|
||||
defaults: yes
|
||||
authorize: yes
|
||||
become: yes
|
||||
register: result
|
||||
|
||||
- debug: var=result
|
||||
|
@ -31,6 +33,7 @@
|
|||
src: defaults/config.j2
|
||||
defaults: yes
|
||||
authorize: yes
|
||||
become: yes
|
||||
register: result
|
||||
|
||||
- debug: var=result
|
||||
|
@ -45,6 +48,7 @@
|
|||
lines:
|
||||
- mac-address-table notification mac-move
|
||||
authorize: yes
|
||||
become: yes
|
||||
ignore_errors: yes
|
||||
|
||||
- name: show interfaces brief to ensure deivce goes to valid prompt
|
||||
|
@ -52,6 +56,7 @@
|
|||
commands:
|
||||
- show interfaces
|
||||
authorize: yes
|
||||
become: yes
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
|
@ -59,4 +64,4 @@
|
|||
- "result.changed == false"
|
||||
- "result.stdout is defined"
|
||||
|
||||
- debug: msg="END cli/defaults.yaml"
|
||||
- debug: msg="END cli/defaults.yaml on connection={{ ansible_connection }}"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
- debug: msg="START cli/save.yaml"
|
||||
- debug: msg="START cli/save.yaml on connection={{ ansible_connection }}"
|
||||
|
||||
- name: setup
|
||||
ios_config:
|
||||
|
@ -10,12 +10,14 @@
|
|||
- interface Loopback999
|
||||
match: none
|
||||
authorize: yes
|
||||
become: yes
|
||||
|
||||
|
||||
- name: save config
|
||||
ios_config:
|
||||
save: true
|
||||
authorize: yes
|
||||
become: yes
|
||||
register: result
|
||||
# FIXME https://github.com/ansible/ansible-modules-core/issues/5008
|
||||
ignore_errors: true
|
||||
|
@ -30,6 +32,7 @@
|
|||
ios_config:
|
||||
save: true
|
||||
authorize: yes
|
||||
become: yes
|
||||
register: result
|
||||
# FIXME https://github.com/ansible/ansible-modules-core/issues/5008
|
||||
ignore_errors: true
|
||||
|
@ -41,6 +44,7 @@
|
|||
- "no ip http server"
|
||||
save_when: modified
|
||||
authorize: yes
|
||||
become: yes
|
||||
register: result
|
||||
|
||||
- name: save should always run
|
||||
|
@ -50,6 +54,7 @@
|
|||
- "ip http server"
|
||||
save_when: modified
|
||||
authorize: yes
|
||||
become: yes
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
|
@ -61,6 +66,7 @@
|
|||
lines:
|
||||
- "no ip http server"
|
||||
authorize: yes
|
||||
become: yes
|
||||
register: result
|
||||
|
||||
- debug: msg="END cli/save.yaml"
|
||||
- debug: msg="END cli/save.yaml on connection={{ ansible_connection }}"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
- debug: msg="START cli/src_basic.yaml"
|
||||
- debug: msg="START cli/src_basic.yaml on connection={{ ansible_connection }}"
|
||||
|
||||
- name: setup
|
||||
ios_config:
|
||||
|
@ -10,11 +10,13 @@
|
|||
- interface Loopback999
|
||||
match: none
|
||||
authorize: yes
|
||||
become: yes
|
||||
|
||||
- name: configure device with config
|
||||
ios_config:
|
||||
src: basic/config.j2
|
||||
authorize: yes
|
||||
become: yes
|
||||
register: result
|
||||
|
||||
- name: debug, remove me
|
||||
|
@ -31,6 +33,7 @@
|
|||
ios_config:
|
||||
src: basic/config.j2
|
||||
authorize: yes
|
||||
become: yes
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
|
@ -40,4 +43,4 @@
|
|||
# FIXME Bug https://github.com/ansible/ansible/issues/19382
|
||||
# - "result.updates is not defined"
|
||||
|
||||
- debug: msg="END cli/src_basic.yaml"
|
||||
- debug: msg="END cli/src_basic.yaml on connection={{ ansible_connection }}"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
- debug: msg="START cli/src_invalid.yaml"
|
||||
- debug: msg="START cli/src_invalid.yaml on connection={{ ansible_connection }}"
|
||||
|
||||
|
||||
# Defend https://github.com/ansible/ansible-modules-core/issues/4797
|
||||
|
@ -7,6 +7,7 @@
|
|||
ios_config:
|
||||
src: basic/foobar.j2
|
||||
authorize: yes
|
||||
become: yes
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
|
@ -16,4 +17,4 @@
|
|||
- "result.failed == true"
|
||||
- "result.msg == 'path specified in src not found'"
|
||||
|
||||
- debug: msg="END cli/src_invalid.yaml"
|
||||
- debug: msg="END cli/src_invalid.yaml on connection={{ ansible_connection }}"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
- debug: msg="START cli/src_match_none.yaml"
|
||||
- debug: msg="START cli/src_match_none.yaml on connection={{ ansible_connection }}"
|
||||
|
||||
- name: setup
|
||||
ios_config:
|
||||
|
@ -10,12 +10,14 @@
|
|||
- interface Loopback999
|
||||
match: none
|
||||
authorize: yes
|
||||
become: yes
|
||||
|
||||
- name: configure device with config
|
||||
ios_config:
|
||||
src: basic/config.j2
|
||||
match: none
|
||||
authorize: yes
|
||||
become: yes
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
|
@ -29,6 +31,7 @@
|
|||
ios_config:
|
||||
src: basic/config.j2
|
||||
authorize: yes
|
||||
become: yes
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
|
@ -38,4 +41,4 @@
|
|||
- "result.changed == false"
|
||||
- "result.updates is not defined"
|
||||
|
||||
- debug: msg="END cli/src_match_none.yaml"
|
||||
- debug: msg="END cli/src_match_none.yaml on connection={{ ansible_connection }}"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
- debug: msg="START cli/sublevel.yaml"
|
||||
- debug: msg="START cli/sublevel.yaml on connection={{ ansible_connection }}"
|
||||
|
||||
- name: setup test
|
||||
ios_config:
|
||||
|
@ -8,12 +8,14 @@
|
|||
- 'no ip access-list standard test'
|
||||
match: none
|
||||
authorize: yes
|
||||
become: yes
|
||||
|
||||
- name: configure sub level command
|
||||
ios_config:
|
||||
lines: ['permit ip any any log']
|
||||
parents: ['ip access-list extended test']
|
||||
authorize: yes
|
||||
become: yes
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
|
@ -27,6 +29,7 @@
|
|||
lines: ['permit ip any any log']
|
||||
parents: ['ip access-list extended test']
|
||||
authorize: yes
|
||||
become: yes
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
|
@ -39,5 +42,6 @@
|
|||
- 'no ip access-list extended test'
|
||||
match: none
|
||||
authorize: yes
|
||||
become: yes
|
||||
|
||||
- debug: msg="END cli/sublevel.yaml"
|
||||
- debug: msg="END cli/sublevel.yaml on connection={{ ansible_connection }}"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
- debug: msg="START cli/sublevel_block.yaml"
|
||||
- debug: msg="START cli/sublevel_block.yaml on connection={{ ansible_connection }}"
|
||||
|
||||
- name: setup
|
||||
ios_config:
|
||||
|
@ -12,6 +12,7 @@
|
|||
after: ['exit']
|
||||
authorize: yes
|
||||
match: none
|
||||
become: yes
|
||||
|
||||
- name: configure sub level command using block resplace
|
||||
ios_config:
|
||||
|
@ -24,6 +25,7 @@
|
|||
replace: block
|
||||
after: ['exit']
|
||||
authorize: yes
|
||||
become: yes
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
|
@ -46,6 +48,7 @@
|
|||
replace: block
|
||||
after: ['exit']
|
||||
authorize: yes
|
||||
become: yes
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
|
@ -58,5 +61,6 @@
|
|||
- no ip access-list extended test
|
||||
match: none
|
||||
authorize: yes
|
||||
become: yes
|
||||
|
||||
- debug: msg="END cli/sublevel_block.yaml"
|
||||
- debug: msg="END cli/sublevel_block.yaml on connection={{ ansible_connection }}"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
- debug: msg="START cli/sublevel_exact.yaml"
|
||||
- debug: msg="START cli/sublevel_exact.yaml on connection={{ ansible_connection }}"
|
||||
|
||||
- name: setup
|
||||
ios_config:
|
||||
|
@ -14,6 +14,7 @@
|
|||
after: exit
|
||||
match: none
|
||||
authorize: yes
|
||||
become: yes
|
||||
|
||||
- name: configure sub level command using exact match
|
||||
ios_config:
|
||||
|
@ -27,6 +28,7 @@
|
|||
after: exit
|
||||
match: exact
|
||||
authorize: yes
|
||||
become: yes
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
|
@ -49,6 +51,7 @@
|
|||
parents: ip access-list extended test
|
||||
match: exact
|
||||
authorize: yes
|
||||
become: yes
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
|
@ -61,5 +64,6 @@
|
|||
- no ip access-list extended test
|
||||
match: none
|
||||
authorize: yes
|
||||
become: yes
|
||||
|
||||
- debug: msg="END cli/sublevel_exact.yaml"
|
||||
- debug: msg="END cli/sublevel_exact.yaml on connection={{ ansible_connection }}"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
- debug: msg="START cli/sublevel_strict.yaml"
|
||||
- debug: msg="START cli/sublevel_strict.yaml on connection={{ ansible_connection }}"
|
||||
|
||||
- name: setup
|
||||
ios_config:
|
||||
|
@ -13,6 +13,7 @@
|
|||
before: no ip access-list extended test
|
||||
match: none
|
||||
authorize: yes
|
||||
become: yes
|
||||
|
||||
- name: configure sub level command using strict match
|
||||
ios_config:
|
||||
|
@ -24,6 +25,7 @@
|
|||
parents: ip access-list extended test
|
||||
match: strict
|
||||
authorize: yes
|
||||
become: yes
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
|
@ -40,6 +42,7 @@
|
|||
after: exit
|
||||
match: strict
|
||||
authorize: yes
|
||||
become: yes
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
|
@ -57,5 +60,6 @@
|
|||
lines: no ip access-list extended test
|
||||
match: none
|
||||
authorize: yes
|
||||
become: yes
|
||||
|
||||
- debug: msg="END cli/sublevel_strict.yaml"
|
||||
- debug: msg="END cli/sublevel_strict.yaml on connection={{ ansible_connection }}"
|
||||
|
|
|
@ -1,16 +1,18 @@
|
|||
---
|
||||
- debug: msg="START cli/toplevel.yaml"
|
||||
- debug: msg="START cli/toplevel.yaml on connection={{ ansible_connection }}"
|
||||
|
||||
- name: setup
|
||||
ios_config:
|
||||
lines: ['hostname {{ shorter_hostname }}']
|
||||
match: none
|
||||
authorize: yes
|
||||
become: yes
|
||||
|
||||
- name: configure top level command
|
||||
ios_config:
|
||||
lines: ['hostname foo']
|
||||
authorize: yes
|
||||
become: yes
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
|
@ -22,6 +24,7 @@
|
|||
ios_config:
|
||||
lines: ['hostname foo']
|
||||
authorize: yes
|
||||
become: yes
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
|
@ -33,5 +36,6 @@
|
|||
lines: ['hostname {{ shorter_hostname }}']
|
||||
match: none
|
||||
authorize: yes
|
||||
become: yes
|
||||
|
||||
- debug: msg="END cli/toplevel.yaml"
|
||||
- debug: msg="END cli/toplevel.yaml on connection={{ ansible_connection }}"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
- debug: msg="START cli/toplevel_after.yaml"
|
||||
- debug: msg="START cli/toplevel_after.yaml on connection={{ ansible_connection }}"
|
||||
|
||||
- name: setup
|
||||
ios_config:
|
||||
|
@ -8,12 +8,14 @@
|
|||
- "hostname {{ shorter_hostname }}"
|
||||
match: none
|
||||
authorize: yes
|
||||
become: yes
|
||||
|
||||
- name: configure top level command with before
|
||||
ios_config:
|
||||
lines: ['hostname foo']
|
||||
after: ['snmp-server contact bar']
|
||||
authorize: yes
|
||||
become: yes
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
|
@ -27,6 +29,7 @@
|
|||
lines: ['hostname foo']
|
||||
after: ['snmp-server contact foo']
|
||||
authorize: yes
|
||||
become: yes
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
|
@ -40,5 +43,6 @@
|
|||
- "hostname {{ shorter_hostname }}"
|
||||
match: none
|
||||
authorize: yes
|
||||
become: yes
|
||||
|
||||
- debug: msg="END cli/toplevel_after.yaml"
|
||||
- debug: msg="END cli/toplevel_after.yaml on connection={{ ansible_connection }}"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
- debug: msg="START cli/toplevel_before.yaml"
|
||||
- debug: msg="START cli/toplevel_before.yaml on connection={{ ansible_connection }}"
|
||||
|
||||
- name: setup
|
||||
ios_config:
|
||||
|
@ -8,12 +8,14 @@
|
|||
- "hostname {{ shorter_hostname }}"
|
||||
match: none
|
||||
authorize: yes
|
||||
become: yes
|
||||
|
||||
- name: configure top level command with before
|
||||
ios_config:
|
||||
lines: ['hostname foo']
|
||||
before: ['snmp-server contact bar']
|
||||
authorize: yes
|
||||
become: yes
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
|
@ -27,6 +29,7 @@
|
|||
lines: ['hostname foo']
|
||||
before: ['snmp-server contact foo']
|
||||
authorize: yes
|
||||
become: yes
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
|
@ -40,5 +43,6 @@
|
|||
- "hostname {{ shorter_hostname }}"
|
||||
match: none
|
||||
authorize: yes
|
||||
become: yes
|
||||
|
||||
- debug: msg="END cli/toplevel_before.yaml"
|
||||
- debug: msg="END cli/toplevel_before.yaml on connection={{ ansible_connection }}"
|
||||
|
|
|
@ -1,17 +1,19 @@
|
|||
---
|
||||
- debug: msg="START cli/toplevel_nonidempotent.yaml"
|
||||
- debug: msg="START cli/toplevel_nonidempotent.yaml on connection={{ ansible_connection }}"
|
||||
|
||||
- name: setup
|
||||
ios_config:
|
||||
lines: ['hostname {{ shorter_hostname }}']
|
||||
match: none
|
||||
authorize: yes
|
||||
become: yes
|
||||
|
||||
- name: configure top level command
|
||||
ios_config:
|
||||
lines: ['hostname foo']
|
||||
match: strict
|
||||
authorize: yes
|
||||
become: yes
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
|
@ -24,6 +26,7 @@
|
|||
lines: ['hostname foo']
|
||||
match: strict
|
||||
authorize: yes
|
||||
become: yes
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
|
@ -35,5 +38,6 @@
|
|||
lines: ['hostname {{ shorter_hostname }}']
|
||||
match: none
|
||||
authorize: yes
|
||||
become: yes
|
||||
|
||||
- debug: msg="END cli/toplevel_nonidempotent.yaml"
|
||||
- debug: msg="END cli/toplevel_nonidempotent.yaml on connection={{ ansible_connection }}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue