From ceef4f97ed1cee1a6fe7c7c3adadd075395ffe48 Mon Sep 17 00:00:00 2001 From: Ganesh Nalawade Date: Fri, 18 Aug 2017 09:50:02 +0530 Subject: [PATCH] Use merge operation for load configuration in junos modules (#28369) * Change load configuration operation from replace to merge --- lib/ansible/modules/network/junos/junos_banner.py | 2 +- lib/ansible/modules/network/junos/junos_l3_interface.py | 2 +- lib/ansible/modules/network/junos/junos_linkagg.py | 2 +- lib/ansible/modules/network/junos/junos_lldp.py | 2 +- lib/ansible/modules/network/junos/junos_lldp_interface.py | 2 +- lib/ansible/modules/network/junos/junos_logging.py | 2 +- lib/ansible/modules/network/junos/junos_static_route.py | 2 +- lib/ansible/modules/network/junos/junos_system.py | 2 +- lib/ansible/modules/network/junos/junos_user.py | 2 ++ lib/ansible/modules/network/junos/junos_vlan.py | 2 +- lib/ansible/modules/network/junos/junos_vrf.py | 2 +- 11 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/ansible/modules/network/junos/junos_banner.py b/lib/ansible/modules/network/junos/junos_banner.py index f0e9e11bd7..c7c99aafd4 100644 --- a/lib/ansible/modules/network/junos/junos_banner.py +++ b/lib/ansible/modules/network/junos/junos_banner.py @@ -161,7 +161,7 @@ def main(): ele = map_obj_to_ele(module, want, top) with locked_config(module): - diff = load_config(module, tostring(ele), warnings, action='replace') + diff = load_config(module, tostring(ele), warnings, action='merge') commit = not module.check_mode if diff: diff --git a/lib/ansible/modules/network/junos/junos_l3_interface.py b/lib/ansible/modules/network/junos/junos_l3_interface.py index 5f73d5eb29..d5333fb284 100644 --- a/lib/ansible/modules/network/junos/junos_l3_interface.py +++ b/lib/ansible/modules/network/junos/junos_l3_interface.py @@ -184,7 +184,7 @@ def main(): diff = None with locked_config(module): for req in requests: - diff = load_config(module, tostring(req), warnings, action='replace') + diff = load_config(module, tostring(req), warnings, action='merge') commit = not module.check_mode if diff: diff --git a/lib/ansible/modules/network/junos/junos_linkagg.py b/lib/ansible/modules/network/junos/junos_linkagg.py index 21dd33babc..fe3c1c3c79 100644 --- a/lib/ansible/modules/network/junos/junos_linkagg.py +++ b/lib/ansible/modules/network/junos/junos_linkagg.py @@ -327,7 +327,7 @@ def main(): diff = None with locked_config(module): for req in requests: - diff = load_config(module, tostring(req), warnings, action='replace') + diff = load_config(module, tostring(req), warnings, action='merge') commit = not module.check_mode if diff: diff --git a/lib/ansible/modules/network/junos/junos_lldp.py b/lib/ansible/modules/network/junos/junos_lldp.py index 10e71c7efc..7f753295d2 100644 --- a/lib/ansible/modules/network/junos/junos_lldp.py +++ b/lib/ansible/modules/network/junos/junos_lldp.py @@ -184,7 +184,7 @@ def main(): ele = map_obj_to_ele(module, want, top, param=item) with locked_config(module): - diff = load_config(module, tostring(ele), warnings, action='replace') + diff = load_config(module, tostring(ele), warnings, action='merge') commit = not module.check_mode if diff: diff --git a/lib/ansible/modules/network/junos/junos_lldp_interface.py b/lib/ansible/modules/network/junos/junos_lldp_interface.py index 9934aff2a9..2f1d2491fb 100644 --- a/lib/ansible/modules/network/junos/junos_lldp_interface.py +++ b/lib/ansible/modules/network/junos/junos_lldp_interface.py @@ -145,7 +145,7 @@ def main(): ele = map_obj_to_ele(module, want, top, param=item) with locked_config(module): - diff = load_config(module, tostring(ele), warnings, action='replace') + diff = load_config(module, tostring(ele), warnings, action='merge') commit = not module.check_mode if diff: diff --git a/lib/ansible/modules/network/junos/junos_logging.py b/lib/ansible/modules/network/junos/junos_logging.py index d250b6958b..e20a1cf1b0 100644 --- a/lib/ansible/modules/network/junos/junos_logging.py +++ b/lib/ansible/modules/network/junos/junos_logging.py @@ -267,7 +267,7 @@ def main(): diff = None with locked_config(module): for req in requests: - diff = load_config(module, tostring(req), warnings, action='replace') + diff = load_config(module, tostring(req), warnings, action='merge') commit = not module.check_mode if diff: diff --git a/lib/ansible/modules/network/junos/junos_static_route.py b/lib/ansible/modules/network/junos/junos_static_route.py index 11adeeab69..07d5941e5c 100644 --- a/lib/ansible/modules/network/junos/junos_static_route.py +++ b/lib/ansible/modules/network/junos/junos_static_route.py @@ -219,7 +219,7 @@ def main(): with locked_config(module): for req in requests: - diff = load_config(module, tostring(req), warnings, action='replace') + diff = load_config(module, tostring(req), warnings, action='merge') commit = not module.check_mode if diff: diff --git a/lib/ansible/modules/network/junos/junos_system.py b/lib/ansible/modules/network/junos/junos_system.py index 8541114e67..3ae2e6f388 100644 --- a/lib/ansible/modules/network/junos/junos_system.py +++ b/lib/ansible/modules/network/junos/junos_system.py @@ -173,7 +173,7 @@ def main(): ele = map_obj_to_ele(module, want, top) with locked_config(module): - diff = load_config(module, tostring(ele), warnings, action='replace') + diff = load_config(module, tostring(ele), warnings, action='merge') commit = not module.check_mode if diff: diff --git a/lib/ansible/modules/network/junos/junos_user.py b/lib/ansible/modules/network/junos/junos_user.py index 17a481f8f1..8c892f3822 100644 --- a/lib/ansible/modules/network/junos/junos_user.py +++ b/lib/ansible/modules/network/junos/junos_user.py @@ -298,6 +298,8 @@ def main(): kwargs = {} if module.params['purge']: kwargs['action'] = 'replace' + else: + kwargs['action'] = 'merge' with locked_config(module): diff = load_config(module, tostring(ele), warnings, **kwargs) diff --git a/lib/ansible/modules/network/junos/junos_vlan.py b/lib/ansible/modules/network/junos/junos_vlan.py index 7caafea473..2b70afa51f 100644 --- a/lib/ansible/modules/network/junos/junos_vlan.py +++ b/lib/ansible/modules/network/junos/junos_vlan.py @@ -207,7 +207,7 @@ def main(): with locked_config(module): for req in requests: - diff = load_config(module, tostring(req), warnings, action='replace') + diff = load_config(module, tostring(req), warnings, action='merge') commit = not module.check_mode if diff: diff --git a/lib/ansible/modules/network/junos/junos_vrf.py b/lib/ansible/modules/network/junos/junos_vrf.py index 014600610b..38c3e7338a 100644 --- a/lib/ansible/modules/network/junos/junos_vrf.py +++ b/lib/ansible/modules/network/junos/junos_vrf.py @@ -245,7 +245,7 @@ def main(): with locked_config(module): for req in requests: - diff = load_config(module, tostring(req), warnings, action='replace') + diff = load_config(module, tostring(req), warnings, action='merge') commit = not module.check_mode if diff: