diff --git a/roles/ufw/defaults/main.yaml b/roles/ufw/defaults/main.yaml new file mode 100644 index 0000000..a14d001 --- /dev/null +++ b/roles/ufw/defaults/main.yaml @@ -0,0 +1,6 @@ +--- +# ufw_state: enabled +# ufw_policy: allow +ufw_rules: + - port: ssh + rule: allow diff --git a/roles/ufw/tasks/configure.yaml b/roles/ufw/tasks/configure.yaml new file mode 100644 index 0000000..1952ce1 --- /dev/null +++ b/roles/ufw/tasks/configure.yaml @@ -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([]) }}" diff --git a/roles/ufw/tasks/default.yaml b/roles/ufw/tasks/default.yaml new file mode 100644 index 0000000..e69de29 diff --git a/roles/ufw/tasks/main.yaml b/roles/ufw/tasks/main.yaml new file mode 100644 index 0000000..83e9fe2 --- /dev/null +++ b/roles/ufw/tasks/main.yaml @@ -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 diff --git a/roles/ufw/vars/default.yaml b/roles/ufw/vars/default.yaml new file mode 100644 index 0000000..e69de29