mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 21:00:22 -07: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:
parent
f64b276f6a
commit
513c75079e
70 changed files with 393 additions and 249 deletions
|
@ -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
|
||||
|
|
|
@ -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 }}"
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 }}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue