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

Port eos tests to network_cli (#33586)

* Add eos and fix tests to run multiple connections

* Update tests to report connection

* Add missing START messages

* Fix unspecified connection

* Python 3 updates

Exceptions don't have `.message` in Python 3

* Override `become` when using `connection=local`

* Slight restructuring to make eapi easier later on

* Move eapi toggle to prepare_eos
* Pull out connection on eapi tasks
This commit is contained in:
Nathaniel Case 2017-12-19 15:49:49 -05:00 committed by GitHub
parent f64b276f6a
commit 513c75079e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
70 changed files with 393 additions and 249 deletions

View file

@ -41,7 +41,7 @@ class ActionModule(_ActionModule):
try:
self._handle_template()
except ValueError as exc:
return dict(failed=True, msg=exc.message)
return dict(failed=True, msg=to_text(exc))
result = super(ActionModule, self).run(tmp, task_vars)
@ -55,7 +55,7 @@ class ActionModule(_ActionModule):
# strip out any keys that have two leading and two trailing
# underscore characters
for key in result.keys():
for key in list(result.keys()):
if PRIVATE_KEYS_RE.match(key):
del result[key]

View file

@ -4,12 +4,19 @@
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 }}"
- name: run test case
include: "{{ test_case_to_run }}"
- name: run test cases (connection=network_cli)
include: "{{ test_case_to_run }} ansible_connection=network_cli"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
- name: run test case (connection=local)
include: "{{ test_case_to_run }} ansible_connection=local ansible_become=no"
with_first_found: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

View file

@ -3,26 +3,14 @@
find:
paths: "{{ role_path }}/tests/eapi"
patterns: "{{ testcase }}.yaml"
delegate_to: localhost
register: test_cases
- 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 }}"
- name: enable eapi
eos_eapi:
http: yes
https: yes
local_http: no
enable_socket: yes
provider: "{{ cli }}"
- name: run test case
include: "{{ test_case_to_run }}"
- name: run test case (connection=local)
include: "{{ test_case_to_run }} ansible_connection=local"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
- name: disable eapi
eos_eapi:
state: stopped
provider: "{{ cli }}"

View file

@ -1,9 +1,12 @@
---
- debug: msg="START cli/basic-login.yaml on connection={{ ansible_connection }}"
- name: Remove previous login banner
eos_config:
lines: no banner login
authorize: yes
provider: "{{ cli }}"
become: yes
- name: Create login banner
eos_banner:
@ -14,6 +17,7 @@
state: present
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -32,6 +36,7 @@
state: present
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -47,6 +52,7 @@
state: absent
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -62,6 +68,7 @@
state: absent
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:

View file

@ -1,9 +1,12 @@
---
- debug: msg="START cli/basic-motd.yaml on connection={{ ansible_connection }}"
- name: Remove previous motd banner
eos_config:
lines: no banner motd
authorize: yes
provider: "{{ cli }}"
become: yes
- name: Create motd
eos_banner:
@ -15,6 +18,7 @@
state: present
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -35,6 +39,7 @@
state: present
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -54,6 +59,7 @@
state: absent
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -73,6 +79,7 @@
state: absent
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:

View file

@ -4,12 +4,19 @@
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 }}"
- name: run test case
include: "{{ test_case_to_run }}"
- name: run test cases (connection=network_cli)
include: "{{ test_case_to_run }} ansible_connection=network_cli"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
- name: run test case (connection=local)
include: "{{ test_case_to_run }} ansible_connection=local ansible_become=no"
with_first_found: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

View file

@ -3,26 +3,14 @@
find:
paths: "{{ role_path }}/tests/eapi"
patterns: "{{ testcase }}.yaml"
delegate_to: localhost
register: test_cases
- name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
- name: enable eapi
eos_eapi:
http: yes
https: yes
local_http: no
enable_socket: yes
provider: "{{ cli }}"
- name: run test case
include: "{{ test_case_to_run }}"
- name: run test case (connection=local)
include: "{{ test_case_to_run }} ansible_connection=local"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
- name: disable eapi
eos_eapi:
state: stopped
provider: "{{ cli }}"

View file

@ -1,5 +1,5 @@
---
- debug: msg="START cli/bad_operator.yaml"
- debug: msg="START cli/bad_operator.yaml on connection={{ ansible_connection }}"
- name: test bad operator
eos_command:
@ -17,4 +17,4 @@
- "result.failed == true"
- "result.msg is defined"
- debug: msg="END cli/bad_operator.yaml"
- debug: msg="END cli/bad_operator.yaml on connection={{ ansible_connection }}"

View file

@ -1,5 +1,5 @@
---
- debug: msg="START cli/contains.yaml"
- debug: msg="START cli/contains.yaml on connection={{ ansible_connection }}"
- name: test contains operator
eos_command:
@ -17,4 +17,4 @@
- "result.changed == false"
- "result.stdout is defined"
- debug: msg="END cli/contains.yaml"
- debug: msg="END cli/contains.yaml on connection={{ ansible_connection }}"

View file

@ -1,5 +1,5 @@
---
- debug: msg="START cli/equal.yaml"
- debug: msg="START cli/equal.yaml on connection={{ ansible_connection }}"
- name: test eq operator
eos_command:
@ -31,4 +31,4 @@
- "result.changed == false"
- "result.stdout is defined"
- debug: msg="END cli/equal.yaml"
- debug: msg="END cli/equal.yaml on connection={{ ansible_connection }}"

View file

