From 991a9dfa120b45d566e6f7aef428fe36f0372137 Mon Sep 17 00:00:00 2001 From: Sumit Jaiswal Date: Wed, 28 Nov 2018 11:27:46 +0530 Subject: [PATCH] PR to support commit check to confirm commits with JunOS (#49054) * commit check support Signed-off-by: Sumit Jaiswal * fixed review comments Signed-off-by: Sumit Jaiswal * fixed review comments Signed-off-by: Sumit Jaiswal * fixed shippable Signed-off-by: Sumit Jaiswal --- lib/ansible/modules/network/junos/junos_config.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/ansible/modules/network/junos/junos_config.py b/lib/ansible/modules/network/junos/junos_config.py index 0b1813340ca..90c0f38f0c6 100644 --- a/lib/ansible/modules/network/junos/junos_config.py +++ b/lib/ansible/modules/network/junos/junos_config.py @@ -122,6 +122,13 @@ options: type: bool default: 'no' version_added: "2.4" + check_commit: + description: + - This argument will check correctness of syntax; do not apply changes. + - Note that this argument can be used to confirm verified configuration done via commit confirmed operation + type: bool + default: 'no' + version_added: "2.8" requirements: - ncclient (>=v0.5.2) notes: @@ -157,6 +164,10 @@ EXAMPLES = """ - set interfaces irb unit 10 family inet address 10.0.0.1/24 - set vlans vlan01 l3-interface irb.10 +- name: Check correctness of commit configuration + junos_config: + check_commit: yes + - name: rollback the configuration to id 10 junos_config: rollback: 10 @@ -313,6 +324,7 @@ def main(): confirm=dict(default=0, type='int'), comment=dict(default=DEFAULT_COMMENT), confirm_commit=dict(type='bool', default=False), + check_commit=dict(type='bool', default=False), # config operations backup=dict(type='bool', default=False), @@ -391,6 +403,9 @@ def main(): if module._diff: result['diff'] = {'prepared': diff} + elif module.params['check_commit']: + commit_configuration(module, check=True) + elif module.params['confirm_commit']: with locked_config(module): # confirm a previous commit