mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-16 22:19:12 -07:00
nxos_file_copy network_cli and httpapi fix (#40592)
* Leverage action plugin to pass credentials to nxos_file_copy for network_cli, httpapi Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * update integration test Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * make sure local test uses provider Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * update tests Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * update doc Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * clarify action plugin comment Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * Add connection=local back to nxos_file_copy because that module is weird Also blacklist it running on nxapi, because that is meaningless * remove provider Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * blacklist nxapi Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> * Address review comment Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
This commit is contained in:
parent
94049680c3
commit
c2f7f36fc5
7 changed files with 46 additions and 112 deletions
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
- name: collect common cli test cases
|
||||
- name: collect common test cases
|
||||
find:
|
||||
paths: "{{ role_path }}/tests/common"
|
||||
patterns: "{{ testcase }}.yaml"
|
||||
|
@ -21,13 +21,13 @@
|
|||
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={}"
|
||||
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 connection={{ cli }}"
|
||||
with_first_found: "{{ test_items }}"
|
||||
- name: run test cases (connection=local)
|
||||
include: "{{ test_case_to_run }} ansible_connection=local"
|
||||
with_items: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
||||
|
|
|
@ -25,3 +25,9 @@
|
|||
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"
|
||||
with_items: "{{ test_items }}"
|
||||
loop_control:
|
||||
loop_var: test_case_to_run
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
---
|
||||
- debug: msg="START TRANSPORT:CLI nxos_file_copy sanity test"
|
||||
- debug: msg="Using provider={{ connection.transport }}"
|
||||
when: ansible_connection == "local"
|
||||
- debug: msg="START connection={{ ansible_connection }} nxos_file_copy sanity test"
|
||||
|
||||
- name: "Setup - Remove existing file"
|
||||
nxos_command: &remove_file
|
||||
|
@ -20,9 +18,6 @@
|
|||
nxos_file_copy: ©_file_same_name
|
||||
local_file: "./network-integration.cfg"
|
||||
file_system: "bootflash:"
|
||||
username: "{{ ansible_ssh_user }}"
|
||||
password: "{{ ansible_ssh_pass }}"
|
||||
host: "{{ ansible_host }}"
|
||||
connect_ssh_port: "{{ ansible_ssh_port }}"
|
||||
register: result
|
||||
|
||||
|
@ -47,9 +42,6 @@
|
|||
local_file: "./inventory.networking.template"
|
||||
remote_file: "network-integration.cfg"
|
||||
file_system: "bootflash:"
|
||||
username: "{{ ansible_ssh_user }}"
|
||||
password: "{{ ansible_ssh_pass }}"
|
||||
host: "{{ ansible_host }}"
|
||||
connect_ssh_port: "{{ ansible_ssh_port }}"
|
||||
register: result
|
||||
|
||||
|
@ -80,4 +72,4 @@
|
|||
feature: scp-server
|
||||
state: disabled
|
||||
|
||||
- debug: msg="END TRANSPORT:CLI nxos_file_copy sanity test"
|
||||
- debug: msg="END connection={{ ansible_connection }} nxos_file_copy sanity test"
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
---
|
||||
- debug: msg="START nxapi/badtransport.yaml"
|
||||
|
||||
- name: Sending transport other than cli should fail
|
||||
nxos_file_copy:
|
||||
local_file: "./network-integration.cfg"
|
||||
file_system: "bootflash:"
|
||||
connect_ssh_port: "{{ ansible_ssh_port }}"
|
||||
provider: "{{ nxapi }}"
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.failed and result.msg is search('Transport')
|
||||
|
||||
- debug: msg="END nxapi/badtransport.yaml"
|
|
@ -1,87 +0,0 @@
|
|||
---
|
||||
- debug: msg="START TRANSPORT:NXAPI nxos_file_copy sanity test"
|
||||
- debug: msg="Using provider={{ connection.transport }}"
|
||||
when: ansible_connection == "local"
|
||||
|
||||
- name: "Setup - Remove existing file"
|
||||
nxos_command: &remove_file
|
||||
commands:
|
||||
- command: terminal dont-ask
|
||||
output: text
|
||||
- command: delete network-integration.cfg
|
||||
output: text
|
||||
ignore_errors: yes
|
||||
|
||||
- name: "Setup - Turn on feature scp-server"
|
||||
nxos_feature:
|
||||
feature: scp-server
|
||||
state: enabled
|
||||
|
||||
- block:
|
||||
- name: "Copy network-integration.cfg to bootflash"
|
||||
nxos_file_copy: ©_file_same_name
|
||||
local_file: "./network-integration.cfg"
|
||||
file_system: "bootflash:"
|
||||
username: "{{ ansible_ssh_user }}"
|
||||
password: "{{ ansible_ssh_pass }}"
|
||||
host: "{{ ansible_host }}"
|
||||
connect_ssh_port: "{{ ansible_ssh_port }}"
|
||||
register: result
|
||||
|
||||
- assert: &true
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: "Check Idempotence - Copy network-integration.cfg to bootflash"
|
||||
nxos_file_copy: *copy_file_same_name
|
||||
register: result
|
||||
|
||||
- assert: &false
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: "Setup - Remove existing file"
|
||||
nxos_command: *remove_file
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- name: "Copy inventory.networking.template to bootflash as another name"
|
||||
nxos_file_copy: ©_file_different_name
|
||||
local_file: "./inventory.networking.template"
|
||||
remote_file: "network-integration.cfg"
|
||||
file_system: "bootflash:"
|
||||
username: "{{ ansible_ssh_user }}"
|
||||
password: "{{ ansible_ssh_pass }}"
|
||||
host: "{{ ansible_host }}"
|
||||
connect_ssh_port: "{{ ansible_ssh_port }}"
|
||||
register: result
|
||||
|
||||
- assert: *true
|
||||
|
||||
- name: "Check Idempotence - Copy inventory.networking.template to bootflash as another name"
|
||||
nxos_file_copy: *copy_file_different_name
|
||||
register: result
|
||||
|
||||
- assert: *false
|
||||
|
||||
- name: "Setup - Remove existing file"
|
||||
nxos_command: *remove_file
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
rescue:
|
||||
|
||||
- debug: msg="TRANSPORT:NXAPI nxos_file_copy failure detected"
|
||||
|
||||
always:
|
||||
|
||||
- name: "Remove file"
|
||||
nxos_command: *remove_file
|
||||
ignore_errors: yes
|
||||
|
||||
- name: "Turn off feature scp-server"
|
||||
nxos_feature:
|
||||
feature: scp-server
|
||||
state: disabled
|
||||
|
||||
- debug: msg="END TRANSPORT:NXAPI nxos_file_copy sanity test"
|
Loading…
Add table
Add a link
Reference in a new issue