mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-02 06:30:19 -07:00
Fix rollback in junos_config (#31424)
* Fix rollback in junos_config Fixes #30778 * Call `load_configuration` with rollback id in case the id is given as input * Pass rollback id to `get_diff()` to fetch diff from device * Fix unit test
This commit is contained in:
parent
2ed46e04f4
commit
88da95bb77
4 changed files with 55 additions and 8 deletions
|
@ -191,7 +191,7 @@ import json
|
|||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.junos import get_diff, load_config, get_configuration
|
||||
from ansible.module_utils.junos import commit_configuration, discard_changes, locked_config
|
||||
from ansible.module_utils.junos import junos_argument_spec
|
||||
from ansible.module_utils.junos import junos_argument_spec, load_configuration
|
||||
from ansible.module_utils.junos import check_args as junos_check_args
|
||||
from ansible.module_utils.netconf import send_request
|
||||
from ansible.module_utils.six import string_types
|
||||
|
@ -227,8 +227,8 @@ def zeroize(ele):
|
|||
return send_request(ele, Element('request-system-zeroize'))
|
||||
|
||||
|
||||
def rollback(ele):
|
||||
return get_diff(ele)
|
||||
def rollback(ele, id='0'):
|
||||
return get_diff(ele, id)
|
||||
|
||||
|
||||
def guess_format(config):
|
||||
|
@ -346,9 +346,16 @@ def main():
|
|||
|
||||
result['__backup__'] = match.text.strip()
|
||||
|
||||
if module.params['rollback']:
|
||||
rollback_id = module.params['rollback']
|
||||
if rollback_id:
|
||||
diff = rollback(module, rollback_id)
|
||||
if commit:
|
||||
diff = rollback(module)
|
||||
kwargs = {
|
||||
'comment': module.params['comment']
|
||||
}
|
||||
with locked_config(module):
|
||||
load_configuration(module, rollback=rollback_id)
|
||||
commit_configuration(module, **kwargs)
|
||||
if module._diff:
|
||||
result['diff'] = {'prepared': diff}
|
||||
result['changed'] = True
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue