From 351bb3dd9afa5e71cf909533b736c48883f8f7ef Mon Sep 17 00:00:00 2001 From: Trishna Guha Date: Fri, 7 Sep 2018 19:39:25 +0530 Subject: [PATCH] [2.7] Add ambiguous command check as the error message is not persistent on nexus devices (#45341) * Add ambiguous command check as the error message is not persistent on nexus devices (#45337) Signed-off-by: Trishna Guha (cherry picked from commit f18856d0e2485aaf807271c7d9385bf564bfbb0f) * cli_config module doc update (#45345) Signed-off-by: Trishna Guha (cherry picked from commit d5bfd93e2838251b061c16f2e8b1ed09479262f6) --- changelogs/fragments/nxos_ambiguous_command_check.yaml | 2 ++ lib/ansible/module_utils/network/nxos/nxos.py | 2 +- lib/ansible/modules/network/cli/cli_config.py | 8 +++----- 3 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 changelogs/fragments/nxos_ambiguous_command_check.yaml 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