我尝试将以下内容添加到Ansible攻略中:
firewall-cmd --permanent --new-zone dockerc
firewall-cmd --permanent --zone dockerc --add-source 172.17.0.0/16
firewall-cmd --permanent --zone dockerc --add-port 8443/tcp
firewall-cmd --permanent --zone dockerc --add-port 53/udp但根据http://docs.ansible.com/ansible/firewalld_module.html的说法,区域没有添加新区域的选项。
有没有人知道是否可以使用Ansible将dockerc添加为一个新的专区?
发布于 2018-06-27 19:36:44
从2017-12-12开始,特别是提交8475171f67f,firewalld模块支持区域的创建(和删除)。
- firewalld:
zone: custom
state: present
permanent: true将state设置为present或absent,并确保zone、state和permanent是任务中唯一的键。
来自source code的注释
只能使用区域和状态参数“存在”或“不存在”来执行
发布于 2017-02-18 07:34:29
不幸的是,firewalld模块不适合创建新区域。如果firewall-cmd在您的主机上可用,则只需单独运行它:
- command: firewall-cmd --permanent --new-zone dockerc一旦设置好区域,您就可以正常使用该模块:
- firewalld:
zone: dockerc
permanent: true
source: 172.17.0.0/16
state: enabled如果您不能单独使用firewall-cmd命令,那么您可能就不走运了,因为检查source code of the module,您可以看到它不包含创建新区域的代码。
但是请注意,这个模块是ansible内部的一个策划者模块,这意味着它没有得到完全的核心支持。如果您了解python,那么欢迎您发送一个拉取请求,使此模块能够创建新区域。
https://stackoverflow.com/questions/42293872
复制相似问题