mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
Update nxos_install_os module (#40102)
* Add nxos_install_os integration tests * Update call to check timers * Update check_ansible_timer method * Modify network_cli integration tests * Add timer check for nxos_install_os * Add comments for clear_persistent_sockets * Update connection info for tests * More updates * Restructure files for provider and non-provider testing * Update env var name and add check for ISSU switchover
This commit is contained in:
@@ -35,13 +35,9 @@ notes:
|
||||
- N9k 7.0(3)I4(6), 7.0(3)I5(3), 7.0(3)I6(1), 7.0(3)I7(1), 7.0(3)F2(2), 7.0(3)F3(2)
|
||||
- N3k 6.0(2)A8(6), 6.0(2)A8(8), 7.0(3)I6(1), 7.0(3)I7(1)
|
||||
- N7k 7.3(0)D1(1), 8.0(1), 8.2(1)
|
||||
- This module executes longer then the default ansible timeout value and
|
||||
will generate errors unless the module timeout parameter is set to a
|
||||
value of 500 seconds or higher.
|
||||
The example time is sufficent for most upgrades but this can be
|
||||
tuned higher based on specific upgrade time requirements.
|
||||
The module will exit with a failure message if the timer is
|
||||
not set to 500 seconds or higher.
|
||||
- This module requires both the ANSIBLE_PERSISTENT_CONNECT_TIMEOUT and
|
||||
ANSIBLE_PERSISTENT_COMMAND_TIMEOUT timers to be set to 600 seconds or higher.
|
||||
The module will exit if the timers are not set properly.
|
||||
- Do not include full file paths, just the name of the file(s) stored on
|
||||
the top level flash directory.
|
||||
- This module attempts to install the software immediately,
|
||||
@@ -81,7 +77,6 @@ EXAMPLES = '''
|
||||
nxos_install_os:
|
||||
system_image_file: nxos.7.0.3.I6.1.bin
|
||||
issu: desired
|
||||
provider: "{{ connection | combine({'timeout': 500}) }}"
|
||||
|
||||
- name: Wait for device to come back up with new image
|
||||
wait_for:
|
||||
@@ -129,25 +124,6 @@ from ansible.module_utils.network.nxos.nxos import nxos_argument_spec, check_arg
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
|
||||
def check_ansible_timer(module):
|
||||
'''Check Ansible Timer Values'''
|
||||
msg = "The 'timeout' provider param value for this module to execute\n"
|
||||
msg = msg + 'properly is too low.\n'
|
||||
msg = msg + 'Upgrades can take a long time so the value needs to be set\n'
|
||||
msg = msg + 'to the recommended value of 500 seconds or higher in the\n'
|
||||
msg = msg + 'ansible playbook for the nxos_install_os module.\n'
|
||||
msg = msg + '\n'
|
||||
msg = msg + 'provider: "{{ connection | combine({\'timeout\': 500}) }}"'
|
||||
data = module.params.get('provider')
|
||||
timer_low = False
|
||||
if data.get('timeout') is None:
|
||||
timer_low = True
|
||||
if data.get('timeout') is not None and data.get('timeout') < 500:
|
||||
timer_low = True
|
||||
if timer_low:
|
||||
module.fail_json(msg=msg.split('\n'))
|
||||
|
||||
|
||||
# Output options are 'text' or 'json'
|
||||
def execute_show_command(module, command, output='text'):
|
||||
cmds = [{
|
||||
@@ -276,6 +252,9 @@ def parse_show_install(data):
|
||||
if re.search(r'Install has been successful', x):
|
||||
ud['upgrade_succeeded'] = True
|
||||
break
|
||||
if re.search(r'Switching over onto standby', x):
|
||||
ud['upgrade_succeeded'] = True
|
||||
break
|
||||
|
||||
# We get these messages when the upgrade is non-disruptive and
|
||||
# we loose connection with the switchover but far enough along that
|
||||
@@ -539,10 +518,6 @@ def main():
|
||||
warnings = list()
|
||||
check_args(module, warnings)
|
||||
|
||||
# This module will error out if the Ansible task timeout value is not
|
||||
# tuned high enough.
|
||||
check_ansible_timer(module)
|
||||
|
||||
# Get system_image_file(sif), kickstart_image_file(kif) and
|
||||
# issu settings from module params.
|
||||
sif = module.params['system_image_file']
|
||||
|
||||
@@ -55,6 +55,12 @@ class ActionModule(_ActionModule):
|
||||
elif self._play_context.connection == 'local':
|
||||
self._task.args['username'] = self._play_context.connection_user
|
||||
|
||||
if self._task.action == 'nxos_install_os':
|
||||
if C.PERSISTENT_COMMAND_TIMEOUT < 600 or C.PERSISTENT_CONNECT_TIMEOUT < 600:
|
||||
msg = 'PERSISTENT_COMMAND_TIMEOUT and PERSISTENT_CONNECT_TIMEOUT'
|
||||
msg += ' must be set to 600 seconds or higher when using nxos_install_os module'
|
||||
return {'failed': True, 'msg': msg}
|
||||
|
||||
if self._play_context.connection in ('network_cli', 'httpapi'):
|
||||
provider = self._task.args.get('provider', {})
|
||||
if any(provider.values()):
|
||||
|
||||
Reference in New Issue
Block a user