我想提取将 IPv6 地址分配给接口的 Juniper 配置行,并将该输出保存到文件中。
我所追求的输出是使用命令“show configuration |”生成的。展示套装| 匹配 "inet6 地址" '
我正在构建一个 Ansible 剧本并排除错误以完成以下任务。它基本上为我提供了完整的界面配置,我只想将其缩小到适合手动命令中“匹配”行的行。注释掉的过滤器不起作用,我找不到以我理解的方式解释过滤器的文档。
- name: "Get selected configuration hierarchies"
juniper_junos_config:
host: "{{ ansible_host }}"
retrieve: "committed"
config_mode : "private"
filter: "<configuration><interfaces/></configuration>"
#filter: "<configuration><interfaces/><family/><inet6/><address/></configuration>"
#filter: "inet6/address"
format: "set"
options:
inherit: "inherit"
dest: "{{ inventory_hostname }}-inet6-config"
register: response
- name: "Print result"
debug:
var: response
输出:
ok: [LAB-QFX5110-1] => {
"response": {
"changed": false,
"config": "\nset interfaces xe-0/0/0 apply-groups-except jumbo-frames\nset interfaces xe-0/0/0 description \"Test Laptop - DMZ;000\"\nset interfaces xe-0/0/0 gigether-options 802.3ad ae12\n<SNIP>\nset interfaces lo0 unit 10 family inet address 100.126.0.x/32\nset interfaces lo0 unit 10 family inet6 address ABCD:EF00:0000:01c4::1/128\n<SNIP>/n",
"config_lines": [
"",
"set interfaces xe-0/0/0 apply-groups-except jumbo-frames",
"set interfaces xe-0/0/0 description \"Test Laptop - DMZ;000\"",
"set interfaces xe-0/0/0 gigether-options 802.3ad ae12",
"<SNIP>",
"set interfaces lo0 unit 10 family inet address 100.126.0.x/32",
"set interfaces lo0 unit 10 family inet6 address ABCD:EF00:0000:01c4::1/128",
"<SNIP>",
],
"failed": false,
"msg": "Configuration has been: opened, retrieved, closed."
}
}
我只想要这样的行:
设置接口单元 X 系列 inet6 地址 XXXX:YYYY:ZZZZ:1234::1/127
但我似乎无法插入正确的过滤器。
我还会提到,如果有更好的方法来收集它,我愿意探索它。看起来这就是 Ansible 被创建来执行的任务。