Add role for ufw
This commit is contained in:
parent
7caf443b35
commit
b45f8cf5dd
6
roles/ufw/defaults/main.yaml
Normal file
6
roles/ufw/defaults/main.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
# ufw_state: enabled
|
||||
# ufw_policy: allow
|
||||
ufw_rules:
|
||||
- port: ssh
|
||||
rule: allow
|
12
roles/ufw/tasks/configure.yaml
Normal file
12
roles/ufw/tasks/configure.yaml
Normal file
@ -0,0 +1,12 @@
|
||||
---
|
||||
- name: set ufw state
|
||||
community.general.ufw:
|
||||
state: "{{ ufw_state | default('enabled') }}"
|
||||
policy: "{{ ufw_policy | default('allow') }}"
|
||||
|
||||
- name: configure rules
|
||||
community.general.ufw:
|
||||
port: "{{ item.port | default(omit) }}"
|
||||
proto: "{{ item.proto | default(omit) }}"
|
||||
rule: "{{ item.rule | default(omit) }}"
|
||||
loop: "{{ ufw_rules | default([]) }}"
|
0
roles/ufw/tasks/default.yaml
Normal file
0
roles/ufw/tasks/default.yaml
Normal file
26
roles/ufw/tasks/main.yaml
Normal file
26
roles/ufw/tasks/main.yaml
Normal file
@ -0,0 +1,26 @@
|
||||
---
|
||||
- name: gather OS specific variables
|
||||
ansible.builtin.include_vars: "{{ lookup('ansible.builtin.first_found', params) }}"
|
||||
vars:
|
||||
params:
|
||||
files:
|
||||
- "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yaml"
|
||||
- "{{ ansible_distribution }}.yaml"
|
||||
- "{{ ansible_os_family }}.yaml"
|
||||
- "default.yaml"
|
||||
paths:
|
||||
- vars
|
||||
|
||||
- name: run os specific tasks
|
||||
ansible.builtin.include_tasks: "{{ lookup('ansible.builtin.first_found', params) }}"
|
||||
vars:
|
||||
params:
|
||||
files:
|
||||
- "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yaml"
|
||||
- "{{ ansible_distribution }}.yaml"
|
||||
- "{{ ansible_os_family }}.yaml"
|
||||
- "default.yaml"
|
||||
paths:
|
||||
- tasks
|
||||
|
||||
- include_tasks: configure.yaml
|
0
roles/ufw/vars/default.yaml
Normal file
0
roles/ufw/vars/default.yaml
Normal file
Loading…
Reference in New Issue
Block a user