@ -1,5 +1,5 @@
---
- debug: msg="START cli/greaterthan.yaml"
- debug: msg="START cli/greaterthan.yaml on connection={{ ansible_connection }}"
- name: test gt operator
eos_command:
@ -31,4 +31,4 @@
- "result.changed == false"
- "result.stdout is defined"
- debug: msg="END cli/greaterthan.yaml"
- debug: msg="END cli/greaterthan.yaml on connection={{ ansible_connection }}"

View file

@ -1,5 +1,5 @@
---
- debug: msg="START cli/greaterthanorequal.yaml"
- debug: msg="START cli/greaterthanorequal.yaml on connection={{ ansible_connection }}"
- name: test ge operator
eos_command:
@ -31,4 +31,4 @@
- "result.changed == false"
- "result.stdout is defined"
- debug: msg="END cli/greaterthanorequal.yaml"
- debug: msg="END cli/greaterthanorequal.yaml on connection={{ ansible_connection }}"

View file

@ -1,5 +1,5 @@
---
- debug: msg="START cli/invalid.yaml"
- debug: msg="START cli/invalid.yaml on connection={{ ansible_connection }}"
- name: run invalid command
eos_command:
@ -27,4 +27,4 @@
- "result.failed == true"
- "result.msg is defined"
- debug: msg="END cli/invalid.yaml"
- debug: msg="END cli/invalid.yaml on connection={{ ansible_connection }}"

View file

@ -1,5 +1,5 @@
---
- debug: msg="START cli/lessthan.yaml"
- debug: msg="START cli/lessthan.yaml on connection={{ ansible_connection }}"
- name: test lt operator
eos_command:
@ -31,4 +31,4 @@
- "result.changed == false"
- "result.stdout is defined"
- debug: msg="END cli/lessthan.yaml"
- debug: msg="END cli/lessthan.yaml on connection={{ ansible_connection }}"

View file

@ -1,5 +1,5 @@
---
- debug: msg="START cli/lessthanorequal.yaml"
- debug: msg="START cli/lessthanorequal.yaml on connection={{ ansible_connection }}"
- name: test le operator
eos_command:
@ -31,4 +31,4 @@
- "result.changed == false"
- "result.stdout is defined"
- debug: msg="END cli/lessthanorequal.yaml"
- debug: msg="END cli/lessthanorequal.yaml on connection={{ ansible_connection }}"

View file

@ -1,5 +1,5 @@
---
- debug: msg="START cli/notequal.yaml"
- debug: msg="START cli/notequal.yaml on connection={{ ansible_connection }}"
- name: test neq operator
eos_command:
@ -31,4 +31,4 @@
- "result.changed == false"
- "result.stdout is defined"
- debug: msg="END cli/notequal.yaml"
- debug: msg="END cli/notequal.yaml on connection={{ ansible_connection }}"

View file

@ -1,5 +1,5 @@
---
- debug: msg="START cli/output.yaml"
- debug: msg="START cli/output.yaml on connection={{ ansible_connection }}"
- name: get output for single command
eos_command:
@ -25,4 +25,4 @@
- "result.changed == false"
- "result.stdout is defined"
- debug: msg="END cli/output.yaml"
- debug: msg="END cli/output.yaml on connection={{ ansible_connection }}"

View file

@ -1,5 +1,5 @@
---
- debug: msg="START cli/timeout.yaml"
- debug: msg="START cli/timeout.yaml on connection={{ ansible_connection }}"
- name: test bad condition
eos_command:
@ -16,4 +16,4 @@
- "result.failed == true"
- "result.msg is defined"
- debug: msg="END cli/timeout.yaml"
- debug: msg="END cli/timeout.yaml on connection={{ ansible_connection }}"

View file

@ -4,12 +4,19 @@
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 }}"
- name: run test case
include: "{{ test_case_to_run }}"
- name: run test cases (connection=network_cli)
include: "{{ test_case_to_run }} ansible_connection=network_cli"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
- name: run test case (connection=local)
include: "{{ test_case_to_run }} ansible_connection=local ansible_become=no"
with_first_found: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

View file

@ -3,26 +3,14 @@
find:
paths: "{{ role_path }}/tests/eapi"
patterns: "{{ testcase }}.yaml"
delegate_to: localhost
register: test_cases
- name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
- name: enable eapi
eos_eapi:
http: yes
https: yes
local_http: no
socket: yes
provider: "{{ cli }}"
- name: run test case
include: "{{ test_case_to_run }}"
- name: run test case (connection=local)
include: "{{ test_case_to_run }} ansible_connection=local"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
- name: disable eapi
eos_eapi:
state: stopped
provider: "{{ cli }}"

View file

@ -1,5 +1,5 @@
---
- debug: msg="START cli/backup.yaml"
- debug: msg="START cli/backup.yaml on connection={{ ansible_connection }}"
- name: setup
eos_config:
@ -10,13 +10,14 @@
- interface Ethernet2
match: none
provider: "{{ cli }}"
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
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -41,10 +43,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 }}"

View file

@ -1,16 +1,18 @@
---
- debug: msg="START cli/config.yaml"
- debug: msg="START cli/config.yaml on connection={{ ansible_connection }}"
- name: setup
eos_config:
lines: hostname {{ inventory_hostname_short }}
match: none
provider: "{{ cli }}"
become: yes
- name: get current running-config
eos_command:
commands: show running-config
provider: "{{ cli }}"
become: yes
register: config
- name: configure hostname
@ -18,6 +20,7 @@
lines: hostname foo
config: "{{ config.stdout[0] }}"
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -29,6 +32,7 @@
eos_command:
commands: show running-config
provider: "{{ cli }}"
become: yes
register: config
- name: configure hostname again
@ -36,6 +40,7 @@
lines: hostname foo
config: "{{ config.stdout[0] }}"
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -47,5 +52,6 @@
lines: hostname {{ inventory_hostname_short }}
match: none
provider: "{{ cli }}"
become: yes
- debug: msg="END cli/config.yaml"
- debug: msg="END cli/config.yaml on connection={{ ansible_connection }}"

