|
109 | 109 | retrieved if not set.
|
110 | 110 | default: None
|
111 | 111 | required: False
|
| 112 | + candidate_file: |
| 113 | + description: |
| 114 | + - File to store backup of candidate config from device. This is the |
| 115 | + config we are intending to install, before we roll back to the |
| 116 | + running_config. |
| 117 | + default: None |
| 118 | + required: False |
112 | 119 | '''
|
113 | 120 |
|
114 | 121 | EXAMPLES = '''
|
@@ -193,7 +200,8 @@ def main():
|
193 | 200 | replace_config=dict(type='bool', required=False, default=False),
|
194 | 201 | diff_file=dict(type='str', required=False, default=None),
|
195 | 202 | get_diffs=dict(type='bool', required=False, default=True),
|
196 |
| - archive_file=dict(type='str', required=False, default=None) |
| 203 | + archive_file=dict(type='str', required=False, default=None), |
| 204 | + candidate_file=dict(type='str', required=False, default=None) |
197 | 205 | ),
|
198 | 206 | supports_check_mode=True
|
199 | 207 | )
|
@@ -231,6 +239,7 @@ def main():
|
231 | 239 | diff_file = module.params['diff_file']
|
232 | 240 | get_diffs = module.params['get_diffs']
|
233 | 241 | archive_file = module.params['archive_file']
|
| 242 | + candidate_file = module.params['candidate_file'] |
234 | 243 |
|
235 | 244 | argument_check = {'hostname': hostname, 'username': username, 'dev_os': dev_os}
|
236 | 245 | for key, val in argument_check.items():
|
@@ -291,6 +300,13 @@ def main():
|
291 | 300 | except Exception as e:
|
292 | 301 | module.fail_json(msg="cannot diff config: " + str(e))
|
293 | 302 |
|
| 303 | + try: |
| 304 | + if candidate_file is not None: |
| 305 | + running_config = device.get_config(retrieve="candidate")["candidate"] |
| 306 | + save_to_file(running_config, candidate_file) |
| 307 | + except Exception, e: |
| 308 | + module.fail_json(msg="cannot retrieve running config:" + str(e)) |
| 309 | + |
294 | 310 | try:
|
295 | 311 | if module.check_mode or not commit_changes:
|
296 | 312 | device.discard_config()
|
|
0 commit comments