Fix issues with nxos_os_install module (#48811)

* Use expect module to copy files

* Remove old and redundant upgrade files

* Return error message instead of code

* Cleanup copy command code

* Fix force issue in nxos_install_os

* new nxos_install_os integration tests

* Uncomment transport tests

* Revert negative test change

* Remove combined option that is no longer required

* Make shippable happy

* Add n5k test files
This commit is contained in:
Mike Wiebe 2018-11-19 23:44:15 -05:00 committed by Trishna Guha
parent 10095a397c
commit a721572206
32 changed files with 492 additions and 185 deletions

View file

@ -10,7 +10,7 @@
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
- name: run test cases (ansible_connection=httpapi)
include: "{{ test_case_to_run }} ansible_connection=httpapi"
include: "{{ test_case_to_run }} ansible_connection=httpapi connection={{ nxapi }}"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

View file

@ -10,7 +10,7 @@
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
- name: run test cases (ansible_connection=network_cli)
include: "{{ test_case_to_run }} ansible_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

View file

@ -4,24 +4,25 @@
when: ansible_connection == 'httpapi'
- include: targets/nxos_install_os/tasks/upgrade/enable_scp_server.yaml
when: connection is not defined
- include: targets/nxos_install_os/tasks/upgrade/enable_scp_server_provider.yaml
when: connection is defined
- name: "Copy {{ si }} to bootflash"
nxos_file_copy:
local_file: "{{image_dir}}{{ si }}"
file_system: "bootflash:"
file_pull: True
file_pull_timeout: 1200
remote_file: "{{image_dir}}{{ si }}"
remote_scp_server: 192.168.1.1
remote_scp_server_user: scp_user
remote_scp_server_password: scp_password
register: result
ignore_errors: "{{ ignore_errors_httpapi }}"
- name: "Copy {{ si }} to bootflash"
nxos_file_copy:
local_file: "{{image_dir}}{{ si }}"
file_system: "bootflash:"
register: result
ignore_errors: "{{ ignore_errors_httpapi }}"
#- name: "Copy {{ si }} to bootflash"
# expect:
# command: "scp {{image_dir}}{{ si }} {{ ansible_ssh_user }}@{{ ansible_ssh_host }}:"
# responses:
# (?i)Are you sure you want to continue connecting.*: yes
# (?i)password: "{{ ansible_ssh_pass }}"
# timeout: 1800
# register: result
- debug:
msg: "{{ item.key }} {{ item.value }}"
@ -29,11 +30,24 @@
- name: "Copy {{ ki }} to bootflash"
nxos_file_copy:
local_file: "{{image_dir}}/{{ ki }}"
file_system: "bootflash:"
register: result
file_pull: True
file_pull_timeout: 1200
remote_file: "{{image_dir}}{{ ki }}"
remote_scp_server: 192.168.1.1
remote_scp_server_user: scp_user
remote_scp_server_password: scp_password
when: ki is defined
ignore_errors: "{{ ignore_errors_httpapi }}"
register: result
#- name: "Copy {{ ki }} to bootflash"
# expect:
# command: "scp {{image_dir}}{{ ki }} {{ ansible_ssh_user }}@{{ ansible_ssh_host }}:"
# responses:
# (?i)Are you sure you want to continue connecting.*: yes
# (?i)password: "{{ ansible_ssh_pass }}"
# timeout: 1800
# when: ki is defined
# register: result
- debug:
msg: "{{ item.key }} {{ item.value }}"

View file

@ -6,5 +6,6 @@
- allow delete boot-image
- "delete {{ item }}"
match: none
provider: "{{ connection }}"
ignore_errors: yes
with_items: "{{ delete_image_list }}"

View file

@ -1,11 +0,0 @@
---
- name: "Delete Files To Make Room On Bootflash using provider"
nxos_config: &remove_file
lines:
- terminal dont-ask
- allow delete boot-image
- "delete {{ item }}"
match: none
provider: "{{ connection }}"
ignore_errors: yes
with_items: "{{ delete_image_list }}"

View file

@ -3,3 +3,4 @@
nxos_feature:
feature: scp-server
state: enabled
provider: "{{ connection }}"

View file

@ -1,6 +0,0 @@
---
- name: "Setup - Turn on feature scp-server using provider"
nxos_feature:
feature: scp-server
state: enabled
provider: "{{ connection }}"

View file

@ -1,15 +1,15 @@
---
- include: targets/nxos_install_os/tasks/upgrade/delete_files.yaml
when: delete_image_list is defined
when: delete_files
- include: targets/nxos_install_os/tasks/upgrade/copy_kick_system_images.yaml
when: copy_images is defined
- include: "targets/nxos_install_os/tasks/upgrade/copy_kick_system_images.yaml ansible_connection=network_cli connection={{ cli }}"
when: copy_images
- include: targets/nxos_install_os/tasks/upgrade/install_with_kick.yaml
when: ki is defined and combined is undefined
when: ki is defined
- include: targets/nxos_install_os/tasks/upgrade/install_system.yaml
when: combined is defined
when: ki is undefined
# Only needed when - meta: reset_connection does not work. Fixed in 2.6
#- include: targets/nxos_install_os/tasks/upgrade/clear_persistent_sockets.yaml
@ -19,6 +19,7 @@
- name: "Check installed OS for newly installed version {{ tv }}"
nxos_command:
commands: ['show version | json']
provider: "{{ connection }}"
register: output
- debug: msg="Version detected {{ output['stdout_lines'][0]['kickstart_ver_str'] }}"

View file

@ -1,25 +0,0 @@
---
- include: targets/nxos_install_os/tasks/upgrade/delete_files_provider.yaml
when: delete_image_list is defined
- include: targets/nxos_install_os/tasks/upgrade/copy_kick_system_images.yaml
when: copy_images is defined
- include: targets/nxos_install_os/tasks/upgrade/install_with_kick_provider.yaml
when: ki is defined and combined is undefined
- include: targets/nxos_install_os/tasks/upgrade/install_system_provider.yaml
when: combined is defined
# Only needed when - meta: reset_connection does not work. Fixed in 2.6
#- include: targets/nxos_install_os/tasks/upgrade/clear_persistent_sockets.yaml
- meta: reset_connection
- name: "Check installed OS for newly installed version {{ tv }}"
nxos_command:
commands: ['show version | json']
provider: "{{ connection }}"
register: output
- debug: msg="Version detected {{ output['stdout_lines'][0]['kickstart_ver_str'] }}"

View file

@ -4,9 +4,31 @@
nxos_install_os:
system_image_file: "{{ si }}"
issu: "{{ issu }}"
provider: "{{ connection }}"
register: result
when: not force
- name: "Set OS image {{ si }} boot pointers"
nxos_config:
lines:
- no boot nxos
- no boot kickstart
- no boot system
- "boot nxos bootflash:{{ si }}"
- copy run start
match: line
provider: "{{ connection }}"
when: force
- name: "Boot image {{ si }} using reload"
nxos_command:
commands: 'terminal dont-ask ; reload'
provider: "{{ connection }}"
ignore_errors: yes
when: force
- debug: msg=" {{ result['install_state'] }}"
when: not force
- name: Wait for device to come back up with new image
wait_for:

View file

@ -1,25 +0,0 @@
---
- name: "Install OS image {{ si }} using provider"
check_mode: "{{ checkmode }}"
nxos_install_os:
system_image_file: "{{ si }}"
issu: "{{ issu }}"
provider: "{{ connection }}"
register: result
- debug: msg=" {{ result['install_state'] }}"
- name: Wait for device to come back up with new image
wait_for:
port: 22
state: started
timeout: 500
delay: 60
host: "{{ inventory_hostname }}"
when: result.changed and not checkmode
- debug: msg='Wait 5 mins to allow system to stabilize'
when: result.changed and not checkmode
- pause:
seconds: 300
when: result.changed and not checkmode

View file

@ -5,9 +5,31 @@
system_image_file: "{{ si }}"
kickstart_image_file: "{{ ki }}"
issu: "{{ issu }}"
provider: "{{ connection }}"
register: result
when: not force
- name: "Set OS image {{ si }} boot pointers"
nxos_config:
lines:
- no boot kickstart
- no boot system
- "boot kickstart bootflash:{{ ki }}"
- "boot system bootflash:{{ si }}"
- copy run start
match: line
provider: "{{ connection }}"
when: force
- name: "Boot image {{ si }} using reload"
nxos_command:
commands: 'terminal dont-ask ; reload'
provider: "{{ connection }}"
ignore_errors: yes
when: force
- debug: msg=" {{ result['install_state'] }}"
when: not force
- name: Wait for device to come back up with new image
wait_for:

View file

@ -1,26 +0,0 @@
---
- name: "Install OS image {{ si }} using provider"
check_mode: "{{ checkmode }}"
nxos_install_os:
system_image_file: "{{ si }}"
kickstart_image_file: "{{ ki }}"
issu: "{{ issu }}"
provider: "{{ connection }}"
register: result
- debug: msg=" {{ result['install_state'] }}"
- name: Wait for device to come back up with new image
wait_for:
port: 22
state: started
timeout: 500
delay: 60
host: "{{ inventory_hostname }}"
when: result.changed and not checkmode
- debug: msg='Wait 5 mins to allow system to stabilize'
when: result.changed and not checkmode
- pause:
seconds: 300
when: result.changed and not checkmode

View file

@ -4,7 +4,3 @@
- meta: end_play
- include: targets/nxos_install_os/tasks/upgrade/install_os.yaml
when: connection is not defined
- include: targets/nxos_install_os/tasks/upgrade/install_os_provider.yaml
when: connection is defined

View file

@ -1,22 +0,0 @@
---
- name: "Reload to upgrade to OS image {{ si }}"
nxos_config:
lines:
- terminal dont-ask
- no boot nxos
- "boot nxos bootflash:{{ si }}"
- reload
match: none
ignore_errors: yes
- name: Wait for device to come back up with new image
wait_for:
port: 22
state: started
timeout: 500
delay: 60
host: "{{ inventory_hostname }}"
- debug: msg='Wait 5 mins to allow system to stabilize'
- pause:
seconds: 300

View file

@ -1,23 +0,0 @@
---
- name: "Reload to upgrade to OS image {{ si }} using provider"
nxos_config:
lines:
- terminal dont-ask
- no boot nxos
- "boot nxos bootflash:{{ si }}"
- reload
match: none
provider: "{{ connection }}"
ignore_errors: yes
- name: Wait for device to come back up with new image
wait_for:
port: 22
state: started
timeout: 500
delay: 60
host: "{{ inventory_hostname }}"
- debug: msg='Wait 5 mins to allow system to stabilize'
- pause:
seconds: 300

View file

@ -3,12 +3,16 @@
- debug: msg="Using provider={{ connection.transport }}"
when: connection is defined
- set_fact: checkmode='no'
- set_fact: issu='desired'
- set_fact: copy_images='yes'
- set_fact: image_dir='/Users/mwiebe/Projects/nxos_ansible/images/'
- set_fact: checkmode='no'
- set_fact: issu='desired'
- set_fact: copy_images=True
# Set boot pointers and reload
- set_fact: force=False
- set_fact: delete_files=True
- set_fact:
delete_image_list:
- nxos.7.0.3.I7.2.bin
@ -38,18 +42,17 @@
# Upgrade to 6.0(2)U6(3a) #
#---------------------------------------------------------#
- set_fact: si='n3000-uk9.6.0.2.U6.3a.bin'
- set_fact: ki='n3000-uk9-kickstart.6.0.2.U6.3a.bin'
- set_fact: si='n3000-s2-dk9.8.0.1.bin'
- set_fact: ki='n3000-s2-kickstart.8.0.1.bin'
- name: Upgrade to U6.3a
include: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml
#---------------------------------------------------------#
# Upgrade to 7.0(3)I7(3) #
# Upgrade to 7.0(3)I7(2) #
#---------------------------------------------------------#
- set_fact: si='nxos.7.0.3.I7.2.bin'
- set_fact: combined='true'
- name: Upgrade to 7.0.3.I7.2
include: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml

View file

@ -0,0 +1,28 @@
---
- debug: msg="START connection={{ ansible_connection }} nxos_os_install upgrade"
- debug: msg="Using provider={{ connection.transport }}"
when: connection is defined
# Set directory pointer to software images
- set_fact: image_dir='/auto/fe_ssr/agents-ci/agents_images/release_images/greensboro/REL_7_0_3_I7_4/'
- set_fact: checkmode='no'
- set_fact: issu='no'
- set_fact: copy_images=True
# Set boot pointers and reload
- set_fact: force=False
- set_fact: delete_files=True
- set_fact:
delete_image_list:
- nxos*.bin
- n3000*.bin
#---------------------------------------------------------#
# Upgrade Device #
#---------------------------------------------------------#
- set_fact: si='nxos.7.0.3.I7.4.bin'
- name: Upgrade N3172 Device to Greensboro Release Image
include: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml

View file

@ -0,0 +1,29 @@
---
- debug: msg="START connection={{ ansible_connection }} nxos_os_install upgrade"
- debug: msg="Using provider={{ connection.transport }}"
when: connection is defined
# Set directory pointer to software images
- set_fact: image_dir='/auto/fe_ssr/agents-ci/agents_images/release_images/602U6_1/'
- set_fact: checkmode='no'
- set_fact: issu='desired'
- set_fact: copy_images=True
# Set boot pointers and reload
- set_fact: force=False
- set_fact: delete_files=True
- set_fact:
delete_image_list:
- n3000*.bin
- nxos*.bin
#---------------------------------------------------------#
# Upgrade Device #
#---------------------------------------------------------#
- set_fact: si='n3000-uk9.6.0.2.U6.1a.bin'
- set_fact: ki='n3000-uk9-kickstart.6.0.2.U6.1a.bin'
- name: Upgrade N3500 Device to U61a Release Image
include: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml

View file

@ -0,0 +1,29 @@
---
- debug: msg="START connection={{ ansible_connection }} nxos_os_install upgrade"
- debug: msg="Using provider={{ connection.transport }}"
when: connection is defined
# Set directory pointer to software images
- set_fact: image_dir='/auto/fe_ssr/agents-ci/agents_images/release_images/602U6_2/'
- set_fact: checkmode='no'
- set_fact: issu='no'
- set_fact: copy_images=True
# Set boot pointers and reload
- set_fact: force=False
- set_fact: delete_files=True
- set_fact:
delete_image_list:
- n3000*.bin
- nxos*.bin
#---------------------------------------------------------#
# Upgrade Device #
#---------------------------------------------------------#
- set_fact: si='n3000-uk9.6.0.2.U6.2a.bin'
- set_fact: ki='n3000-uk9-kickstart.6.0.2.U6.2a.bin'
- name: Upgrade N3500 Device to U62a Release Image
include: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml

View file

@ -0,0 +1,29 @@
---
- debug: msg="START connection={{ ansible_connection }} nxos_os_install upgrade"
- debug: msg="Using provider={{ connection.transport }}"
when: connection is defined
# Set directory pointer to software images
- set_fact: image_dir='/auto/fe_ssr/agents-ci/agents_images/release_images/602U6_3/'
- set_fact: checkmode='no'
- set_fact: issu='desired'
- set_fact: copy_images=True
# Set boot pointers and reload
- set_fact: force=False
- set_fact: delete_files=True
- set_fact:
delete_image_list:
- n3000*.bin
- nxos*.bin
#---------------------------------------------------------#
# Upgrade Device #
#---------------------------------------------------------#
- set_fact: si='n3000-uk9.6.0.2.U6.3a.bin'
- set_fact: ki='n3000-uk9-kickstart.6.0.2.U6.3a.bin'
- name: Upgrade N3500 Device to U63a Release Image
include: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml

View file

@ -0,0 +1,29 @@
---
- debug: msg="START connection={{ ansible_connection }} nxos_os_install upgrade"
- debug: msg="Using provider={{ connection.transport }}"
when: connection is defined
# Set directory pointer to software images
- set_fact: image_dir='/auto/fe_ssr/agents-ci/agents_images/release_images/602A8_8/'
- set_fact: checkmode='no'
- set_fact: issu='desired'
- set_fact: copy_images=True
# Set boot pointers and reload
- set_fact: force=False
- set_fact: delete_files=True
- set_fact:
delete_image_list:
- n3000*.bin
- n3500*.bin
#---------------------------------------------------------#
# Upgrade Device #
#---------------------------------------------------------#
- set_fact: si='n3500-uk9.6.0.2.A8.8.bin'
- set_fact: ki='n3500-uk9-kickstart.6.0.2.A8.8.bin'
- name: Upgrade N3500 Device to A8_8 Release Image
include: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml

View file

@ -0,0 +1,28 @@
---
- debug: msg="START connection={{ ansible_connection }} nxos_os_install upgrade"
- debug: msg="Using provider={{ connection.transport }}"
when: connection is defined
# Set directory pointer to software images
- set_fact: image_dir='/auto/fe_ssr/agents-ci/agents_images/release_images/greensboro/REL_7_0_3_I7_4/'
- set_fact: checkmode='no'
- set_fact: issu='desired'
- set_fact: copy_images=False
# Set boot pointers and reload
- set_fact: force=False
- set_fact: delete_files=False
- set_fact:
delete_image_list:
- nxos*.bin
- n3500*.bin
#---------------------------------------------------------#
# Upgrade Device #
#---------------------------------------------------------#
- set_fact: si='nxos.7.0.3.I7.4.bin'
- name: Upgrade N3500 Device to Greensboro Release Image
include: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml

View file

@ -0,0 +1,28 @@
---
- debug: msg="START connection={{ ansible_connection }} nxos_os_install upgrade"
- debug: msg="Using provider={{ connection.transport }}"
when: connection is defined
# Set directory pointer to software images
- set_fact: image_dir='/auto/fe_ssr/agents-ci/agents_images/release_images/730_N11/'
- set_fact: checkmode='no'
- set_fact: issu='no'
- set_fact: copy_images=True
# Set boot pointers and reload
- set_fact: force=False
- set_fact: delete_files=True
- set_fact:
delete_image_list:
- n6000*.bin
#---------------------------------------------------------#
# Upgrade Device #
#---------------------------------------------------------#
- set_fact: si='n6000-uk9.7.3.0.N1.1.bin'
- set_fact: ki='n6000-uk9-kickstart.7.3.0.N1.1.bin'
- name: Upgrade N5k Device to 7.3(0)N1(1) Release Image
include: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml

View file

@ -0,0 +1,28 @@
---
- debug: msg="START connection={{ ansible_connection }} nxos_os_install upgrade"
- debug: msg="Using provider={{ connection.transport }}"
when: connection is defined
# Set directory pointer to software images
- set_fact: image_dir='/auto/fe_ssr/agents-ci/agents_images/release_images/733_N11/'
- set_fact: checkmode='no'
- set_fact: issu='no'
- set_fact: copy_images=False
# Set boot pointers and reload
- set_fact: force=False
- set_fact: delete_files=False
- set_fact:
delete_image_list:
- n6000*.bin
#---------------------------------------------------------#
# Upgrade Device #
#---------------------------------------------------------#
- set_fact: si='n6000-uk9.7.3.3.N1.1.bin'
- set_fact: ki='n6000-uk9-kickstart.7.3.3.N1.1.bin'
- name: Upgrade N5k Device to 7.3(3)N1(1) Release Image
include: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml

View file

@ -0,0 +1,28 @@
---
- debug: msg="START connection={{ ansible_connection }} nxos_os_install upgrade"
- debug: msg="Using provider={{ connection.transport }}"
when: connection is defined
# Set directory pointer to software images
- set_fact: image_dir='/auto/fe_ssr/agents-ci/agents_images/release_images/atherton/REL_8_0_1/'
- set_fact: checkmode='no'
- set_fact: issu='no'
- set_fact: copy_images=True
# Set boot pointers and reload
- set_fact: force=False
- set_fact: delete_files=True
- set_fact:
delete_image_list:
- n7000*.bin
#---------------------------------------------------------#
# Upgrade Device #
#---------------------------------------------------------#
- set_fact: si='n7000-s2-dk9.8.0.1.bin'
- set_fact: ki='n7000-s2-kickstart.8.0.1.bin'
- name: Upgrade N7k Device to Atherton Release Image
include: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml

View file

@ -0,0 +1,28 @@
---
- debug: msg="START connection={{ ansible_connection }} nxos_os_install upgrade"
- debug: msg="Using provider={{ connection.transport }}"
when: connection is defined
# Set directory pointer to software images
- set_fact: image_dir='/auto/fe_ssr/agents-ci/agents_images/release_images/helsinki/REL_7_3_0_D1_1/'
- set_fact: checkmode='no'
- set_fact: issu='no'
- set_fact: copy_images=True
# Set boot pointers and reload
- set_fact: force=True
- set_fact: delete_files=True
- set_fact:
delete_image_list:
- n7000*.bin
#---------------------------------------------------------#
# Upgrade Device #
#---------------------------------------------------------#
- set_fact: si='n7000-s2-dk9.7.3.0.D1.1.bin'
- set_fact: ki='n7000-s2-kickstart.7.3.0.D1.1.bin'
- name: Upgrade N7k Device to Helsinki Release Image
include: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml

View file

@ -0,0 +1,41 @@
---
- debug: msg="START connection={{ ansible_connection }} nxos_os_install upgrade"
- debug: msg="Using provider={{ connection.transport }}"
when: connection is defined
# Set directory pointer to software images
- set_fact: image_dir='/auto/fe_ssr/agents-ci/agents_images/release_images/greensboro/REL_7_0_3_I7_4/'
- set_fact: checkmode='no'
- set_fact: issu='yes'
- set_fact: copy_images=False
# Set boot pointers and reload
- set_fact: force=False
- set_fact: delete_files=False
- set_fact:
delete_image_list:
- nxos*.bin
#---------------------------------------------------------#
# Remove incompatible features #
#---------------------------------------------------------#
- name: Unconfigure features that will conflict with upgrade
nxos_config:
lines:
- terminal dont-ask
- no feature nv overlay
- no nxapi ssl protocols
- no nxapi ssl ciphers weak
match: none
provider: "{{ connection }}"
ignore_errors: yes
#---------------------------------------------------------#
# Upgrade Device #
#---------------------------------------------------------#
- set_fact: si='nxos.7.0.3.I7.4.bin'
- name: Upgrade N9k Device to Greensboro Release Image
include: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml

View file

@ -0,0 +1,39 @@
---
- debug: msg="START connection={{ ansible_connection }} nxos_os_install upgrade"
- debug: msg="Using provider={{ connection.transport }}"
when: connection is defined
# Set directory pointer to software images
- set_fact: image_dir='/auto/fe_ssr/agents-ci/agents_images/release_images/hamilton/REL_9_2_1/'
- set_fact: checkmode='no'
- set_fact: issu='desired'
- set_fact: copy_images=False
# Set boot pointers and reload
- set_fact: force=False
- set_fact: delete_files=False
- set_fact:
delete_image_list:
- nxos*.bin
#---------------------------------------------------------#
# Remove incompatible features #
#---------------------------------------------------------#
- name: Unconfigure features that will conflict with upgrade
nxos_config:
lines:
- terminal dont-ask
- no feature ngmvpn
match: none
provider: "{{ connection }}"
ignore_errors: yes
#---------------------------------------------------------#
# Upgrade Device #
#---------------------------------------------------------#
- set_fact: si='nxos.9.2.1.bin'
- name: Upgrade N9k Device to Hamilton Release Image
include: targets/nxos_install_os/tasks/upgrade/main_os_install.yaml