尝试通过 Ansible 推出 UFW。
- name: Install UFW Firwall
hosts: all
tasks:
- name: UFW enabled
community.general.ufw:
state: "enabled"
policy: "deny"
我希望传出规则允许一切,传入规则拒绝一切。我只是不知道该如何实现,有人能帮我吗?
答案1
好吧,这真的很简单。只需添加一个direction: outgoing
。所以完整的代码如下:
- name: Install UFW Firewall
hosts: all
tasks:
- name: Outgoing allow
community.general.ufw:
state: enabled
direction: outgoing
policy: allow
- name: Incoming deny
community.general.ufw:
state: enabled
direction: incoming
policy: deny