From e3c4e49f59b90c7bdbd9695164a7b372303eb176 Mon Sep 17 00:00:00 2001 From: Mike Wiebe Date: Mon, 19 Nov 2018 23:44:15 -0500 Subject: [PATCH] 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 (cherry picked from commit a7215722069b79c422f3cacd26497f48effbcaf6) --- lib/ansible/module_utils/network/nxos/nxos.py | 2 +- .../modules/network/nxos/nxos_install_os.py | 32 ++++++++++--- .../nxos_install_os/tasks/httpapi.yaml | 2 +- .../nxos_install_os/tasks/network_cli.yaml | 2 +- .../upgrade/copy_kick_system_images.yaml | 48 ++++++++++++------- .../tasks/upgrade/delete_files.yaml | 1 + .../tasks/upgrade/delete_files_provider.yaml | 11 ----- .../tasks/upgrade/enable_scp_server.yaml | 1 + .../upgrade/enable_scp_server_provider.yaml | 6 --- .../tasks/upgrade/install_os.yaml | 11 +++-- .../tasks/upgrade/install_os_provider.yaml | 25 ---------- .../tasks/upgrade/install_system.yaml | 22 +++++++++ .../upgrade/install_system_provider.yaml | 25 ---------- .../tasks/upgrade/install_with_kick.yaml | 22 +++++++++ .../upgrade/install_with_kick_provider.yaml | 26 ---------- .../tasks/upgrade/main_os_install.yaml | 4 -- .../upgrade/set_boot_pointer_and_reload.yaml | 22 --------- .../set_boot_pointer_and_reload_provider.yaml | 23 --------- .../nxos_install_os/tests/common/upgrade.yaml | 19 ++++---- .../common/upgrade_n3172_greensboro.yaml | 28 +++++++++++ .../tests/common/upgrade_n3172_u61a.yaml | 29 +++++++++++ .../tests/common/upgrade_n3172_u62a.yaml | 29 +++++++++++ .../tests/common/upgrade_n3172_u63a.yaml | 29 +++++++++++ .../tests/common/upgrade_n35_62a88.yaml | 29 +++++++++++ .../tests/common/upgrade_n35_greensboro.yaml | 28 +++++++++++ .../tests/common/upgrade_n5k_730_N11.yaml | 28 +++++++++++ .../tests/common/upgrade_n5k_733_N11.yaml | 28 +++++++++++ .../tests/common/upgrade_n7k_atherton.yaml | 28 +++++++++++ .../tests/common/upgrade_n7k_helsinki.yaml | 28 +++++++++++ .../tests/common/upgrade_n9k_greensboro.yaml | 41 ++++++++++++++++ .../tests/common/upgrade_n9k_hamilton.yaml | 39 +++++++++++++++ 31 files changed, 486 insertions(+), 182 deletions(-) delete mode 100644 test/integration/targets/nxos_install_os/tasks/upgrade/delete_files_provider.yaml delete mode 100644 test/integration/targets/nxos_install_os/tasks/upgrade/enable_scp_server_provider.yaml delete mode 100644 test/integration/targets/nxos_install_os/tasks/upgrade/install_os_provider.yaml delete mode 100644 test/integration/targets/nxos_install_os/tasks/upgrade/install_system_provider.yaml delete mode 100644 test/integration/targets/nxos_install_os/tasks/upgrade/install_with_kick_provider.yaml delete mode 100644 test/integration/targets/nxos_install_os/tasks/upgrade/set_boot_pointer_and_reload.yaml delete mode 100644 test/integration/targets/nxos_install_os/tasks/upgrade/set_boot_pointer_and_reload_provider.yaml create mode 100644 test/integration/targets/nxos_install_os/tests/common/upgrade_n3172_greensboro.yaml create mode 100644 test/integration/targets/nxos_install_os/tests/common/upgrade_n3172_u61a.yaml create mode 100644 test/integration/targets/nxos_install_os/tests/common/upgrade_n3172_u62a.yaml create mode 100644 test/integration/targets/nxos_install_os/tests/common/upgrade_n3172_u63a.yaml create mode 100644 test/integration/targets/nxos_install_os/tests/common/upgrade_n35_62a88.yaml create mode 100644 test/integration/targets/nxos_install_os/tests/common/upgrade_n35_greensboro.yaml create mode 100644 test/integration/targets/nxos_install_os/tests/common/upgrade_n5k_730_N11.yaml create mode 100644 test/integration/targets/nxos_install_os/tests/common/upgrade_n5k_733_N11.yaml create mode 100644 test/integration/targets/nxos_install_os/tests/common/upgrade_n7k_atherton.yaml create mode 100644 test/integration/targets/nxos_install_os/tests/common/upgrade_n7k_helsinki.yaml create mode 100644 test/integration/targets/nxos_install_os/tests/common/upgrade_n9k_greensboro.yaml create mode 100644 test/integration/targets/nxos_install_os/tests/common/upgrade_n9k_hamilton.yaml diff --git a/lib/ansible/module_utils/network/nxos/nxos.py b/lib/ansible/module_utils/network/nxos/nxos.py index 40e043c1a7..3f740791da 100644 --- a/lib/ansible/module_utils/network/nxos/nxos.py +++ b/lib/ansible/module_utils/network/nxos/nxos.py @@ -181,7 +181,7 @@ class Cli: message = getattr(e, 'err', e) err = to_text(message, errors='surrogate_then_replace') if opts.get('ignore_timeout') and code: - msgs.append(code) + msgs.append(err) return msgs elif code and 'no graceful-restart' in err: if 'ISSU/HA will be affected if Graceful Restart is disabled' in err: diff --git a/lib/ansible/modules/network/nxos/nxos_install_os.py b/lib/ansible/modules/network/nxos/nxos_install_os.py index e634023c19..2d2fca4843 100644 --- a/lib/ansible/modules/network/nxos/nxos_install_os.py +++ b/lib/ansible/modules/network/nxos/nxos_install_os.py @@ -205,6 +205,7 @@ def parse_show_install(data): ud['disruptive'] = False ud['upgrade_needed'] = False ud['error'] = False + ud['invalid_command'] = False ud['install_in_progress'] = False ud['server_error'] = False ud['upgrade_succeeded'] = False @@ -228,6 +229,7 @@ def parse_show_install(data): ud['error'] = True break if re.search(r'[I|i]nvalid command', x): + ud['invalid_command'] = True ud['error'] = True break if re.search(r'No install all data found', x): @@ -241,6 +243,9 @@ def parse_show_install(data): if re.search(r'Backend processing error', x): ud['server_error'] = True break + if re.search(r'timed out', x): + ud['server_error'] = True + break if re.search(r'^(-1|5\d\d)$', x): ud['server_error'] = True break @@ -343,7 +348,7 @@ def massage_install_data(data): return result_data -def build_install_cmd_set(issu, image, kick, type): +def build_install_cmd_set(issu, image, kick, type, force=True): commands = ['terminal dont-ask'] # Different NX-OS plaforms behave differently for @@ -355,6 +360,7 @@ def build_install_cmd_set(issu, image, kick, type): # 2) Separate kickstart + system images. # * Omit hidden 'force' option for issu. # * Use hidden 'force' option for disruptive upgrades. + # * Note: Not supported on all platforms if re.search(r'required|desired|yes', issu): if kick is None: issu_cmd = 'non-disruptive' @@ -364,7 +370,7 @@ def build_install_cmd_set(issu, image, kick, type): if kick is None: issu_cmd = '' else: - issu_cmd = 'force' + issu_cmd = 'force' if force else '' if type == 'impact': rootcmd = 'show install all impact' @@ -411,6 +417,7 @@ def check_mode_legacy(module, issu, image, kick=None): # Process System Image data['error'] = False tsver = 'show version image bootflash:%s' % image + data['upgrade_cmd'] = [tsver] target_image = parse_show_version(execute_show_command(module, tsver)) if target_image['error']: data['error'] = True @@ -423,6 +430,7 @@ def check_mode_legacy(module, issu, image, kick=None): # Process Kickstart Image if kick is not None and not data['error']: tkver = 'show version image bootflash:%s' % kick + data['upgrade_cmd'].append(tsver) target_kick = parse_show_version(execute_show_command(module, tkver)) if target_kick['error']: data['error'] = True @@ -432,6 +440,7 @@ def check_mode_legacy(module, issu, image, kick=None): data['disruptive'] = True upgrade_msg = upgrade_msg + ' kickstart: %s' % tkver + data['list_data'] = data['raw'] data['processed'] = upgrade_msg return data @@ -451,6 +460,7 @@ def check_mode_nextgen(module, issu, image, kick=None): data = check_install_in_progress(module, commands, opts) if data['server_error']: data['error'] = True + data['upgrade_cmd'] = commands return data @@ -472,6 +482,11 @@ def check_mode(module, issu, image, kick=None): # impact data from the 'show install all impact' command. # Fallback to legacy method. data = check_mode_legacy(module, issu, image, kick) + if data['invalid_command']: + # If we are upgrading from a device running a separate kickstart and + # system image the impact command will fail. + # Fallback to legacy method. + data = check_mode_legacy(module, issu, image, kick) return data @@ -501,6 +516,12 @@ def do_install_all(module, issu, image, kick=None): # The system may be busy from the call to check_mode so loop until # it's done. upgrade = check_install_in_progress(module, commands, opts) + if upgrade['invalid_command'] and 'force' in commands[1]: + # Not all platforms support the 'force' keyword. Check for this + # condition and re-try without the 'force' keyword if needed. + commands = build_install_cmd_set(issu, image, kick, 'install', False) + upgrade = check_install_in_progress(module, commands, opts) + upgrade['upgrade_cmd'] = commands # Special case: If we encounter a server error at this stage # it means the command was sent and the upgrade was started but @@ -549,11 +570,8 @@ def main(): install_result = do_install_all(module, issu, sif, kick=kif) if install_result['error']: - msg = "Failed to upgrade device using image " - if kif: - msg = msg + "files: kickstart: %s, system: %s" % (kif, sif) - else: - msg = msg + "file: system: %s" % sif + cmd = install_result['upgrade_cmd'] + msg = 'Failed to upgrade device using command: %s' % cmd module.fail_json(msg=msg, raw_data=install_result['list_data']) state = install_result['processed'] diff --git a/test/integration/targets/nxos_install_os/tasks/httpapi.yaml b/test/integration/targets/nxos_install_os/tasks/httpapi.yaml index 28c543fba2..34516c8eb0 100644 --- a/test/integration/targets/nxos_install_os/tasks/httpapi.yaml +++ b/test/integration/targets/nxos_install_os/tasks/httpapi.yaml @@ -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 diff --git a/test/integration/targets/nxos_install_os/tasks/network_cli.yaml b/test/integration/targets/nxos_install_os/tasks/network_cli.yaml index e69ab5e2fe..497a535b24 100644 --- a/test/integration/targets/nxos_install_os/tasks/network_cli.yaml +++ b/test/integration/targets/nxos_install_os/tasks/network_cli.yaml @@ -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 diff --git a/test/integration/targets/nxos_install_os/tasks/upgrade/copy_kick_system_images.yaml b/test/integration/targets/nxos_install_os/tasks/upgrade/copy_kick_system_images.yaml index b043b1e35e..7f8383f76d 100644 --- a/test/integration/targets/nxos_install_os/tasks/upgrade/copy_kick_system_images.yaml +++ b/test/integration/targets/nxos_install_os/tasks/upgrade/copy_kick_system_images.yaml @@ -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 }}" diff --git a/test/integration/targets/nxos_install_os/tasks/upgrade/delete_files.yaml b/test/integration/targets/nxos_install_os/tasks/upgrade/delete_files.yaml index 27157b690b..f72f31569f 100644 --- a/test/integration/targets/nxos_install_os/tasks/upgrade/delete_files.yaml +++ b/test/integration/targets/nxos_install_os/tasks/upgrade/delete_files.yaml @@ -6,5 +6,6 @@ - allow delete boot-image - "delete {{ item }}" match: none + provider: "{{ connection }}" ignore_errors: yes with_items: "{{ delete_image_list }}" diff --git a/test/integration/targets/nxos_install_os/tasks/upgrade/delete_files_provider.yaml b/test/integration/targets/nxos_install_os/tasks/upgrade/delete_files_provider.yaml deleted file mode 100644 index 0ba4280402..0000000000 --- a/test/integration/targets/nxos_install_os/tasks/upgrade/delete_files_provider.yaml +++ /dev/null @@ -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 }}" diff --git a/test/integration/targets/nxos_install_os/tasks/upgrade/enable_scp_server.yaml b/test/integration/targets/nxos_install_os/tasks/upgrade/enable_scp_server.yaml index f8a4e54e34..4fcae4ca60 100644 --- a/test/integration/targets/nxos_install_os/tasks/upgrade/enable_scp_server.yaml +++ b/test/integration/targets/nxos_install_os/tasks/upgrade/enable_scp_server.yaml @@ -3,3 +3,4 @@ nxos_feature: feature: scp-server state: enabled + provider: "{{ connection }}" diff --git a/test/integration/targets/nxos_install_os/tasks/upgrade/enable_scp_server_provider.yaml b/test/integration/targets/nxos_install_os/tasks/upgrade/enable_scp_server_provider.yaml deleted file mode 100644 index d1da1833bf..0000000000 --- a/test/integration/targets/nxos_install_os/tasks/upgrade/enable_scp_server_provider.yaml +++ /dev/null @@ -1,6 +0,0 @@ ---- -- name: "Setup - Turn on feature scp-server using provider" - nxos_feature: - feature: scp-server - state: enabled - provider: "{{ connection }}" diff --git a/test/integration/targets/nxos_install_os/tasks/upgrade/install_os.yaml b/test/integration/targets/nxos_install_os/tasks/upgrade/install_os.yaml index 6dc811cdc7..2c0dac2639 100644 --- a/test/integration/targets/nxos_install_os/tasks/upgrade/install_os.yaml +++ b/test/integration/targets/nxos_install_os/tasks/upgrade/install_os.yaml @@ -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'] }}" diff --git a/test/integration/targets/nxos_install_os/tasks/upgrade/install_os_provider.yaml b/test/integration/targets/nxos_install_os/tasks/upgrade/install_os_provider.yaml deleted file mode 100644 index b8381aa002..0000000000 --- a/test/integration/targets/nxos_install_os/tasks/upgrade/install_os_provider.yaml +++ /dev/null @@ -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'] }}" diff --git a/test/integration/targets/nxos_install_os/tasks/upgrade/install_system.yaml b/test/integration/targets/nxos_install_os/tasks/upgrade/install_system.yaml index ec1b34fccf..d3b4dd8961 100644 --- a/test/integration/targets/nxos_install_os/tasks/upgrade/install_system.yaml +++ b/test/integration/targets/nxos_install_os/tasks/upgrade/install_system.yaml @@ -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: diff --git a/test/integration/targets/nxos_install_os/tasks/upgrade/install_system_provider.yaml b/test/integration/targets/nxos_install_os/tasks/upgrade/install_system_provider.yaml deleted file mode 100644 index e8aee7b5f4..0000000000 --- a/test/integration/targets/nxos_install_os/tasks/upgrade/install_system_provider.yaml +++ /dev/null @@ -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 diff --git a/test/integration/targets/nxos_install_os/tasks/upgrade/install_with_kick.yaml b/test/integration/targets/nxos_install_os/tasks/upgrade/install_with_kick.yaml index 3599da1b10..524a4a5df3 100644 --- a/test/integration/targets/nxos_install_os/tasks/upgrade/install_with_kick.yaml +++ b/test/integration/targets/nxos_install_os/tasks/upgrade/install_with_kick.yaml @@ -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: diff --git a/test/integration/targets/nxos_install_os/tasks/upgrade/install_with_kick_provider.yaml b/test/integration/targets/nxos_install_os/tasks/upgrade/install_with_kick_provider.yaml deleted file mode 100644 index 07aefbf077..0000000000 --- a/test/integration/targets/nxos_install_os/tasks/upgrade/install_with_kick_provider.yaml +++ /dev/null @@ -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 diff --git a/test/integration/targets/nxos_install_os/tasks/upgrade/main_os_install.yaml b/test/integration/targets/nxos_install_os/tasks/upgrade/main_os_install.yaml index cc4bd30ab0..5af834dc18 100644 --- a/test/integration/targets/nxos_install_os/tasks/upgrade/main_os_install.yaml +++ b/test/integration/targets/nxos_install_os/tasks/upgrade/main_os_install.yaml @@ -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 diff --git a/test/integration/targets/nxos_install_os/tasks/upgrade/set_boot_pointer_and_reload.yaml b/test/integration/targets/nxos_install_os/tasks/upgrade/set_boot_pointer_and_reload.yaml deleted file mode 100644 index b4422b140f..0000000000 --- a/test/integration/targets/nxos_install_os/tasks/upgrade/set_boot_pointer_and_reload.yaml +++ /dev/null @@ -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 diff --git a/test/integration/targets/nxos_install_os/tasks/upgrade/set_boot_pointer_and_reload_provider.yaml b/test/integration/targets/nxos_install_os/tasks/upgrade/set_boot_pointer_and_reload_provider.yaml deleted file mode 100644 index 24e45094f6..0000000000 --- a/test/integration/targets/nxos_install_os/tasks/upgrade/set_boot_pointer_and_reload_provider.yaml +++ /dev/null @@ -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 diff --git a/test/integration/targets/nxos_install_os/tests/common/upgrade.yaml b/test/integration/targets/nxos_install_os/tests/common/upgrade.yaml index 8444cb6747..3c8c213408 100644 --- a/test/integration/targets/nxos_install_os/tests/common/upgrade.yaml +++ b/test/integration/targets/nxos_install_os/tests/common/upgrade.yaml @@ -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 diff --git a/test/integration/targets/nxos_install_os/tests/common/upgrade_n3172_greensboro.yaml b/test/integration/targets/nxos_install_os/tests/common/upgrade_n3172_greensboro.yaml new file mode 100644 index 0000000000..e1d47bc531 --- /dev/null +++ b/test/integration/targets/nxos_install_os/tests/common/upgrade_n3172_greensboro.yaml @@ -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 diff --git a/test/integration/targets/nxos_install_os/tests/common/upgrade_n3172_u61a.yaml b/test/integration/targets/nxos_install_os/tests/common/upgrade_n3172_u61a.yaml new file mode 100644 index 0000000000..7f5a7a9ea4 --- /dev/null +++ b/test/integration/targets/nxos_install_os/tests/common/upgrade_n3172_u61a.yaml @@ -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 diff --git a/test/integration/targets/nxos_install_os/tests/common/upgrade_n3172_u62a.yaml b/test/integration/targets/nxos_install_os/tests/common/upgrade_n3172_u62a.yaml new file mode 100644 index 0000000000..bf70c2a5c4 --- /dev/null +++ b/test/integration/targets/nxos_install_os/tests/common/upgrade_n3172_u62a.yaml @@ -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 diff --git a/test/integration/targets/nxos_install_os/tests/common/upgrade_n3172_u63a.yaml b/test/integration/targets/nxos_install_os/tests/common/upgrade_n3172_u63a.yaml new file mode 100644 index 0000000000..6040c159a6 --- /dev/null +++ b/test/integration/targets/nxos_install_os/tests/common/upgrade_n3172_u63a.yaml @@ -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 diff --git a/test/integration/targets/nxos_install_os/tests/common/upgrade_n35_62a88.yaml b/test/integration/targets/nxos_install_os/tests/common/upgrade_n35_62a88.yaml new file mode 100644 index 0000000000..a55948ccbb --- /dev/null +++ b/test/integration/targets/nxos_install_os/tests/common/upgrade_n35_62a88.yaml @@ -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 diff --git a/test/integration/targets/nxos_install_os/tests/common/upgrade_n35_greensboro.yaml b/test/integration/targets/nxos_install_os/tests/common/upgrade_n35_greensboro.yaml new file mode 100644 index 0000000000..a38e3c1504 --- /dev/null +++ b/test/integration/targets/nxos_install_os/tests/common/upgrade_n35_greensboro.yaml @@ -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 diff --git a/test/integration/targets/nxos_install_os/tests/common/upgrade_n5k_730_N11.yaml b/test/integration/targets/nxos_install_os/tests/common/upgrade_n5k_730_N11.yaml new file mode 100644 index 0000000000..aafb125ede --- /dev/null +++ b/test/integration/targets/nxos_install_os/tests/common/upgrade_n5k_730_N11.yaml @@ -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 diff --git a/test/integration/targets/nxos_install_os/tests/common/upgrade_n5k_733_N11.yaml b/test/integration/targets/nxos_install_os/tests/common/upgrade_n5k_733_N11.yaml new file mode 100644 index 0000000000..3ee83ebfef --- /dev/null +++ b/test/integration/targets/nxos_install_os/tests/common/upgrade_n5k_733_N11.yaml @@ -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 diff --git a/test/integration/targets/nxos_install_os/tests/common/upgrade_n7k_atherton.yaml b/test/integration/targets/nxos_install_os/tests/common/upgrade_n7k_atherton.yaml new file mode 100644 index 0000000000..6ab9b3f607 --- /dev/null +++ b/test/integration/targets/nxos_install_os/tests/common/upgrade_n7k_atherton.yaml @@ -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 diff --git a/test/integration/targets/nxos_install_os/tests/common/upgrade_n7k_helsinki.yaml b/test/integration/targets/nxos_install_os/tests/common/upgrade_n7k_helsinki.yaml new file mode 100644 index 0000000000..d80a3b6365 --- /dev/null +++ b/test/integration/targets/nxos_install_os/tests/common/upgrade_n7k_helsinki.yaml @@ -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 diff --git a/test/integration/targets/nxos_install_os/tests/common/upgrade_n9k_greensboro.yaml b/test/integration/targets/nxos_install_os/tests/common/upgrade_n9k_greensboro.yaml new file mode 100644 index 0000000000..6c4eab0471 --- /dev/null +++ b/test/integration/targets/nxos_install_os/tests/common/upgrade_n9k_greensboro.yaml @@ -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 diff --git a/test/integration/targets/nxos_install_os/tests/common/upgrade_n9k_hamilton.yaml b/test/integration/targets/nxos_install_os/tests/common/upgrade_n9k_hamilton.yaml new file mode 100644 index 0000000000..1eda79c74a --- /dev/null +++ b/test/integration/targets/nxos_install_os/tests/common/upgrade_n9k_hamilton.yaml @@ -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