2017-10-25 15:41:23 +00:00
|
|
|
---
|
2018-05-24 14:51:18 +00:00
|
|
|
- debug: msg="START connection={{ ansible_connection }} nxos_file_copy sanity test"
|
2017-10-25 15:41:23 +00:00
|
|
|
|
|
|
|
- name: "Setup - Remove existing file"
|
|
|
|
nxos_command: &remove_file
|
|
|
|
commands:
|
|
|
|
- terminal dont-ask
|
2018-02-02 12:54:53 +00:00
|
|
|
- delete network-integration.cfg
|
2018-08-03 05:03:06 +00:00
|
|
|
- delete bootflash:/dir1/dir2/dir3/network-integration_copy.cfg
|
|
|
|
- rmdir dir1/dir2/dir3
|
|
|
|
- rmdir dir1/dir2
|
|
|
|
- rmdir dir1
|
2017-10-25 15:41:23 +00:00
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- name: "Setup - Turn on feature scp-server"
|
|
|
|
nxos_feature:
|
|
|
|
feature: scp-server
|
|
|
|
state: enabled
|
|
|
|
|
|
|
|
- block:
|
2018-02-02 12:54:53 +00:00
|
|
|
- name: "Copy network-integration.cfg to bootflash"
|
2017-10-25 15:41:23 +00:00
|
|
|
nxos_file_copy: ©_file_same_name
|
2018-02-02 12:54:53 +00:00
|
|
|
local_file: "./network-integration.cfg"
|
2017-10-25 15:41:23 +00:00
|
|
|
file_system: "bootflash:"
|
2017-11-28 05:24:23 +00:00
|
|
|
connect_ssh_port: "{{ ansible_ssh_port }}"
|
2017-10-25 15:41:23 +00:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: &true
|
|
|
|
that:
|
|
|
|
- "result.changed == true"
|
|
|
|
|
2018-02-02 12:54:53 +00:00
|
|
|
- name: "Check Idempotence - Copy network-integration.cfg to bootflash"
|
2017-10-25 15:41:23 +00: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
|
|
|
|
|
2018-02-02 12:54:53 +00:00
|
|
|
- name: "Copy inventory.networking.template to bootflash as another name"
|
2017-10-25 15:41:23 +00:00
|
|
|
nxos_file_copy: ©_file_different_name
|
2018-02-02 12:54:53 +00:00
|
|
|
local_file: "./inventory.networking.template"
|
|
|
|
remote_file: "network-integration.cfg"
|
2017-10-25 15:41:23 +00:00
|
|
|
file_system: "bootflash:"
|
2017-11-28 05:24:23 +00:00
|
|
|
connect_ssh_port: "{{ ansible_ssh_port }}"
|
2017-10-25 15:41:23 +00:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: *true
|
|
|
|
|
2018-02-02 12:54:53 +00:00
|
|
|
- name: "Check Idempotence - Copy inventory.networking.template to bootflash as another name"
|
2017-10-25 15:41:23 +00:00
|
|
|
nxos_file_copy: *copy_file_different_name
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: *false
|
|
|
|
|
2018-07-25 12:16:55 +00:00
|
|
|
- name: "Copy file using file_pull"
|
|
|
|
nxos_file_copy: ©_pull
|
|
|
|
file_pull: True
|
|
|
|
file_pull_timeout: 1200
|
|
|
|
remote_file: "/network-integration.cfg"
|
2018-08-03 05:03:06 +00:00
|
|
|
local_file: "network-integration_copy.cfg"
|
|
|
|
local_file_directory: "dir1/dir2/dir3"
|
2018-07-25 12:16:55 +00:00
|
|
|
remote_scp_server: "{{ inventory_hostname_short }}"
|
|
|
|
remote_scp_server_user: "{{ ansible_ssh_user }}"
|
|
|
|
remote_scp_server_password: "{{ ansible_ssh_pass }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: *true
|
|
|
|
|
|
|
|
- name: "Overwrite the file"
|
|
|
|
nxos_file_copy: *copy_pull
|
2017-10-25 15:41:23 +00:00
|
|
|
register: result
|
|
|
|
|
2018-07-25 12:16:55 +00:00
|
|
|
- assert: *true
|
|
|
|
|
2017-10-25 15:41:23 +00:00
|
|
|
rescue:
|
|
|
|
|
|
|
|
- debug: msg="TRANSPORT:CLI 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
|
|
|
|
|
2018-05-24 14:51:18 +00:00
|
|
|
- debug: msg="END connection={{ ansible_connection }} nxos_file_copy sanity test"
|