View file

@ -1,5 +1,5 @@
---
- debug: msg="START cli/defaults.yaml"
- debug: msg="START cli/defaults.yaml on connection={{ ansible_connection }}"
- name: setup
eos_config:
@ -10,12 +10,14 @@
- interface Ethernet2
match: none
provider: "{{ cli }}"
become: yes
- name: configure device with defaults included
eos_config:
src: defaults/config.j2
defaults: yes
provider: "{{ cli }}"
become: yes
register: result
- debug: var=result
@ -30,6 +32,7 @@
src: defaults/config.j2
defaults: yes
provider: "{{ cli }}"
become: yes
register: result
- debug: var=result
@ -39,4 +42,4 @@
- "result.changed == false"
- "result.updates is not defined"
- debug: msg="END cli/defaults.yaml"
- debug: msg="END cli/defaults.yaml on connection={{ ansible_connection }}"

View file

@ -1,5 +1,5 @@
---
- debug: msg="START cli/save.yaml"
- debug: msg="START cli/save.yaml on connection={{ ansible_connection }}"
- name: setup
eos_config:
@ -10,12 +10,14 @@
- interface Ethernet2
match: none
provider: "{{ cli }}"
become: yes
- name: save config always
eos_config:
save_when: always
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -26,10 +28,11 @@
eos_config:
save_when: always
provider: "{{ cli }}"
become: yes
register: result
- assert:
that:
- "result.changed == true"
- debug: msg="END cli/save.yaml"
- debug: msg="END cli/save.yaml on connection={{ ansible_connection }}"

View file

@ -1,5 +1,5 @@
---
- debug: msg="START cli/src_basic.yaml"
- debug: msg="START cli/src_basic.yaml on connection={{ ansible_connection }}"
- name: setup
eos_config:
@ -10,11 +10,13 @@
- interface Ethernet2
match: none
provider: "{{ cli }}"
become: yes
- name: configure device with config
eos_config:
src: basic/config.j2
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -28,6 +30,7 @@
src: basic/config.j2
defaults: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -36,4 +39,4 @@
# https://github.com/ansible/ansible-modules-core/issues/4807
- "result.updates is not defined"
- debug: msg="END cli/src_basic.yaml"
- debug: msg="END cli/src_basic.yaml on connection={{ ansible_connection }}"

View file

@ -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 @@
eos_config:
src: basic/foobar.j2
provider: "{{ cli }}"
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 }}"

View file

@ -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
eos_config:
@ -10,12 +10,14 @@
- interface Ethernet2
match: none
provider: "{{ cli }}"
become: yes
- name: configure device with config
eos_config:
src: basic/config.j2
provider: "{{ cli }}"
match: none
become: yes
register: result
- assert:
@ -29,6 +31,7 @@
src: basic/config.j2
defaults: yes
provider: "{{ cli }}"
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 }}"

View file

@ -1,17 +1,19 @@
---
- debug: msg="START cli/sublevel.yaml"
- debug: msg="START cli/sublevel.yaml on connection={{ ansible_connection }}"
- name: setup
eos_config:
lines: no vlan 10
match: none
provider: "{{ cli }}"
become: yes
- name: configure sub level command
eos_config:
lines: name test
parents: vlan 10
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -25,6 +27,7 @@
lines: name test
parents: vlan 10
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -36,6 +39,7 @@
lines: no vlan 10
match: none
provider: "{{ cli }}"
become: yes
- debug: msg="END cli/sublevel.yaml"
- debug: msg="END cli/sublevel.yaml on connection={{ ansible_connection }}"

View file

@ -1,5 +1,5 @@
---
- debug: msg="START cli/sublevel_block.yaml"
- debug: msg="START cli/sublevel_block.yaml on connection={{ ansible_connection }}"
- name: setup
eos_config:
@ -12,6 +12,7 @@
after: exit
match: none
provider: "{{ cli }}"
become: yes
- name: configure sub level command using block resplace
eos_config:
@ -24,6 +25,7 @@
replace: block
after: exit
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -46,6 +48,7 @@
replace: block
after: exit
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -57,5 +60,6 @@
lines: no ip access-list test
match: none
provider: "{{ cli }}"
become: yes
- debug: msg="END cli/sublevel_block.yaml"
- debug: msg="END cli/sublevel_block.yaml on connection={{ ansible_connection }}"

View file

@ -1,5 +1,5 @@
---
- debug: msg="START cli/sublevel_exact.yaml"
- debug: msg="START cli/sublevel_exact.yaml on connection={{ ansible_connection }}"
- name: setup
eos_config:
@ -14,6 +14,7 @@
after: exit
match: none
provider: "{{ cli }}"
become: yes
- name: configure sub level command using exact match
eos_config:
@ -28,6 +29,7 @@
match: exact
replace: block
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -50,6 +52,7 @@
parents: ip access-list test
match: exact
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -61,5 +64,6 @@
lines: no ip access-list test
match: none
provider: "{{ cli }}"
become: yes
- debug: msg="END cli/sublevel_exact.yaml"
- debug: msg="END cli/sublevel_exact.yaml on connection={{ ansible_connection }}"

