From 4c2a3bfed509fabb2d73b39118feb62fbee4412b Mon Sep 17 00:00:00 2001 From: Mike Wiebe Date: Sun, 17 Mar 2019 23:44:40 -0400 Subject: [PATCH] Fix nxos action plugin for nxos_install_os (#53768) * Fix nxos action plugin for nxos_install_os * Update module docs --- .../modules/network/nxos/nxos_install_os.py | 3 +++ lib/ansible/plugins/action/nxos.py | 17 +++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/network/nxos/nxos_install_os.py b/lib/ansible/modules/network/nxos/nxos_install_os.py index 41058091554..b0e653bed0c 100644 --- a/lib/ansible/modules/network/nxos/nxos_install_os.py +++ b/lib/ansible/modules/network/nxos/nxos_install_os.py @@ -38,6 +38,9 @@ notes: - 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. + - When using connection local, ANSIBLE_PERSISTENT_CONNECT_TIMEOUT and + ANSIBLE_PERSISTENT_COMMAND_TIMEOUT can only be set using ENV variables or + the ansible.cfg file. - 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, diff --git a/lib/ansible/plugins/action/nxos.py b/lib/ansible/plugins/action/nxos.py index a42b1dbe0d2..4eda0341ec4 100644 --- a/lib/ansible/plugins/action/nxos.py +++ b/lib/ansible/plugins/action/nxos.py @@ -55,10 +55,23 @@ class ActionModule(ActionNetworkModule): self._task.args['username'] = self._play_context.connection_user if self._task.action == 'nxos_install_os': + persistent_command_timeout = 0 + persistent_connect_timeout = 0 connection = self._connection - if connection.get_option('persistent_command_timeout') < 600 or connection.get_option('persistent_connect_timeout') < 600: + if connection.transport == 'local': + persistent_command_timeout = C.PERSISTENT_COMMAND_TIMEOUT + persistent_connect_timeout = C.PERSISTENT_CONNECT_TIMEOUT + else: + persistent_command_timeout = connection.get_option('persistent_command_timeout') + persistent_connect_timeout = connection.get_option('persistent_connect_timeout') + + display.vvvv('PERSISTENT_COMMAND_TIMEOUT is %s' % str(persistent_command_timeout), self._play_context.remote_addr) + display.vvvv('PERSISTENT_CONNECT_TIMEOUT is %s' % str(persistent_connect_timeout), self._play_context.remote_addr) + if persistent_command_timeout < 600 or 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' + msg += ' must be set to 600 seconds or higher when using nxos_install_os module.' + msg += ' Current persistent_command_timeout setting:' + str(persistent_command_timeout) + msg += ' Current persistent_connect_timeout setting:' + str(persistent_connect_timeout) return {'failed': True, 'msg': msg} if self._play_context.connection in ('network_cli', 'httpapi'):