我有以下玩法:
- command: "hostname -I"
register: IP_ADRESSS
changed_when: False
- firewalld:
interface: eth0
state: enabled
permanent: yes
zone: public
source: {{ IP_ADDRESS.stdout }}
notify: "RESTART FIREWALL"
比赛结果如下:
fatal: [test-server]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"immediate": false,
"interface": "eth0",
"masquerade": null,
"offline": null,
"permanent": true,
"port": null,
"rich_rule": null,
"service": null,
"source": "10.0.0.5 "
"state": "enabled"
"timeout": 0,
"zone": "public"
}
},
"msg": "ERROR: Exception caught: org.fedoraproject.FirewallD1.Exception: INVALID_ADDR: 10.0.0.5 Permanent operation"
}
当“source”的值来自“IP_ADDRESS.stdout”的值时,就会发生错误。IP_ADDRESS.stdout 的结果在 ip 地址的末尾添加了一个空格,这会导致失败。当我“硬编码”IP地址时,它可以工作。
谁能指导我如何更正标准输出输出?
谢谢