View file

@ -1,5 +1,5 @@
---
- debug: msg="START cli/sublevel_strict.yaml"
- debug: msg="START cli/sublevel_strict.yaml on connection={{ ansible_connection }}"
- name: setup
eos_config:
@ -14,6 +14,7 @@
after: exit
match: none
provider: "{{ cli }}"
become: yes
- name: configure sub level command using strict match
eos_config:
@ -28,6 +29,7 @@
match: strict
replace: block
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -50,6 +52,7 @@
parents: ip access-list test
match: strict
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -61,5 +64,6 @@
lines: no ip access-list test
match: none
provider: "{{ cli }}"
become: yes
- debug: msg="END cli/sublevel_strict.yaml"
- debug: msg="END cli/sublevel_strict.yaml on connection={{ ansible_connection }}"

View file

@ -1,16 +1,18 @@
---
- debug: msg="START cli/toplevel.yaml"
- debug: msg="START cli/toplevel.yaml on connection={{ ansible_connection }}"
- name: setup
eos_config:
lines: hostname veos01
match: none
provider: "{{ cli }}"
become: yes
- name: configure top level command
eos_config:
lines: hostname foo
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -22,6 +24,7 @@
eos_config:
lines: hostname foo
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -33,5 +36,6 @@
lines: hostname veos01
match: none
provider: "{{ cli }}"
become: yes
- debug: msg="END cli/toplevel.yaml"
- debug: msg="END cli/toplevel.yaml on connection={{ ansible_connection }}"

View file

@ -1,5 +1,5 @@
---
- debug: msg="START cli/toplevel_after.yaml"
- debug: msg="START cli/toplevel_after.yaml on connection={{ ansible_connection }}"
- name: setup
eos_config:
@ -8,12 +8,14 @@
- hostname veos01
match: none
provider: "{{ cli }}"
become: yes
- name: configure top level command with before
eos_config:
lines: hostname foo
after: snmp-server contact bar
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -27,6 +29,7 @@
lines: hostname foo
after: snmp-server contact foo
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -40,5 +43,6 @@
- hostname veos01
match: none
provider: "{{ cli }}"
become: yes
- debug: msg="END cli/toplevel_after.yaml"
- debug: msg="END cli/toplevel_after.yaml on connection={{ ansible_connection }}"

View file

@ -1,5 +1,5 @@
---
- debug: msg="START cli/toplevel_before.yaml"
- debug: msg="START cli/toplevel_before.yaml on connection={{ ansible_connection }}"
- name: setup
eos_config:
@ -8,12 +8,14 @@
- hostname veos01
match: none
provider: "{{ cli }}"
become: yes
- name: configure top level command with before
eos_config:
lines: hostname foo
before: snmp-server contact bar
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -27,6 +29,7 @@
lines: hostname foo
before: snmp-server contact foo
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -40,5 +43,6 @@
- no snmp-server contact
match: none
provider: "{{ cli }}"
become: yes
- debug: msg="END cli/toplevel_before.yaml"
- debug: msg="END cli/toplevel_before.yaml on connection={{ ansible_connection }}"

View file

@ -4,12 +4,19 @@
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 }}"
- name: run test case
include: "{{ test_case_to_run }}"
- name: run test cases (connection=network_cli)
include: "{{ test_case_to_run }} ansible_connection=network_cli"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
- name: run test case (connection=local)
include: "{{ test_case_to_run }} ansible_connection=local ansible_become=no"
with_first_found: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

View file

@ -1,27 +1,26 @@
- debug: msg="START cli/config.yaml"
---
- debug: msg="START cli/config.yaml on connection={{ ansible_connection }}"
#----
- name: Setup
eos_config:
lines: no management api http-commands
match: none
provider: "{{ cli }}"
connection: local
become: yes
- name: Get running-config
eos_command:
commands: show running-config
provider: "{{ cli }}"
become: yes
register: config
connection: local
- name: Set config
eos_eapi:
config: "{{ config.stdout[0] }}"
provider: "{{ cli }}"
become: yes
register: config
connection: local
- name: Ensure that this triggered a change
assert:
@ -33,15 +32,15 @@
eos_command:
commands: show running-config
provider: "{{ cli }}"
become: yes
register: config
connection: local
- name: Set config
eos_eapi:
config: "{{ config.stdout[0] }}"
provider: "{{ cli }}"
become: yes
register: config
connection: local
- name: Idempotency check
@ -49,4 +48,4 @@
that:
- "config.changed == false"
- debug: msg="END cli/config.yaml"
- debug: msg="END cli/config.yaml on connection={{ ansible_connection }}"

View file

@ -8,15 +8,14 @@
enable_local_http: yes
local_http_port: 8181
provider: "{{ cli }}"
become: yes
register: eos_eapi_output
connection: local
- eos_command:
commands:
- show management api http-commands | json
provider: "{{ cli }}"
register: http_config
connection: local
- name: Expect endpoint ports to be set
assert:
@ -32,8 +31,8 @@
enable_local_http: yes
local_http_port: 8181
provider: "{{ cli }}"
become: yes
register: eos_eapi_output
connection: local
- name: Expect action to be idempotent
assert:

View file

@ -7,8 +7,8 @@
enable_local_http: no
enable_socket: no
provider: "{{ cli }}"
become: yes
register: eos_eapi_output
connection: local
- debug: var=eos_eapi_output
@ -17,7 +17,6 @@
- show management api http-commands | json
provider: "{{ cli }}"
register: http_config
connection: local
- debug: var=http_config
@ -36,8 +35,8 @@
enable_local_http: no
enable_socket: no
provider: "{{ cli }}"
become: yes
register: eos_eapi_output
connection: local
- debug: var=eos_eapi_output
when: debug

