From d9acf0715063dd4feadf63d429dd2d46077c0996 Mon Sep 17 00:00:00 2001 From: rahushen Date: Wed, 13 Sep 2017 08:24:35 -0400 Subject: [PATCH] Fixes #27336 - nxos_gir_profile_management issue while creating profile (#29151) * Fixes #27336 * Correct documentation errors (cherry picked from commit f1cc5a928c50ef524408e74f79d1071518d28ca3) --- .../network/nxos/nxos_gir_profile_management.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/ansible/modules/network/nxos/nxos_gir_profile_management.py b/lib/ansible/modules/network/nxos/nxos_gir_profile_management.py index 49667efd7e..d912551481 100644 --- a/lib/ansible/modules/network/nxos/nxos_gir_profile_management.py +++ b/lib/ansible/modules/network/nxos/nxos_gir_profile_management.py @@ -35,7 +35,6 @@ author: - Gabriele Gerbino (@GGabriele) notes: - Tested against NXOSv 7.3.(0)D1(1) on VIRL - - This module is not idempotent when C(state=present). - C(state=absent) removes the whole profile. options: commands: @@ -70,7 +69,7 @@ options: EXAMPLES = ''' # Create a maintenance-mode profile -- nxos_gir_profile: +- nxos_gir_profile_management: mode: maintenance commands: - router eigrp 11 @@ -79,7 +78,7 @@ EXAMPLES = ''' username: "{{ un }}" password: "{{ pwd }}" # Remove the maintenance-mode profile -- nxos_gir_profile: +- nxos_gir_profile_management: mode: maintenance state: absent host: "{{ inventory_hostname }}" @@ -146,6 +145,9 @@ def get_existing(module): def state_present(module, existing, commands): cmds = list() + if existing == commands: + # Idempotent case + return cmds cmds.extend(commands) if module.params['mode'] == 'maintenance': cmds.insert(0, 'configure maintenance profile maintenance-mode') @@ -206,9 +208,10 @@ def main(): if module.check_mode: module.exit_json(changed=True, commands=cmds) else: - load_config(module, cmds) - changed = True - end_state = invoke('get_existing', module) + if cmds: + load_config(module, cmds) + changed = True + end_state = invoke('get_existing', module) result['changed'] = changed if module._verbosity > 0: