diff --git a/changelogs/fragments/fix_nxos_terminal_plugin_order.yaml b/changelogs/fragments/fix_nxos_terminal_plugin_order.yaml new file mode 100644 index 00000000000..42d8ca8704e --- /dev/null +++ b/changelogs/fragments/fix_nxos_terminal_plugin_order.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - Update terminal plugin to check feature privilege only when escalation is needed (https://github.com/ansible-collections/cisco.nxos/pull/61). diff --git a/lib/ansible/plugins/terminal/nxos.py b/lib/ansible/plugins/terminal/nxos.py index dbeab1f3ffc..e09bf08f7ef 100644 --- a/lib/ansible/plugins/terminal/nxos.py +++ b/lib/ansible/plugins/terminal/nxos.py @@ -57,8 +57,6 @@ class TerminalModule(TerminalBase): out = self._exec_cli_command('show privilege') out = to_text(out, errors='surrogate_then_replace').strip() - if 'Disabled' in out: - raise AnsibleConnectionFailure('Feature privilege is not enabled') # if already at privilege level 15 return if '15' in out: @@ -67,6 +65,9 @@ class TerminalModule(TerminalBase): if self.validate_user_role(): return + if 'Disabled' in out: + raise AnsibleConnectionFailure('Feature privilege is not enabled') + cmd = {u'command': u'enable'} if passwd: cmd[u'prompt'] = to_text(r"(?i)[\r\n]?Password: $", errors='surrogate_or_strict')