View file

@ -7,15 +7,14 @@
enable_local_http: yes
enable_socket: yes
provider: "{{ cli }}"
become: yes
register: eos_eapi_output
connection: local
- eos_command:
commands:
- show management api http-commands | json
provider: "{{ cli }}"
register: http_config
connection: local
- debug: var=http_config
when: debug
@ -35,8 +34,8 @@
enable_local_http: yes
enable_socket: yes
provider: "{{ cli }}"
become: yes
register: eos_eapi_output
connection: local
- debug: var=eos_eapi_output

View file

@ -4,15 +4,14 @@
eos_eapi:
state: started
provider: "{{ cli }}"
become: yes
register: eos_eapi_output
connection: local
- eos_command:
commands:
- show management api http-commands | json
provider: "{{ cli }}"
register: http_config
connection: local
- debug: var=http_config
when: debug
@ -25,8 +24,8 @@
eos_eapi:
state: started
provider: "{{ cli }}"
become: yes
register: eos_eapi_output
connection: local
- debug: var=eos_eapi_output
when: debug

View file

@ -4,15 +4,14 @@
eos_eapi:
state: stopped
provider: "{{ cli }}"
become: yes
register: eos_eapi_output
connection: local
- eos_command:
commands:
- show management api http-commands | json
provider: "{{ cli }}"
register: http_config
connection: local
- debug: var=http_config
when: debug
@ -25,8 +24,8 @@
eos_eapi:
state: stopped
provider: "{{ cli }}"
become: yes
register: eos_eapi_output
connection: local
- debug: var=eos_eapi_output
when: debug

View file

@ -1,13 +1,12 @@
- debug: msg="START cli/vrf.yaml"
---
- debug: msg="START cli/vrf.yaml on connection={{ ansible_connection }}"
#----
- name: Set invalid VRF
eos_eapi:
vrf: foobar
provider: "{{ cli }}"
become: yes
register: eos_eapi_output
connection: local
ignore_errors: true
- name: Ensure that setting VRF failed
@ -22,8 +21,8 @@
eos_eapi:
vrf: default
provider: "{{ cli }}"
become: yes
register: eos_eapi_output
connection: local
ignore_errors: true
@ -31,8 +30,8 @@
eos_eapi:
vrf: default
provider: "{{ cli }}"
become: yes
register: eos_eapi_output
connection: local
- name: Ensure idempotent
assert:
@ -48,10 +47,9 @@
commands: show vrf
provider: "{{ cli }}"
register: eos_eapi_output
connection: local
when: false
#- debug:
# msg: "{{ eos_eapi_output }}"
- debug: msg="END cli/vrf.yaml"
- debug: msg="END cli/vrf.yaml on connection={{ ansible_connection }}"

View file

@ -4,12 +4,19 @@
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 }}"
- name: run test case
include: "{{ test_case_to_run }}"
- name: run test cases (connection=network_cli)
include: "{{ test_case_to_run }} ansible_connection=network_cli"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
- name: run test case (connection=local)
include: "{{ test_case_to_run }} ansible_connection=local ansible_become=no"
with_first_found: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

View file

@ -3,26 +3,14 @@
find:
paths: "{{ role_path }}/tests/eapi"
patterns: "{{ testcase }}.yaml"
delegate_to: localhost
register: test_cases
- name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
- name: enable eapi
eos_eapi:
http: yes
https: yes
local_http: no
enable_socket: yes
provider: "{{ cli }}"
- name: run test case
include: "{{ test_case_to_run }}"
- name: run test case (connection=local)
include: "{{ test_case_to_run }} ansible_connection=local"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
- name: disable eapi
eos_eapi:
state: stopped
provider: "{{ cli }}"

View file

@ -1,5 +1,5 @@
---
- debug: msg="START cli/all_facts.yaml"
- debug: msg="START cli/all_facts.yaml on connection={{ ansible_connection }}"
- name: test getting all facts
@ -7,6 +7,7 @@
provider: "{{ cli }}"
gather_subset:
- all
become: yes
register: result
@ -28,4 +29,4 @@
- "result.ansible_facts.ansible_net_memfree_mb > 1"
- "result.ansible_facts.ansible_net_memtotal_mb > 1"
- debug: msg="END cli/all_facts.yaml"
- debug: msg="END cli/all_facts.yaml on connection={{ ansible_connection }}"

View file

@ -1,10 +1,11 @@
---
- debug: msg="START cli/default_facts.yaml"
- debug: msg="START cli/default_facts.yaml on connection={{ ansible_connection }}"
- name: test getting default facts
eos_facts:
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -28,4 +29,4 @@
# ... and not present
- "result.ansible_facts.ansible_net_config is not defined" # config
- debug: msg="END cli/default.yaml"
- debug: msg="END cli/default.yaml on connection={{ ansible_connection }}"

View file

@ -1,5 +1,5 @@
---
- debug: msg="START cli/invalid_subset.yaml"
- debug: msg="START cli/invalid_subset.yaml on connection={{ ansible_connection }}"
- name: test invalid subset (foobar)
@ -45,4 +45,4 @@
- debug: msg="END cli/invalid_subset.yaml"
- debug: msg="END cli/invalid_subset.yaml on connection={{ ansible_connection }}"

View file

