From 2a908b832c33fbce2fe7aa8347994299b03a1ea7 Mon Sep 17 00:00:00 2001 From: Peter Sprygada Date: Tue, 20 Sep 2016 16:12:08 -0400 Subject: [PATCH] fixes commit confirm check in junos shared module (#17663) The module didn't perform a commit confirm check which would cause checking commits to be non idempotent. This change will fix that problem. --- lib/ansible/module_utils/junos.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/ansible/module_utils/junos.py b/lib/ansible/module_utils/junos.py index 7546f9e4bf8..5f7d3cc66dc 100644 --- a/lib/ansible/module_utils/junos.py +++ b/lib/ansible/module_utils/junos.py @@ -236,6 +236,18 @@ class Netconf(object): exc = get_exception() raise NetworkError('unable to commit config: %s' % str(exc)) + def confirm_commit(self, checkonly=False): + try: + resp = self.rpc('get_commit_information') + needs_confirm = 'commit confirmed, rollback' in resp[0][4].text + if checkonly: + return needs_confirm + return self.commit_config() + except IndexError: + # if there is no comment tag, the system is not in a commit + # confirmed state so just return + pass + def rollback_config(self, identifier, commit=True, comment=None): self.lock_config()