我想获得配置提交到设备之前和之后的输出。
Ansible 代码:
- name: Get device information
hosts: working_hosts
connection: local
gather_facts: false
vars:
ansible_network_os: junipernetworks.junos.junos
connection_info:
port: '{{ ansible_ssh_port }}'
user: '{{ ansible_ssh_user }}'
passwd: '{{ ansible_ssh_pass }}'
tasks:
- name: load configure lines into device and commit to device
junipernetworks.junos.junos_config:
update: 'merge'
lines:
- set security address-book global address 10.xxx.x.xxx 10.xxx.x.xxx/xx
check_commit: yes
confirm_commit: yes
register: junos_output
diff: true
- debug:
var: junos_output
下面的输出没有显示以前和当前提交的配置之间的差异,如果我在这里做错了什么,请帮助我。
输出:
ok: [xx.xx.xxx.xx] => {
"changed": false,
"invocation": {
"module_args": {
"backup": false,
"backup_options": null,
"check_commit": true,
"comment": "configured by junos_config",
"confirm": 0,
"confirm_commit": false,
"lines": [
"set security address-book global address 10.xxx.x.xxx 10.xxx.x.xxx/xx"
],
"provider": null,
"replace": null,
"rollback": null,
"src": null,
"src_format": null,
"update": "merge",
"zeroize": false
}
}
}
我们可以使用以下命令将候选配置与之前提交的配置进行比较:
show | compare rollback rollback-number
show | compare rollback 1
输出:
[edit security address-book global]
+ address xx.xxx.xx.xx { ... }
+ address xx.xxx.xx.xx {
+ xx.xxx.x.xxx/xx;
+ }
我可以使用 juniper.device.config 模块获得预期的输出,但我需要 junipernetworks.junos.junos_config 模块。
- name: Print diff between current and rollback 1. No check. No commit.
juniper.device.config:
rollback: 1
diff: true
check: false
commit: false
register: response
- name: Print the msg.
debug:
var: response.diff_lines
提前致谢。