@ -1,5 +1,5 @@
---
- debug: msg="START cli/not_hardware_facts.yaml"
- debug: msg="START cli/not_hardware_facts.yaml on connection={{ ansible_connection }}"
- name: test not hardware
@ -7,6 +7,7 @@
provider: "{{ cli }}"
gather_subset:
- "!hardware"
become: yes
register: result
- assert:
@ -27,4 +28,4 @@
# ... and not present
- "result.ansible_facts.ansible_net_filesystems is not defined"
- debug: msg="END cli/not_hardware_facts.yaml"
- debug: msg="END cli/not_hardware_facts.yaml on connection={{ ansible_connection }}"

View file

@ -4,12 +4,19 @@
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 }}"
- name: run test case
include: "{{ test_case_to_run }}"
- name: run test cases (connection=network_cli)
include: "{{ test_case_to_run }} ansible_connection=network_cli"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
- name: run test case (connection=local)
include: "{{ test_case_to_run }} ansible_connection=local ansible_become=no"
with_first_found: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

View file

@ -3,26 +3,14 @@
find:
paths: "{{ role_path }}/tests/eapi"
patterns: "{{ testcase }}.yaml"
delegate_to: localhost
register: test_cases
- name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
- name: enable eapi
eos_eapi:
http: yes
https: yes
local_http: no
enable_socket: yes
provider: "{{ cli }}"
- name: run test case
include: "{{ test_case_to_run }}"
- name: run test case (connection=local)
include: "{{ test_case_to_run }} ansible_connection=local"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
- name: disable eapi
eos_eapi:
state: stopped
provider: "{{ cli }}"

View file

@ -1,4 +1,6 @@
---
- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}"
- name: Set up host logging
eos_logging:
dest: host
@ -6,6 +8,7 @@
state: present
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -20,6 +23,7 @@
state: present
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -33,6 +37,7 @@
state: absent
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -47,6 +52,7 @@
state: absent
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -60,6 +66,7 @@
state: present
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -73,6 +80,7 @@
size: 480000
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -87,6 +95,7 @@
- { dest: buffered, size: 480000, state: absent }
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:

View file

@ -4,12 +4,19 @@
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 }}"
- name: run test case
include: "{{ test_case_to_run }}"
- name: run test cases (connection=network_cli)
include: "{{ test_case_to_run }} ansible_connection=network_cli"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
- name: run test case (connection=local)
include: "{{ test_case_to_run }} ansible_connection=local ansible_become=no"
with_first_found: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

View file

@ -1,5 +1,5 @@
---
- debug: msg="START cli/basic.yaml"
- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}"
- name: setup - remove config used in test
eos_config:
@ -9,6 +9,7 @@
- no ip route 192.168.5.0/24 192.168.0.1
authorize: yes
provider: "{{ cli }}"
become: yes
- name: configure static route
eos_static_route: &single_route
@ -17,6 +18,7 @@
admin_distance: 2
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -26,6 +28,7 @@
- name: configure static route(Idempotence)
eos_static_route: *single_route
become: yes
register: result
- assert:
@ -40,6 +43,7 @@
authorize: yes
provider: "{{ cli }}"
state: absent
become: yes
register: result
- assert:
@ -49,6 +53,7 @@
- name: delete static route
eos_static_route: *delete_single
become: yes
register: result
- assert:
@ -62,6 +67,7 @@
- { address: 192.168.5.0/24, next_hop: 192.168.0.1 }
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -72,6 +78,7 @@
- name: configure static routes using aggregate(Idemporence)
eos_static_route: *configure_aggregate
become: yes
register: result
- assert:
@ -86,6 +93,7 @@
authorize: yes
state: absent
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -96,6 +104,7 @@
- name: delete static routes using aggregate(Idempotence)
eos_static_route: *delete_aggregate
become: yes
register: result
- assert:
@ -110,5 +119,6 @@
- no ip route 192.168.5.0/24 192.168.0.1
authorize: yes
provider: "{{ cli }}"
become: yes
- debug: msg="END cli/basic.yaml"
- debug: msg="END cli/basic.yaml on connection={{ ansible_connection }}"

View file

@ -4,12 +4,19 @@
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 }}" #"
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
- name: run test case
include: "{{ test_case_to_run }}"
- name: run test cases (connection=network_cli)
include: "{{ test_case_to_run }} ansible_connection=network_cli"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
- name: run test case (connection=local)
include: "{{ test_case_to_run }} ansible_connection=local ansible_become=no"
with_first_found: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

View file

@ -3,26 +3,14 @@
find:
paths: "{{ role_path }}/tests/eapi"
patterns: "{{ testcase }}.yaml"
delegate_to: localhost
register: test_cases
- 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 }}"
- name: enable eapi
eos_eapi:
http: yes
https: yes
local_http: no
enable_socket: yes
provider: "{{ cli }}"
- name: run test case
include: "{{ test_case_to_run }}"
- name: run test case (connection=local)
include: "{{ test_case_to_run }} ansible_connection=local"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
- name: disable eapi
eos_eapi:
state: stopped
provider: "{{ cli }}"

View file

