1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

integration/targets/ios_* work to support IOS (#20414)

* WIP

* Don't set connection: network_cli in the playbook

* ios_config tests now passing

* Create test loopback device

* delete

* ios_* pass (apart from ios_facts)

* Remove provider lines
This commit is contained in:
John R Barker 2017-01-20 20:18:12 +00:00 committed by GitHub
parent 7330ab8062
commit a12033a6e0
38 changed files with 53 additions and 142 deletions

View file

@ -1,7 +1,6 @@
--- ---
- hosts: ios - hosts: ios
gather_facts: no gather_facts: no
connection: local
vars: vars:
limit_to: "*" limit_to: "*"

View file

@ -0,0 +1,2 @@
dependencies:
- prepare_ios_tests

View file

@ -4,6 +4,7 @@
paths: "{{ role_path }}/tests/cli" paths: "{{ role_path }}/tests/cli"
patterns: "{{ testcase }}.yaml" patterns: "{{ testcase }}.yaml"
register: test_cases register: test_cases
delegate_to: localhost
- name: set test_items - name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"

View file

@ -8,7 +8,6 @@
- show interfaces GigabitEthernet 0/0 - show interfaces GigabitEthernet 0/0
wait_for: wait_for:
- "result[0] contains 'Description: Foo'" - "result[0] contains 'Description: Foo'"
provider: "{{ cli }}"
register: result register: result
ignore_errors: yes ignore_errors: yes

View file

@ -5,11 +5,10 @@
ios_command: ios_command:
commands: commands:
- show version - show version
- show interface GigabitEthernet0/0 - show interface loopback 888
wait_for: wait_for:
- "result[0] contains 15.6" - "result[0] contains Cisco"
- "result[1] contains GigabitEthernet0/0" - "result[1] contains Loopback888"
provider: "{{ cli }}"
register: result register: result
- assert: - assert:

View file

@ -3,8 +3,7 @@
- name: run invalid command - name: run invalid command
ios_command: ios_command:
commands: ['show foo'] commands: show foo
provider: "{{ cli }}"
register: result register: result
ignore_errors: yes ignore_errors: yes
@ -17,7 +16,6 @@
commands: commands:
- show version - show version
- show foo - show foo
provider: "{{ cli }}"
register: result register: result
ignore_errors: yes ignore_errors: yes

View file

@ -3,8 +3,8 @@
- name: get output for single command - name: get output for single command
ios_command: ios_command:
commands: ['show version'] commands:
provider: "{{ cli }}" - show version
register: result register: result
- assert: - assert:
@ -17,7 +17,6 @@
commands: commands:
- show version - show version
- show interfaces - show interfaces
provider: "{{ cli }}"
register: result register: result
- assert: - assert:

View file

@ -7,7 +7,6 @@
- show version - show version
wait_for: wait_for:
- "result[0] contains bad_value_string" - "result[0] contains bad_value_string"
provider: "{{ cli }}"
register: result register: result
ignore_errors: yes ignore_errors: yes

View file

@ -0,0 +1,2 @@
dependencies:
- prepare_ios_tests

View file

@ -4,6 +4,7 @@
paths: "{{ role_path }}/tests/cli" paths: "{{ role_path }}/tests/cli"
patterns: "{{ testcase }}.yaml" patterns: "{{ testcase }}.yaml"
register: test_cases register: test_cases
delegate_to: localhost
- name: set test_items - name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"

View file

@ -9,7 +9,6 @@
parents: parents:
- interface Loopback999 - interface Loopback999
match: none match: none
provider: "{{ cli }}"
- name: collect any backup files - name: collect any backup files
find: find:
@ -28,13 +27,13 @@
ios_config: ios_config:
src: basic/config.j2 src: basic/config.j2
backup: yes backup: yes
provider: "{{ cli }}"
register: result register: result
- assert: - assert:
that: that:
- "result.changed == true" - "result.changed == true"
- "result.updates is not defined" # FIXME Bug https://github.com/ansible/ansible/issues/19382
# - "result.updates is not defined"
- name: collect any backup files - name: collect any backup files
find: find:

View file

@ -9,13 +9,11 @@
parents: parents:
- interface Loopback999 - interface Loopback999
match: none match: none
provider: "{{ cli }}"
- name: configure device with defaults included - name: configure device with defaults included
ios_config: ios_config:
src: defaults/config.j2 src: defaults/config.j2
defaults: yes defaults: yes
provider: "{{ cli }}"
register: result register: result
- debug: var=result - debug: var=result
@ -23,13 +21,13 @@
- assert: - assert:
that: that:
- "result.changed == true" - "result.changed == true"
- "result.updates is not defined" # FIXME Bug https://github.com/ansible/ansible/issues/19382
# - "result.updates is not defined"
- name: check device with defaults included - name: check device with defaults included
ios_config: ios_config:
src: defaults/config.j2 src: defaults/config.j2
defaults: yes defaults: yes
provider: "{{ cli }}"
register: result register: result
- debug: var=result - debug: var=result

View file

@ -9,13 +9,11 @@
parents: parents:
- interface Loopback999 - interface Loopback999
match: none match: none
provider: "{{ cli }}"
- name: save config - name: save config
ios_config: ios_config:
save: true save: true
provider: "{{ cli }}"
register: result register: result
# FIXME https://github.com/ansible/ansible-modules-core/issues/5008 # FIXME https://github.com/ansible/ansible-modules-core/issues/5008
ignore_errors: true ignore_errors: true
@ -29,7 +27,6 @@
- name: save should always run - name: save should always run
ios_config: ios_config:
save: true save: true
provider: "{{ cli }}"
register: result register: result
# FIXME https://github.com/ansible/ansible-modules-core/issues/5008 # FIXME https://github.com/ansible/ansible-modules-core/issues/5008
ignore_errors: true ignore_errors: true

View file

@ -9,30 +9,32 @@
parents: parents:
- interface Loopback999 - interface Loopback999
match: none match: none
provider: "{{ cli }}"
- name: configure device with config - name: configure device with config
ios_config: ios_config:
src: basic/config.j2 src: basic/config.j2
provider: "{{ cli }}"
register: result register: result
- name: debug, remove me
debug:
msg: "{{ result }}"
- assert: - assert:
that: that:
- "result.changed == true" - "result.changed == true"
# https://github.com/ansible/ansible-modules-core/issues/4807 # https://github.com/ansible/ansible-modules-core/issues/4807
- "result.updates is not defined" # FIXME Bug https://github.com/ansible/ansible/issues/19382
# - "result.updates is not defined"
- name: check device with config - name: check device with config
ios_config: ios_config:
src: basic/config.j2 src: basic/config.j2
provider: "{{ cli }}"
register: result register: result
- assert: - assert:
that: that:
- "result.changed == false" - "result.changed == false"
# https://github.com/ansible/ansible-modules-core/issues/4807 # https://github.com/ansible/ansible-modules-core/issues/4807
- "result.updates is not defined" # 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"

View file

@ -6,7 +6,6 @@
- name: configure with invalid src - name: configure with invalid src
ios_config: ios_config:
src: basic/foobar.j2 src: basic/foobar.j2
provider: "{{ cli }}"
register: result register: result
ignore_errors: yes ignore_errors: yes

View file

@ -9,12 +9,10 @@
parents: parents:
- interface Loopback999 - interface Loopback999
match: none match: none
provider: "{{ cli }}"
- name: configure device with config - name: configure device with config
ios_config: ios_config:
src: basic/config.j2 src: basic/config.j2
provider: "{{ cli }}"
match: none match: none
register: result register: result
@ -22,12 +20,12 @@
that: that:
- "result.changed == true" - "result.changed == true"
# https://github.com/ansible/ansible-modules-core/issues/4807 # https://github.com/ansible/ansible-modules-core/issues/4807
- "result.updates is not defined" # FIXME Bug https://github.com/ansible/ansible/issues/19382
# - "result.updates is not defined"
- name: check device with config - name: check device with config
ios_config: ios_config:
src: basic/config.j2 src: basic/config.j2
provider: "{{ cli }}"
register: result register: result
- assert: - assert:

View file

@ -1,49 +0,0 @@
---
- debug: msg="START cli/src_match_none.yaml"
- name: setup
ios_config:
commands:
- no description
- no shutdown
parents:
- interface Loopback999
match: none
provider: "{{ cli }}"
- name: configure device with config
ios_config:
src: basic/config.j2
provider: "{{ cli }}"
match: none
register: result
- assert:
that:
- "result.changed == true"
# https://github.com/ansible/ansible-modules-core/issues/4807
- "result.updates is not defined"
- name: check device with config
ios_config:
src: basic/config.j2
provider: "{{ cli }}"
<<<<<<< f84b1d496e52b69dab38894e7ec7b90b63857331
=======
match: none
>>>>>>> Tests for ios_config
register: result
- assert:
that:
# Idempotent test
# https://github.com/ansible/ansible-modules-core/issues/4807
- "result.changed == false"
- "result.updates is not defined"
<<<<<<< f84b1d496e52b69dab38894e7ec7b90b63857331
=======
# FIXME bug https://github.com/ansible/ansible-modules-core/issues/5003
ignore_errors: true
>>>>>>> Tests for ios_config
- debug: msg="END cli/src_match_none.yaml"

View file

@ -6,14 +6,12 @@
lines: lines:
- 'no ip access-list extended test' - 'no ip access-list extended test'
- 'no ip access-list standard test' - 'no ip access-list standard test'
provider: "{{ cli }}"
match: none match: none
- name: configure sub level command - name: configure sub level command
ios_config: ios_config:
lines: ['permit ip any any log'] lines: ['permit ip any any log']
parents: ['ip access-list extended test'] parents: ['ip access-list extended test']
provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -26,7 +24,6 @@
ios_config: ios_config:
lines: ['permit ip any any log'] lines: ['permit ip any any log']
parents: ['ip access-list extended test'] parents: ['ip access-list extended test']
provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -37,7 +34,6 @@
ios_config: ios_config:
lines: lines:
- 'no ip access-list extended test' - 'no ip access-list extended test'
provider: "{{ cli }}"
match: none match: none
- debug: msg="END cli/sublevel.yaml" - debug: msg="END cli/sublevel.yaml"

View file

@ -10,7 +10,6 @@
parents: ['ip access-list extended test'] parents: ['ip access-list extended test']
before: ['no ip access-list extended test'] before: ['no ip access-list extended test']
after: ['exit'] after: ['exit']
provider: "{{ cli }}"
match: none match: none
- name: configure sub level command using block resplace - name: configure sub level command using block resplace
@ -23,7 +22,6 @@
parents: ['ip access-list extended test'] parents: ['ip access-list extended test']
replace: block replace: block
after: ['exit'] after: ['exit']
provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -45,7 +43,6 @@
parents: ['ip access-list extended test'] parents: ['ip access-list extended test']
replace: block replace: block
after: ['exit'] after: ['exit']
provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -57,6 +54,5 @@
lines: lines:
- no ip access-list extended test - no ip access-list extended test
match: none match: none
provider: "{{ cli }}"
- debug: msg="END cli/sublevel_block.yaml" - debug: msg="END cli/sublevel_block.yaml"

View file

@ -13,7 +13,6 @@
before: no ip access-list extended test before: no ip access-list extended test
after: exit after: exit
match: none match: none
provider: "{{ cli }}"
- name: configure sub level command using exact match - name: configure sub level command using exact match
ios_config: ios_config:
@ -26,7 +25,6 @@
before: no ip access-list extended test before: no ip access-list extended test
after: exit after: exit
match: exact match: exact
provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -48,7 +46,6 @@
- permit ip host 4.4.4.4 any log - permit ip host 4.4.4.4 any log
parents: ip access-list extended test parents: ip access-list extended test
match: exact match: exact
provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -60,6 +57,5 @@
lines: lines:
- no ip access-list extended test - no ip access-list extended test
match: none match: none
provider: "{{ cli }}"
- debug: msg="END cli/sublevel_exact.yaml" - debug: msg="END cli/sublevel_exact.yaml"

View file

@ -12,7 +12,6 @@
parents: ip access-list extended test parents: ip access-list extended test
before: no ip access-list extended test before: no ip access-list extended test
match: none match: none
provider: "{{ cli }}"
- name: configure sub level command using strict match - name: configure sub level command using strict match
ios_config: ios_config:
@ -23,7 +22,6 @@
- permit ip host 4.4.4.4 any log - permit ip host 4.4.4.4 any log
parents: ip access-list extended test parents: ip access-list extended test
match: strict match: strict
provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -39,7 +37,6 @@
parents: ip access-list extended test parents: ip access-list extended test
after: exit after: exit
match: strict match: strict
provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -56,6 +53,5 @@
ios_config: ios_config:
lines: no ip access-list extended test lines: no ip access-list extended test
match: none match: none
provider: "{{ cli }}"
- debug: msg="END cli/sublevel_strict.yaml" - debug: msg="END cli/sublevel_strict.yaml"

View file

@ -3,14 +3,12 @@
- name: setup - name: setup
ios_config: ios_config:
lines: ['hostname {{ inventory_hostname_short }}'] lines: ['hostname {{ shorter_hostname }}']
provider: "{{ cli }}"
match: none match: none
- name: configure top level command - name: configure top level command
ios_config: ios_config:
lines: ['hostname foo'] lines: ['hostname foo']
provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -21,7 +19,6 @@
- name: configure top level command idempotent check - name: configure top level command idempotent check
ios_config: ios_config:
lines: ['hostname foo'] lines: ['hostname foo']
provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -30,8 +27,7 @@
- name: teardown - name: teardown
ios_config: ios_config:
lines: ['hostname {{ inventory_hostname_short }}'] lines: ['hostname {{ shorter_hostname }}']
provider: "{{ cli }}"
match: none match: none
- debug: msg="END cli/toplevel.yaml" - debug: msg="END cli/toplevel.yaml"

View file

@ -5,15 +5,13 @@
ios_config: ios_config:
lines: lines:
- "snmp-server contact ansible" - "snmp-server contact ansible"
- "hostname {{ inventory_hostname_short }}" - "hostname {{ shorter_hostname }}"
provider: "{{ cli }}"
match: none match: none
- name: configure top level command with before - name: configure top level command with before
ios_config: ios_config:
lines: ['hostname foo'] lines: ['hostname foo']
after: ['snmp-server contact bar'] after: ['snmp-server contact bar']
provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -26,7 +24,6 @@
ios_config: ios_config:
lines: ['hostname foo'] lines: ['hostname foo']
after: ['snmp-server contact foo'] after: ['snmp-server contact foo']
provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -37,8 +34,7 @@
ios_config: ios_config:
lines: lines:
- "no snmp-server contact" - "no snmp-server contact"
- "hostname {{ inventory_hostname_short }}" - "hostname {{ shorter_hostname }}"
provider: "{{ cli }}"
match: none match: none
- debug: msg="END cli/toplevel_after.yaml" - debug: msg="END cli/toplevel_after.yaml"

View file

@ -5,15 +5,13 @@
ios_config: ios_config:
lines: lines:
- "snmp-server contact ansible" - "snmp-server contact ansible"
- "hostname {{ inventory_hostname_short }}" - "hostname {{ shorter_hostname }}"
provider: "{{ cli }}"
match: none match: none
- name: configure top level command with before - name: configure top level command with before
ios_config: ios_config:
lines: ['hostname foo'] lines: ['hostname foo']
before: ['snmp-server contact bar'] before: ['snmp-server contact bar']
provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -26,7 +24,6 @@
ios_config: ios_config:
lines: ['hostname foo'] lines: ['hostname foo']
before: ['snmp-server contact foo'] before: ['snmp-server contact foo']
provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -37,8 +34,7 @@
ios_config: ios_config:
lines: lines:
- "no snmp-server contact" - "no snmp-server contact"
- "hostname {{ inventory_hostname_short }}" - "hostname {{ shorter_hostname }}"
provider: "{{ cli }}"
match: none match: none
- debug: msg="END cli/toplevel_before.yaml" - debug: msg="END cli/toplevel_before.yaml"

View file

@ -3,14 +3,12 @@
- name: setup - name: setup
ios_config: ios_config:
lines: ['hostname {{ inventory_hostname_short }}'] lines: ['hostname {{ shorter_hostname }}']
provider: "{{ cli }}"
match: none match: none
- name: configure top level command - name: configure top level command
ios_config: ios_config:
lines: ['hostname foo'] lines: ['hostname foo']
provider: "{{ cli }}"
match: strict match: strict
register: result register: result
@ -22,7 +20,6 @@
- name: configure top level command idempotent check - name: configure top level command idempotent check
ios_config: ios_config:
lines: ['hostname foo'] lines: ['hostname foo']
provider: "{{ cli }}"
match: strict match: strict
register: result register: result
@ -32,8 +29,7 @@
- name: teardown - name: teardown
ios_config: ios_config:
lines: ['hostname {{ inventory_hostname_short }}'] lines: ['hostname {{ shorter_hostname }}']
provider: "{{ cli }}"
match: none match: none
- debug: msg="END cli/toplevel_nonidempotent.yaml" - debug: msg="END cli/toplevel_nonidempotent.yaml"

View file

@ -4,6 +4,7 @@
paths: "{{ role_path }}/tests/cli" paths: "{{ role_path }}/tests/cli"
patterns: "{{ testcase }}.yaml" patterns: "{{ testcase }}.yaml"
register: test_cases register: test_cases
delegate_to: localhost
- name: set test_items - name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"

View file

@ -4,7 +4,6 @@
- name: test getting all facts - name: test getting all facts
ios_facts: ios_facts:
provider: "{{ cli }}"
gather_subset: gather_subset:
- all - all
register: result register: result

View file

@ -4,7 +4,6 @@
- name: test getting default facts - name: test getting default facts
ios_facts: ios_facts:
provider: "{{ cli }}"
register: result register: result
- assert: - assert:

View file

@ -4,7 +4,6 @@
- name: test invalid subset (foobar) - name: test invalid subset (foobar)
ios_facts: ios_facts:
provider: "{{ cli }}"
gather_subset: gather_subset:
- "foobar" - "foobar"
register: result register: result
@ -26,7 +25,6 @@
- name: test subset specified multiple times - name: test subset specified multiple times
ios_facts: ios_facts:
provider: "{{ cli }}"
gather_subset: gather_subset:
- "!hardware" - "!hardware"
- "hardware" - "hardware"

View file

@ -4,7 +4,6 @@
- name: test not hardware - name: test not hardware
ios_facts: ios_facts:
provider: "{{ cli }}"
gather_subset: gather_subset:
- "!hardware" - "!hardware"
register: result register: result

View file

@ -0,0 +1,2 @@
dependencies:
- prepare_ios_tests

View file

@ -4,6 +4,7 @@
paths: "{{ role_path }}/tests/cli" paths: "{{ role_path }}/tests/cli"
patterns: "{{ testcase }}.yaml" patterns: "{{ testcase }}.yaml"
register: test_cases register: test_cases
delegate_to: localhost
- name: set test_items - name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"

View file

@ -6,7 +6,6 @@
commands: commands:
- no interface Loopback999 - no interface Loopback999
match: none match: none
provider: "{{ cli }}"
ignore_errors: yes ignore_errors: yes
- name: collect any backup files - name: collect any backup files
@ -26,7 +25,6 @@
ios_template: ios_template:
src: basic/config.j2 src: basic/config.j2
backup: yes backup: yes
provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -50,6 +48,5 @@
commands: commands:
- no interface Loopback999 - no interface Loopback999
match: none match: none
provider: "{{ cli }}"
- debug: msg="END cli/backup.yaml" - debug: msg="END cli/backup.yaml"

View file

@ -6,13 +6,11 @@
commands: commands:
- no interface Loopback999 - no interface Loopback999
match: none match: none
provider: "{{ cli }}"
ignore_errors: yes ignore_errors: yes
- name: configure device with config - name: configure device with config
ios_template: ios_template:
src: basic/config.j2 src: basic/config.j2
provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -23,7 +21,6 @@
- name: check device with config - name: check device with config
ios_template: ios_template:
src: basic/config.j2 src: basic/config.j2
provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -36,6 +33,5 @@
commands: commands:
- no interface Loopback999 - no interface Loopback999
match: none match: none
provider: "{{ cli }}"
- debug: msg="END cli/basic.yaml" - debug: msg="END cli/basic.yaml"

View file

@ -5,14 +5,12 @@
ios_config: ios_config:
commands: no interface Loopback999 commands: no interface Loopback999
match: none match: none
provider: "{{ cli }}"
ignore_errors: yes ignore_errors: yes
- name: configure device with defaults included - name: configure device with defaults included
ios_template: ios_template:
src: defaults/config.j2 src: defaults/config.j2
include_defaults: yes include_defaults: yes
provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -24,7 +22,6 @@
ios_template: ios_template:
src: defaults/config.j2 src: defaults/config.j2
include_defaults: yes include_defaults: yes
provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -36,6 +33,5 @@
ios_config: ios_config:
commands: no interface Loopback999 commands: no interface Loopback999
match: none match: none
provider: "{{ cli }}"
- debug: msg="END cli/defaults.yaml" - debug: msg="END cli/defaults.yaml"

View file

@ -6,13 +6,11 @@
commands: commands:
- no interface Loopback999 - no interface Loopback999
match: none match: none
provider: "{{ cli }}"
ignore_errors: yes ignore_errors: yes
- name: configure device with config - name: configure device with config
ios_template: ios_template:
src: basic/config.j2 src: basic/config.j2
provider: "{{ cli }}"
force: yes force: yes
register: result register: result
@ -24,7 +22,6 @@
- name: check device with config - name: check device with config
ios_template: ios_template:
src: basic/config.j2 src: basic/config.j2
provider: "{{ cli }}"
force: yes force: yes
register: result register: result
@ -38,6 +35,5 @@
commands: commands:
- no interface Loopback999 - no interface Loopback999
match: none match: none
provider: "{{ cli }}"
- debug: msg="END cli/force.yaml" - debug: msg="END cli/force.yaml"

View file

@ -0,0 +1,12 @@
---
- name: Ensure we have loopback 888 for testing
ios_config:
src: config.j2
# Some AWS hostnames can be longer than those allowed by the system we are testing
# Truncate the hostname
# http://jinja.pocoo.org/docs/2.9/templates/#truncate
- set_fact:
shorter_hostname: '{{ inventory_hostname_short| truncate(10, True, "") }}'

View file

@ -0,0 +1,4 @@
interface Loopback888
description test for ansible
shutdown