initial version of pf module
This commit is contained in:
parent
107f5d32ac
commit
332b433971
4 changed files with 53 additions and 0 deletions
6
roles/pf/defaults/main.yml
Normal file
6
roles/pf/defaults/main.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
|
||||
firewall_in:
|
||||
- {proto: tcp, port: 22}
|
||||
|
||||
firewall_raw: []
|
4
roles/pf/handlers/main.yml
Normal file
4
roles/pf/handlers/main.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
|
||||
- name: reload pf
|
||||
command: /sbin/pfctl -f /etc/pf.conf
|
21
roles/pf/tasks/main.yml
Normal file
21
roles/pf/tasks/main.yml
Normal file
|
@ -0,0 +1,21 @@
|
|||
---
|
||||
|
||||
- name: copy pf.conf
|
||||
copy:
|
||||
src: "{{ firewall_src }}"
|
||||
dest: /etc/pf.conf
|
||||
mode: 0600
|
||||
owner: root
|
||||
group: "{{ ansible_wheel }}"
|
||||
notify: reload pf
|
||||
when: firewall_src is defined
|
||||
|
||||
- name: create pf.conf from template
|
||||
template:
|
||||
src: pf.conf.j2
|
||||
dest: /etc/pf.conf
|
||||
mode: 0600
|
||||
owner: root
|
||||
group: "{{ ansible_wheel }}"
|
||||
notify: reload pf
|
||||
when: firewall_src is not defined
|
22
roles/pf/templates/pf.conf.j2
Normal file
22
roles/pf/templates/pf.conf.j2
Normal file
|
@ -0,0 +1,22 @@
|
|||
|
||||
set block-policy return
|
||||
set skip on lo0
|
||||
|
||||
block in
|
||||
pass out
|
||||
|
||||
pass in quick proto icmp
|
||||
pass in quick proto icmp6
|
||||
|
||||
{% for rule in firewall_raw %}
|
||||
{{ rule }}
|
||||
{% endfor %}
|
||||
{% for rule in firewall_in %}
|
||||
{% if rule.from is defined %}
|
||||
{% for from in rule.from | ipaddr %}
|
||||
pass in quick proto {{ rule.proto }} from {{ from }} to port {{ rule.port }}
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
pass in quick proto {{ rule.proto }} to port {{ rule.port }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
Loading…
Add table
Add a link
Reference in a new issue