@ -1,5 +1,5 @@
---
- debug: msg="START cli/set_domain_list.yaml"
- debug: msg="START cli/set_domain_list.yaml on connection={{ ansible_connection }}"
- name: setup
eos_config:
@ -8,6 +8,7 @@
- no ip domain-list redhat.com
match: none
provider: "{{ cli }}"
become: yes
- name: configure domain_list
eos_system:
@ -15,6 +16,7 @@
- ansible.com
- redhat.com
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -29,6 +31,7 @@
- ansible.com
- redhat.com
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -40,6 +43,7 @@
domain_list:
- ansible.com
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -52,6 +56,7 @@
domain_list:
- ansible.com
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -64,6 +69,7 @@
- ansible.com
- redhat.com
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -77,6 +83,7 @@
- ansible.com
- redhat.com
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -89,6 +96,7 @@
- ansible.com
- eng.ansible.com
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -104,6 +112,7 @@
- ansible.com
- eng.ansible.com
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -118,5 +127,6 @@
- no ip domain-list eng.ansible.com
match: none
provider: "{{ cli }}"
become: yes
- debug: msg="END cli/set_domain_list.yaml"
- debug: msg="END cli/set_domain_list.yaml on connection={{ ansible_connection }}"

View file

@ -1,16 +1,18 @@
---
- debug: msg="START cli/set_domain_name.yaml"
- debug: msg="START cli/set_domain_name.yaml on connection={{ ansible_connection }}"
- name: setup
eos_config:
lines: no ip domain-name
match: none
provider: "{{ cli }}"
become: yes
- name: configure domain_name
eos_system:
domain_name: eng.ansible.com
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -21,6 +23,7 @@
eos_system:
domain_name: eng.ansible.com
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -32,5 +35,6 @@
lines: no ip domain-name
match: none
provider: "{{ cli }}"
become: yes
- debug: msg="END cli/set_domain_name.yaml"
- debug: msg="END cli/set_domain_name.yaml on connection={{ ansible_connection }}"

View file

@ -1,16 +1,18 @@
---
- debug: msg="START cli/set_hostname.yaml"
- debug: msg="START cli/set_hostname.yaml on connection={{ ansible_connection }}"
- name: setup
eos_config:
lines: hostname switch
match: none
provider: "{{ cli }}"
become: yes
- name: configure hostname
eos_system:
hostname: foo
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -21,6 +23,7 @@
eos_system:
hostname: foo
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -32,5 +35,6 @@
lines: "hostname {{ inventory_hostname }}"
match: none
provider: "{{ cli }}"
become: yes
- debug: msg="END cli/set_hostname.yaml"
- debug: msg="END cli/set_hostname.yaml on connection={{ ansible_connection }}"

View file

@ -1,5 +1,5 @@
---
- debug: msg="START cli/set_lookup_source.yaml"
- debug: msg="START cli/set_lookup_source.yaml on connection={{ ansible_connection }}"
- name: setup
eos_config:
@ -8,11 +8,13 @@
- vrf definition ansible
match: none
provider: "{{ cli }}"
become: yes
- name: configure lookup_source
eos_system:
lookup_source: Management1
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -24,6 +26,7 @@
eos_system:
lookup_source: Management1
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -36,6 +39,7 @@
- interface: Management1
vrf: ansible
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -51,6 +55,7 @@
- interface: Management1
vrf: ansible
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -64,5 +69,6 @@
- no vrf definition ansible
match: none
provider: "{{ cli }}"
become: yes
- debug: msg="END cli/set_lookup_source.yaml"
- debug: msg="END cli/set_lookup_source.yaml on connection={{ ansible_connection }}"

View file

@ -1,5 +1,5 @@
---
- debug: msg="START cli/set_name_servers.yaml"
- debug: msg="START cli/set_name_servers.yaml on connection={{ ansible_connection }}"
- name: setup
eos_config:
@ -8,6 +8,7 @@
- vrf definition ansible
match: none
provider: "{{ cli }}"
become: yes
- name: configure name_servers
eos_system:
@ -16,6 +17,7 @@
- 2.2.2.2
- 3.3.3.3
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -33,6 +35,7 @@
- 2.2.2.2
- 3.3.3.3
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -74,6 +77,7 @@
- 1.1.1.1
- 2.2.2.2
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -89,5 +93,6 @@
- no vrf definition ansible
match: none
provider: "{{ cli }}"
become: yes
- debug: msg="END cli/set_name_servers.yaml"
- debug: msg="END cli/set_name_servers.yaml on connection={{ ansible_connection }}"

View file

@ -4,12 +4,19 @@
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 }}"
- name: run test case
include: "{{ test_case_to_run }}"
- name: run test cases (connection=network_cli)
include: "{{ test_case_to_run }} ansible_connection=network_cli"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
- name: run test case (connection=local)
include: "{{ test_case_to_run }} ansible_connection=local ansible_become=no"
with_first_found: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

View file

@ -3,26 +3,14 @@
find:
paths: "{{ role_path }}/tests/eapi"
patterns: "{{ testcase }}.yaml"
delegate_to: localhost
register: test_cases
- name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
- name: enable eapi
eos_eapi:
http: yes
https: yes
local_http: no
enable_socket: yes
provider: "{{ cli }}"
- name: run test case
include: "{{ test_case_to_run }}"
- name: run test case (connection=local)
include: "{{ test_case_to_run }} ansible_connection=local"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
- name: disable eapi
eos_eapi:
state: stopped
provider: "{{ cli }}"

View file

@ -9,6 +9,7 @@
authorize: yes
provider: "{{ cli }}"
configured_password: pass123
become: yes
- name: test login
expect:
@ -36,4 +37,5 @@
state: absent
provider: "{{ cli }}"
authorize: yes
become: yes
register: result

View file

