mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 06:12:51 +00:00
nxos: merge nxapi/cli tests - config, bgp_neighbor, command, bgp_af (#28235)
* refactor nxos_bgp_af * refactor nxos_bgp_neighbor * refactor nxos_command * refactor nxos_config * removed accidental file
This commit is contained in:
committed by
Trishna Guha
parent
d4e7b045b7
commit
5df02dc288
@@ -1,50 +0,0 @@
|
||||
---
|
||||
- debug: msg="START cli/backup.yaml"
|
||||
|
||||
- name: setup
|
||||
nxos_config:
|
||||
commands:
|
||||
- no description
|
||||
- no shutdown
|
||||
parents:
|
||||
- interface Ethernet2/5
|
||||
match: none
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- name: collect any backup files
|
||||
find:
|
||||
paths: "{{ role_path }}/backup"
|
||||
pattern: "{{ inventory_hostname_short }}_config*"
|
||||
register: backup_files
|
||||
delegate_to: localhost
|
||||
|
||||
- name: delete backup files
|
||||
file:
|
||||
path: "{{ item.path }}"
|
||||
state: absent
|
||||
with_items: "{{backup_files.files|default([])}}"
|
||||
|
||||
- name: configure device with config
|
||||
nxos_config:
|
||||
src: basic/config.j2
|
||||
backup: yes
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "result.updates is defined"
|
||||
|
||||
- name: collect any backup files
|
||||
find:
|
||||
paths: "{{ role_path }}/backup"
|
||||
pattern: "{{ inventory_hostname_short }}_config*"
|
||||
register: backup_files
|
||||
delegate_to: localhost
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "backup_files.files is defined"
|
||||
|
||||
- debug: msg="END cli/backup.yaml"
|
||||
@@ -1,42 +0,0 @@
|
||||
---
|
||||
- debug: msg="START cli/defaults.yaml"
|
||||
|
||||
- name: setup
|
||||
nxos_config:
|
||||
commands:
|
||||
- no description
|
||||
- shutdown
|
||||
parents:
|
||||
- interface Ethernet2/5
|
||||
match: none
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- name: configure device with defaults included
|
||||
nxos_config:
|
||||
src: defaults/config.j2
|
||||
defaults: yes
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- debug: var=result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "result.updates is defined"
|
||||
|
||||
- name: check device with defaults included
|
||||
nxos_config:
|
||||
src: defaults/config.j2
|
||||
defaults: yes
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- debug: var=result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.updates is not defined"
|
||||
|
||||
- debug: msg="END cli/defaults.yaml"
|
||||
@@ -1,35 +0,0 @@
|
||||
---
|
||||
- debug: msg="START cli/save.yaml"
|
||||
|
||||
- name: setup
|
||||
nxos_config:
|
||||
commands:
|
||||
- no description
|
||||
- no shutdown
|
||||
parents:
|
||||
- interface Ethernet2/5
|
||||
match: none
|
||||
provider: "{{ cli }}"
|
||||
|
||||
|
||||
- name: save config
|
||||
nxos_config:
|
||||
save: true
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: save should always run
|
||||
nxos_config:
|
||||
save: true
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- debug: msg="END cli/save.yaml"
|
||||
@@ -1,40 +0,0 @@
|
||||
---
|
||||
- debug: msg="START cli/src_basic.yaml"
|
||||
|
||||
- name: setup
|
||||
nxos_config:
|
||||
commands:
|
||||
- no description
|
||||
- no shutdown
|
||||
parents:
|
||||
- interface Ethernet2/5
|
||||
match: none
|
||||
provider: "{{ cli }}"
|
||||
|
||||
- name: configure device with config
|
||||
nxos_config:
|
||||
src: basic/config.j2
|
||||
defaults: yes
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
# https://github.com/ansible/ansible-modules-core/issues/4807
|
||||
- "result.updates is defined"
|
||||
|
||||
- name: check device with config
|
||||
nxos_config:
|
||||
src: basic/config.j2
|
||||
defaults: yes
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
# https://github.com/ansible/ansible-modules-core/issues/4807
|
||||
- "result.updates is not defined"
|
||||
|
||||
- debug: msg="END cli/src_basic.yaml"
|
||||
@@ -1,19 +0,0 @@
|
||||
---
|
||||
- debug: msg="START cli/src_invalid.yaml"
|
||||
|
||||
|
||||
# Defend https://github.com/ansible/ansible-modules-core/issues/4797
|
||||
- name: configure with invalid src
|
||||
nxos_config:
|
||||
src: basic/foobar.j2
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "result.failed == true"
|
||||
- "result.msg == 'path specified in src not found'"
|
||||
|
||||
- debug: msg="END cli/src_invalid.yaml"
|
||||
@@ -1,37 +0,0 @@
|
||||
---
|
||||
- debug: msg='START cli/toplevel.yaml'
|
||||
|
||||
- name: setup
|
||||
nxos_config:
|
||||
lines: hostname {{ inventory_hostname_short }}
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- name: configure top level command
|
||||
nxos_config:
|
||||
lines: hostname foo
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'hostname foo' in result.updates"
|
||||
|
||||
- name: configure top level command idempotent check
|
||||
nxos_config:
|
||||
lines: hostname foo
|
||||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: teardown
|
||||
nxos_config:
|
||||
lines: hostname {{ inventory_hostname_short }}
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- debug: msg='END cli/toplevel.yaml'
|
||||
@@ -1,39 +0,0 @@
|
||||
---
|
||||
- debug: msg="START cli/nonidempotent.yaml"
|
||||
|
||||
- name: setup
|
||||
nxos_config:
|
||||
lines: hostname {{ inventory_hostname_short }}
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- name: configure top level command
|
||||
nxos_config:
|
||||
lines: hostname foo
|
||||
provider: "{{ cli }}"
|
||||
match: strict
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "'hostname foo' in result.updates"
|
||||
|
||||
- name: configure top level command idempotent check
|
||||
nxos_config:
|
||||
lines: hostname foo
|
||||
provider: "{{ cli }}"
|
||||
match: strict
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: teardown
|
||||
nxos_config:
|
||||
lines: hostname {{ inventory_hostname_short }}
|
||||
provider: "{{ cli }}"
|
||||
match: none
|
||||
|
||||
- debug: msg="END cli/nonidempotent.yaml"
|
||||
Reference in New Issue
Block a user