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
gather_facts: no
connection: local
vars:
limit_to: "*"

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -9,7 +9,6 @@
parents:
- interface Loopback999
match: none
provider: "{{ cli }}"
- name: collect any backup files
find:
@ -28,13 +27,13 @@
ios_config:
src: basic/config.j2
backup: yes
provider: "{{ cli }}"
register: result
- assert:
that:
- "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
find:

View file

@ -9,13 +9,11 @@
parents:
- interface Loopback999
match: none
provider: "{{ cli }}"
- name: configure device with defaults included
ios_config:
src: defaults/config.j2
defaults: yes
provider: "{{ cli }}"
register: result
- debug: var=result
@ -23,13 +21,13 @@
- assert:
that:
- "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
ios_config:
src: defaults/config.j2
defaults: yes
provider: "{{ cli }}"
register: result
- debug: var=result

View file

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

View file

@ -9,30 +9,32 @@
parents:
- interface Loopback999
match: none
provider: "{{ cli }}"
- name: configure device with config
ios_config:
src: basic/config.j2
provider: "{{ cli }}"
register: result
- name: debug, remove me
debug:
msg: "{{ result }}"
- assert:
that:
- "result.changed == true"
# 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
ios_config:
src: basic/config.j2
provider: "{{ cli }}"
register: result
- assert:
that:
- "result.changed == false"
# 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"

View file

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

View file

@ -9,12 +9,10 @@
parents:
- interface Loopback999
match: none
provider: "{{ cli }}"
- name: configure device with config
ios_config:
src: basic/config.j2
provider: "{{ cli }}"
match: none
register: result
@ -22,12 +20,12 @@
that:
- "result.changed == true"
# 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
ios_config:
src: basic/config.j2
provider: "{{ cli }}"
register: result
- 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:
- 'no ip access-list extended test'
- 'no ip access-list standard test'
provider: "{{ cli }}"
match: none
- name: configure sub level command
ios_config:
lines: ['permit ip any any log']
parents: ['ip access-list extended test']
provider: "{{ cli }}"
register: result
- assert:
@ -26,7 +24,6 @@
ios_config:
lines: ['permit ip any any log']
parents: ['ip access-list extended test']
provider: "{{ cli }}"
register: result
- assert:
@ -37,7 +34,6 @@
ios_config:
lines:
- 'no ip access-list extended test'
provider: "{{ cli }}"
match: none
- debug: msg="END cli/sublevel.yaml"

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -6,13 +6,11 @@
commands:
- no interface Loopback999
match: none
provider: "{{ cli }}"
ignore_errors: yes
- name: configure device with config
ios_template:
src: basic/config.j2
provider: "{{ cli }}"
force: yes
register: result
@ -24,7 +22,6 @@
- name: check device with config
ios_template:
src: basic/config.j2
provider: "{{ cli }}"
force: yes
register: result
@ -38,6 +35,5 @@
commands:
- no interface Loopback999
match: none
provider: "{{ cli }}"
- 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