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'):