@ -1,4 +1,6 @@
---
- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}"
- name: Set Up
eos_config:
lines:
@ -7,6 +9,7 @@
- no username ansibletest3
- no username ansibletest4
provider: "{{ cli }}"
become: yes
- name: Create user with role
eos_user:
@ -17,6 +20,7 @@
configured_password: test1
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -36,6 +40,7 @@
authorize: yes
update_password: on_create
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -54,6 +59,7 @@
state: present
role: network-operator
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -73,6 +79,7 @@
state: present
authorize: yes
provider: "{{ cli }}"
become: yes
ignore_errors: yes
register: result
@ -90,3 +97,5 @@
- no username ansibletest3
- no username ansibletest4
provider: "{{ cli }}"
authorize: yes
become: yes

View file

@ -4,12 +4,19 @@
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 }}"
- name: run test case
include: "{{ test_case_to_run }}"
- name: run test cases (connection=network_cli)
include: "{{ test_case_to_run }} ansible_connection=network_cli"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
- name: run test case (connection=local)
include: "{{ test_case_to_run }} ansible_connection=local ansible_become=no"
with_first_found: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

View file

@ -8,6 +8,7 @@
- no vlan 4002
authorize: yes
provider: "{{ cli }}"
become: yes
- name: setup - remove switchport settings on interface Ethernet1 used in test
eos_config:
@ -17,6 +18,7 @@
parents: interface Ethernet1
authorize: yes
provider: "{{ cli }}"
become: yes
- name: setup - remove switchport settings on interface Ethernet2 used in test
eos_config:
@ -26,6 +28,7 @@
parents: interface Ethernet2
authorize: yes
provider: "{{ cli }}"
become: yes
- name: Create vlan
eos_vlan:
@ -34,6 +37,7 @@
state: present
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -51,6 +55,7 @@
state: present
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -67,6 +72,7 @@
state: suspend
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -85,6 +91,7 @@
state: suspend
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -100,6 +107,7 @@
state: active
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -119,6 +127,7 @@
- Ethernet2
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -141,6 +150,7 @@
- Ethernet2
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -158,6 +168,7 @@
- Ethernet1
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -177,6 +188,7 @@
- Ethernet1
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -194,6 +206,7 @@
state: present
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -213,6 +226,7 @@
state: present
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -231,6 +245,7 @@
purge: yes
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -251,6 +266,7 @@
purge: yes
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:

View file

@ -4,12 +4,19 @@
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 }}"
- name: run test case
include: "{{ test_case_to_run }}"
- name: run test cases (connection=network_cli)
include: "{{ test_case_to_run }} ansible_connection=network_cli"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
- name: run test case (connection=local)
include: "{{ test_case_to_run }} ansible_connection=local ansible_become=no"
with_first_found: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

View file

@ -6,6 +6,7 @@
state: absent
authorize: yes
provider: "{{ cli }}"
become: yes
- name: setup - remove vrf
eos_vrf:
@ -13,6 +14,7 @@
state: absent
authorize: yes
provider: "{{ cli }}"
become: yes
- name: setup - remove vrf
eos_vrf:
@ -20,6 +22,7 @@
state: absent
authorize: yes
provider: "{{ cli }}"
become: yes
- name: Create vrf
eos_vrf:
@ -28,6 +31,7 @@
state: present
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -45,6 +49,7 @@
state: present
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -61,6 +66,7 @@
state: present
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -78,6 +84,7 @@
state: present
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -96,6 +103,7 @@
interfaces:
- Ethernet2
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -115,6 +123,7 @@
interfaces:
- Ethernet2
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -132,6 +141,7 @@
state: present
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -152,6 +162,7 @@
state: present
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -170,6 +181,7 @@
purge: yes
authorize: yes
provider: "{{ cli }}"
become: yes
register: result
- assert:
@ -191,6 +203,7 @@
state: absent
authorize: yes
provider: "{{ cli }}"
become: yes
- name: Delete VRFs again (idempotent)
eos_vrf:
@ -198,6 +211,7 @@
state: absent
authorize: yes
provider: "{{ cli }}"
become: yes
- name: Delete aggregate of VRFs
eos_vrf:
@ -209,6 +223,7 @@
state: absent
authorize: yes
provider: "{{ cli }}"
become: yes
- name: Delete VRFs again (idempotent)
eos_vrf:
@ -220,6 +235,7 @@
state: absent
authorize: yes
provider: "{{ cli }}"
become: yes
# FIXME add in tests for everything defined in docs
# FIXME Test state:absent + test:

View file

@ -4,9 +4,8 @@
- no shutdown
- no switchport
parents: int Ethernet1
authorize: yes
provider: "{{ cli }}"
connection: local
become: yes
connection: network_cli
- name: Enable Ethernet2 interface and disable switchport
eos_config:
@ -14,6 +13,15 @@
- no shutdown
- no switchport
parents: int Ethernet2
authorize: yes
provider: "{{ cli }}"
connection: local
become: yes
connection: network_cli
- name: enable eapi
eos_eapi:
http: yes
https: yes
local_http: no
enable_socket: yes
become: yes
connection: network_cli
tags: eapi

View file

@ -72,17 +72,11 @@ class ManageNetworkCI(object):
def wait(self):
"""Wait for instance to respond to ansible ping."""
if self.core_ci.platform in ('vyos',):
connection_type = 'network_cli'
else:
connection_type = 'local'
extra_vars = [
'ansible_host=%s' % self.core_ci.connection.hostname,
'ansible_port=%s' % self.core_ci.connection.port,
'ansible_connection=%s' % connection_type,
'ansible_connection=local',
'ansible_ssh_private_key_file=%s' % self.core_ci.ssh_key.key,
'ansible_network_os=%s' % self.core_ci.platform,
]
name = '%s-%s' % (self.core_ci.platform, self.core_ci.version.replace('.', '-'))