mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 13:20:23 -07:00
nxos_rpm module (#40849)
* Add nxos_rpm feature * fix timing issues * fix timing issues * shippable fix * review comment * review comments fixes * typo fix
This commit is contained in:
parent
276358c885
commit
9abc3dbec4
7 changed files with 467 additions and 0 deletions
2
test/integration/targets/nxos_rpm/defaults/main.yaml
Normal file
2
test/integration/targets/nxos_rpm/defaults/main.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
testcase: "*"
|
2
test/integration/targets/nxos_rpm/meta/main.yml
Normal file
2
test/integration/targets/nxos_rpm/meta/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
dependencies:
|
||||
- prepare_nxos_tests
|
27
test/integration/targets/nxos_rpm/tasks/cli.yaml
Normal file
27
test/integration/targets/nxos_rpm/tasks/cli.yaml
Normal file
|
@ -0,0 +1,27 @@
|
|||
---
|
||||
- name: collect common test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/common"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
connection: local
|
||||
register: test_cases
|
||||
|
||||
- name: collect cli test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/cli"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
connection: local
|
||||
register: cli_cases
|
||||
|
||||
- set_fact:
|
||||
test_cases:
|
||||
files: "{{ test_cases.files }} + {{ cli_cases.files }}"
|
||||
|
||||
- name: set test_items
|
||||
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
|
||||
|
||||
- name: run test cases (connection=network_cli)
|
||||
include: "{{ test_case_to_run }} ansible_connection=network_cli connection={{ cli }}"
|
||||
with_items: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
3
test/integration/targets/nxos_rpm/tasks/main.yaml
Normal file
3
test/integration/targets/nxos_rpm/tasks/main.yaml
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
- { include: cli.yaml, tags: ['cli'] }
|
||||
- { include: nxapi.yaml, tags: ['nxapi'] }
|
33
test/integration/targets/nxos_rpm/tasks/nxapi.yaml
Normal file
33
test/integration/targets/nxos_rpm/tasks/nxapi.yaml
Normal file
|
@ -0,0 +1,33 @@
|
|||
---
|
||||
- name: collect common test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/common"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
connection: local
|
||||
register: test_cases
|
||||
|
||||
- name: collect nxapi test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/nxapi"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
connection: local
|
||||
register: nxapi_cases
|
||||
|
||||
- set_fact:
|
||||
test_cases:
|
||||
files: "{{ test_cases.files }} + {{ nxapi_cases.files }}"
|
||||
|
||||
- name: set test_items
|
||||
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
|
||||
|
||||
- name: run test cases (connection=httpapi)
|
||||
include: "{{ test_case_to_run }} ansible_connection=httpapi connection={{ nxapi }}"
|
||||
with_items: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
||||
|
||||
- name: run test cases (connection=local)
|
||||
include: "{{ test_case_to_run }} ansible_connection=local connection={{ nxapi }}"
|
||||
with_items: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
95
test/integration/targets/nxos_rpm/tests/common/sanity.yaml
Normal file
95
test/integration/targets/nxos_rpm/tests/common/sanity.yaml
Normal file
|
@ -0,0 +1,95 @@
|
|||
---
|
||||
- debug: msg="START connection={{ ansible_connection }} nxos_rpm sanity test"
|
||||
- debug: msg="Using provider={{ connection.transport }}"
|
||||
when: ansible_connection == "local"
|
||||
|
||||
- set_fact: smu_run="false"
|
||||
- set_fact: smu_run="true"
|
||||
when: ((platform is search('N9K')) and (imagetag and (imagetag is version_compare('I2', 'ge'))))
|
||||
|
||||
- set_fact: sdk_run="false"
|
||||
- set_fact: sdk_run="true"
|
||||
when: ((platform is search('N9K')) and (imagetag and (imagetag is version_compare('I6', 'ge'))))
|
||||
|
||||
# The smu and nxsdk packages MUST be present on the device before the tests are run.
|
||||
# The smu patch must be built to match the image version under test
|
||||
# Only run this test after replacing the pkg with proper rpm files
|
||||
|
||||
- debug: msg="***WARNING*** Remove meta end_play to verify this module ***WARNING***"
|
||||
|
||||
- meta: end_play
|
||||
|
||||
- block:
|
||||
- name: Install smu RPM
|
||||
nxos_rpm: &tsmurpm
|
||||
pkg: "nxos.sample-n9k_ALL-1.0.0-7.0.3.I7.3.lib32_n9000.rpm"
|
||||
register: result
|
||||
|
||||
- assert: &true1
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: Check Idempotence
|
||||
nxos_rpm: *tsmurpm
|
||||
register: result
|
||||
|
||||
- assert: &false1
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: Remove smu RPM
|
||||
nxos_rpm: &rsmurpm
|
||||
pkg: "nxos.sample-n9k_ALL-1.0.0-7.0.3.I7.3.lib32_n9000.rpm"
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- assert: *true1
|
||||
|
||||
- name: Check Idempotence
|
||||
nxos_rpm: *rsmurpm
|
||||
register: result
|
||||
|
||||
- assert: *false1
|
||||
|
||||
when: smu_run
|
||||
|
||||
# healthMonitor-1.0-1.5.0.x86_64.rpm is avaibale at https://github.com/CiscoDevNet/NX-SDK/tree/master/rpm/RPMS
|
||||
- block:
|
||||
- name: Install nxsdk RPM(aggregate)
|
||||
nxos_rpm: &tsdkrpm
|
||||
aggregate:
|
||||
- { pkg: "healthMonitor-1.0-1.5.0.x86_64.rpm", file_system: "bootflash" }
|
||||
- { pkg: "customCliApp-1.0-1.0.0.x86_64.rpm" }
|
||||
register: result
|
||||
|
||||
- assert: &true2
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: Check Idempotence
|
||||
nxos_rpm: *tsdkrpm
|
||||
register: result
|
||||
|
||||
- assert: &false2
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: Remove nxsdk RPM(aggregate)
|
||||
nxos_rpm: &rsdkrpm
|
||||
aggregate:
|
||||
- { pkg: "healthMonitor-1.0-1.5.0.x86_64.rpm" }
|
||||
- { pkg: "customCliApp-1.0-1.0.0.x86_64.rpm" }
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- assert: *true2
|
||||
|
||||
- name: Check Idempotence
|
||||
nxos_rpm: *rsdkrpm
|
||||
register: result
|
||||
|
||||
- assert: *false2
|
||||
|
||||
when: sdk_run
|
||||
|
||||
- debug: msg="END connection={{ ansible_connection }} nxos_rpm sanity test"
|
Loading…
Add table
Add a link
Reference in a new issue