2017-10-25 17:41:23 +02:00
|
|
|
---
|
2018-05-24 16:51:18 +02:00
|
|
|
- debug: msg="START connection={{ ansible_connection }} nxos_file_copy sanity test"
|
2017-10-25 17:41:23 +02:00
|
|
|
|
2019-08-29 21:57:39 +02:00
|
|
|
# This test uses a file that is committed to the Ansible core repository.
|
|
|
|
# The file name and relative path is test/integration/targets/network-integration.cfg
|
|
|
|
- set_fact: test_source_file="network-integration.cfg"
|
|
|
|
- set_fact: test_destination_file="test_destination_file"
|
|
|
|
|
2017-10-25 17:41:23 +02:00
|
|
|
- name: "Setup - Remove existing file"
|
|
|
|
nxos_command: &remove_file
|
|
|
|
commands:
|
|
|
|
- terminal dont-ask
|
2019-08-29 21:57:39 +02:00
|
|
|
- "delete {{ test_source_file }}"
|
|
|
|
- "delete {{ test_destination_file }}"
|
|
|
|
- "delete bootflash:/dir1/dir2/dir3/*"
|
2018-08-03 07:03:06 +02:00
|
|
|
- rmdir dir1/dir2/dir3
|
|
|
|
- rmdir dir1/dir2
|
|
|
|
- rmdir dir1
|
2017-10-25 17:41:23 +02:00
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- name: "Setup - Turn on feature scp-server"
|
2019-08-29 21:57:39 +02:00
|
|
|
nxos_feature:
|
2017-10-25 17:41:23 +02:00
|
|
|
feature: scp-server
|
|
|
|
state: enabled
|
|
|
|
|
|
|
|
- block:
|
2019-08-29 21:57:39 +02:00
|
|
|
- name: "Copy {{ test_source_file }} file from Ansible controller to bootflash"
|
2017-10-25 17:41:23 +02:00
|
|
|
nxos_file_copy: ©_file_same_name
|
2019-08-29 21:57:39 +02:00
|
|
|
local_file: "./{{ test_source_file }}"
|
2017-10-25 17:41:23 +02:00
|
|
|
file_system: "bootflash:"
|
2017-11-28 06:24:23 +01:00
|
|
|
connect_ssh_port: "{{ ansible_ssh_port }}"
|
2017-10-25 17:41:23 +02:00
|
|
|
register: result
|
|
|
|
|
2019-08-29 21:57:39 +02:00
|
|
|
- assert:
|
2017-10-25 17:41:23 +02:00
|
|
|
that:
|
|
|
|
- "result.changed == true"
|
2019-08-29 21:57:39 +02:00
|
|
|
- "'bootflash:' in result.file_system"
|
|
|
|
- "'./{{ test_source_file }}' in result.local_file"
|
|
|
|
- "'network-integration.cfg' in result.remote_file"
|
|
|
|
- "'Sent: File copied to remote device.' in result.transfer_status"
|
2017-10-25 17:41:23 +02:00
|
|
|
|
2019-08-29 21:57:39 +02:00
|
|
|
- name: "Idempotence - Copy {{ test_source_file }} file from Ansible controller to bootflash"
|
2017-10-25 17:41:23 +02:00
|
|
|
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
|
|
|
|
|
2019-08-29 21:57:39 +02:00
|
|
|
- name: "Copy {{ test_source_file }} file from Ansible controller to bootflash renamed as {{ test_destination_file }}"
|
2017-10-25 17:41:23 +02:00
|
|
|
nxos_file_copy: ©_file_different_name
|
2019-08-29 21:57:39 +02:00
|
|
|
local_file: "./{{ test_source_file }}"
|
|
|
|
remote_file: "{{ test_destination_file }}"
|
2017-10-25 17:41:23 +02:00
|
|
|
file_system: "bootflash:"
|
2017-11-28 06:24:23 +01:00
|
|
|
connect_ssh_port: "{{ ansible_ssh_port }}"
|
2017-10-25 17:41:23 +02:00
|
|
|
register: result
|
|
|
|
|
2019-08-29 21:57:39 +02:00
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == true"
|
|
|
|
- "'bootflash:' in result.file_system"
|
|
|
|
- "'./{{ test_source_file }}' in result.local_file"
|
|
|
|
- "'{{ test_destination_file }}' in result.remote_file"
|
|
|
|
- "'Sent: File copied to remote device.' in result.transfer_status"
|
2017-10-25 17:41:23 +02:00
|
|
|
|
2019-08-29 21:57:39 +02:00
|
|
|
- name: "Idempotence - Copy {{ test_source_file }} file from Ansible controller to bootflash renamed as {{ test_destination_file }}"
|
2017-10-25 17:41:23 +02:00
|
|
|
nxos_file_copy: *copy_file_different_name
|
|
|
|
register: result
|
|
|
|
|
2019-08-29 21:57:39 +02:00
|
|
|
- name: "Verify file_pull true options have no impact when file_true is false"
|
|
|
|
nxos_file_copy:
|
|
|
|
file_pull: False
|
|
|
|
file_pull_timeout: 1200
|
|
|
|
file_pull_compact: True
|
|
|
|
file_pull_kstack: True
|
|
|
|
local_file_directory: "dir1/dir2/dir3"
|
|
|
|
remote_scp_server: "{{ inventory_hostname_short }}"
|
|
|
|
remote_scp_server_user: "{{ ansible_ssh_user }}"
|
|
|
|
remote_scp_server_password: "{{ ansible_ssh_pass }}"
|
|
|
|
# Parameters above are only used when file_pull is True
|
|
|
|
local_file: "./{{ test_source_file }}"
|
|
|
|
remote_file: "{{ test_destination_file }}"
|
|
|
|
file_system: "bootflash:"
|
|
|
|
connect_ssh_port: "{{ ansible_ssh_port }}"
|
|
|
|
register: result
|
|
|
|
|
2017-10-25 17:41:23 +02:00
|
|
|
- assert: *false
|
|
|
|
|
2019-08-29 21:57:39 +02:00
|
|
|
# This step validates the ability to initiate the copy from the nxos device
|
|
|
|
# to pull a file from a remote file server to the nxos bootflash device.
|
|
|
|
#
|
|
|
|
# In this case we are using the nxos device as the remote file server so we
|
|
|
|
# copy a file from bootflash: to bootflash:dir1/dir2/dir3
|
|
|
|
- name: "Initiate copy from nxos device to copy {{ test_destination_file }} to bootflash:dir1/dir2/dir3/{{ test_destination_file }}_copy"
|
|
|
|
nxos_file_copy: ©_pull
|
|
|
|
file_pull: True
|
|
|
|
file_pull_timeout: 30
|
|
|
|
remote_file: "/{{ test_destination_file }}"
|
|
|
|
local_file: "{{ test_destination_file }}_copy"
|
|
|
|
local_file_directory: "dir1/dir2/dir3"
|
|
|
|
remote_scp_server: "{{ inventory_hostname_short }}"
|
|
|
|
remote_scp_server_user: "{{ ansible_ssh_user }}"
|
|
|
|
remote_scp_server_password: "{{ ansible_ssh_pass }}"
|
|
|
|
register: result
|
2018-07-25 14:16:55 +02:00
|
|
|
|
2019-08-29 21:57:39 +02:00
|
|
|
- assert: &overwrite
|
|
|
|
that:
|
|
|
|
- "result.changed == true"
|
|
|
|
- "'copy scp:' in result.copy_cmd"
|
|
|
|
- "'bootflash:' in result.file_system"
|
|
|
|
- "'bootflash:dir1/dir2/dir3/{{ test_destination_file }}_copy' in result.local_file"
|
|
|
|
- "'/{{ test_destination_file }}' in result.remote_file"
|
|
|
|
- "'Received: File copied/pulled to nxos device from remote scp server.' in result.transfer_status"
|
|
|
|
- "'{{ inventory_hostname_short }}' in result.remote_scp_server"
|
|
|
|
|
|
|
|
- name: "Overwrite the file"
|
|
|
|
nxos_file_copy: *copy_pull
|
|
|
|
register: result
|
2017-10-25 17:41:23 +02:00
|
|
|
|
2019-08-29 21:57:39 +02:00
|
|
|
- assert: *overwrite
|
2017-10-25 17:41:23 +02:00
|
|
|
|
|
|
|
always:
|
|
|
|
|
|
|
|
- name: "Remove file"
|
|
|
|
nxos_command: *remove_file
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- name: "Turn off feature scp-server"
|
|
|
|
nxos_feature:
|
|
|
|
feature: scp-server
|
|
|
|
state: disabled
|
|
|
|
|
2018-05-24 16:51:18 +02:00
|
|
|
- debug: msg="END connection={{ ansible_connection }} nxos_file_copy sanity test"
|