【发布时间】:2020-01-11 00:30:00
【问题描述】:
是否有解析我从标准输出中提取的输出。
name: PARSE ALL IP's
set fact: parsedbgpIPs="BGPOUTPUT.stdout[0] | regex_findall('\\b(?:[0-9]{1,3}\\.){3}[0-9]{1,3}\\b') }}"
这会从我的原始命令生成 IP 地址列表的输出。
10.1.1.1
10.2.2.2
10.3.3.3
我的问题是如何将输出分成 3 个 IP 地址,每个地址都存储为一个单独的变量?
【问题讨论】:
-
mystring.split()?如果输出已经是一个列表,那么它们已经是分开的 -
发布“debug: var=BGPOUTPUT”以查看选项。
-
这是在 ansible 中运行,所以输出略有不同
-
任务[调试] ****************************************** ****************************************************** ******************************************* 好的:[Router01] =>味精:|- IP 列表 - 10.1.1.1 - 10.2.2.2 - 10.3.3.3
-
- debug: msg: "List of IP's {{ parsedbgpIPs | to_nice_yaml }}"