我是 Ansible 的新手。我正在尝试编写一个剧本来配置 UFW。我的任务是这样的:
- name: Allow SSH in UFW
ufw:
rule: allow
port: 22
proto: tcp
from_ip:
- "{{ item }}"
with_items:
- 192.168.0.0/24
- 10.200.3.0/24
- 10.200.2.0/24
运行剧本时我得到的结果是:
failed: [192.168.255.20] (item=192.168.0.0/24) => {"changed": false, "item": "192.168.0.0/24", "msg": "ERROR: Bad source address\n"}
failed: [192.168.255.20] (item=10.200.3.0/24) => {"changed": false, "item": "10.200.3.0/24", "msg": "ERROR: Bad source address\n"}
failed: [192.168.255.20] (item=10.200.2.0/24) => {"changed": false, "item": "10.200.2.0/24", "msg": "ERROR: Bad source address\n"}
我在 Ansible UFW 文档或 UFW 本身中找不到任何会阻止它工作的东西。如果我删除“with_items”循环并分别输入每个 IP 子网,它们都可以工作,但这可能会产生一些非常长的剧本。谁能告诉我我做错了什么?
我正在使用的文档在这里: https ://docs.ansible.com/ansible/latest/modules/ufw_module.html?highlight=ufw
编辑:包括以详细模式运行的文本:
failed: [192.168.255.20] (item=10.200.2.0/24) => {
"changed": false,
"invocation": {
"module_args": {
"app": null,
"comment": null,
"default": null,
"delete": false,
"direction": null,
"from_ip": "['10.200.2.0/24']",
"from_port": null,
"insert": null,
"interface": null,
"log": false,
"logging": null,
"port": 22,
"proto": "tcp",
"route": false,
"rule": "allow",
"state": null,
"to_ip": "any",
"to_port": "22"
}
},
"item": "10.200.2.0/24",
"msg": "ERROR: Bad source address\n"