firewalld 模块
使用firewalld模块可以配置防火墙策略
[root@control ~]# cat ~/ansible/firewall.yml
---
- hosts: agent
tasks:
- name: install firewalld.
yum:
name: firewalld
state: present
- name: run firewalld.
service:
name: firewalld
state: started
enabled: yes
- name: set firewalld rule
firewalld:
port: 80/tcp
permanent: yes
state: enabled
以上可进行:安装防火墙、启动防火墙、允许80端口的访问
其他案例
- firewalld:
port: 8081/tcp
permanent: yes
state: disabled
- firewalld:
port: 161-162/udp
permanent: yes
state: enabled
- firewalld:
zone: dmz
service: http
permanent: yes
state: enabled
查看防火墙永久规则:firewalld-cmd --list-ports --permanent
标签:模块,enabled,firewalld,permanent,state,Ansible,应用,yes,name From: https://www.cnblogs.com/houhuilinblogs/p/17965482