diff --git a/changelogs/fragments/nxos_ambiguous_command_check.yaml b/changelogs/fragments/nxos_ambiguous_command_check.yaml new file mode 100644 index 00000000000..90ee4968308 --- /dev/null +++ b/changelogs/fragments/nxos_ambiguous_command_check.yaml @@ -0,0 +1,2 @@ +bugfixes: +- Add ambiguous command check as the error message is not persistent on nexus devices (https://github.com/ansible/ansible/pull/45337). diff --git a/lib/ansible/module_utils/network/nxos/nxos.py b/lib/ansible/module_utils/network/nxos/nxos.py index 5beee80d32d..8ca12f10f1f 100644 --- a/lib/ansible/module_utils/network/nxos/nxos.py +++ b/lib/ansible/module_utils/network/nxos/nxos.py @@ -161,7 +161,7 @@ class Cli: if network_api == 'cliconf' and out: for index, resp in enumerate(out): - if 'Invalid command at' in resp and 'json' in resp: + if ('Invalid command at' in resp or 'Ambiguous command at' in resp) and 'json' in resp: if commands[index]['output'] == 'json': commands[index]['output'] = 'text' out = connection.run_commands(commands, check_rc) diff --git a/lib/ansible/modules/network/cli/cli_config.py b/lib/ansible/modules/network/cli/cli_config.py index 6c5c0b59887..b6e7ef36a8b 100644 --- a/lib/ansible/modules/network/cli/cli_config.py +++ b/lib/ansible/modules/network/cli/cli_config.py @@ -27,7 +27,8 @@ options: description: - The config to be pushed to the network device. This argument is mutually exclusive with C(rollback) and either one of the - option should be given as input. + option should be given as input. The config should have + indentation that the device uses. type: 'str' commit: description: @@ -120,10 +121,7 @@ EXAMPLES = """ - name: Use diff_match cli_config: - config: | - interface loopback999 - no description - shutdown + config: "{{ lookup('file', 'interface_config') }}" diff_match: none - name: nxos replace config