mirror of
https://github.com/fscotto/infra.git
synced 2026-05-30 23:49:56 +00:00
Generalize UFW rule inventory inputs
This commit is contained in:
@@ -19,6 +19,7 @@ host_ufw_rules:
|
|||||||
- rule: allow
|
- rule: allow
|
||||||
port: "22"
|
port: "22"
|
||||||
proto: tcp
|
proto: tcp
|
||||||
|
src: "192.168.0.0/24"
|
||||||
|
|
||||||
host_sshd_settings:
|
host_sshd_settings:
|
||||||
PermitRootLogin: "no"
|
PermitRootLogin: "no"
|
||||||
|
|||||||
@@ -142,6 +142,11 @@
|
|||||||
notify: Reload SSH service
|
notify: Reload SSH service
|
||||||
when: (host_sshd_allow_users | default([])) | length > 0
|
when: (host_sshd_allow_users | default([])) | length > 0
|
||||||
|
|
||||||
|
- name: Define effective desktop UFW rules
|
||||||
|
tags: [services, packages]
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
desktop_ufw_rules_effective: "{{ host_ufw_rules | default([]) }}"
|
||||||
|
|
||||||
- name: Apply host UFW rules on desktop
|
- name: Apply host UFW rules on desktop
|
||||||
tags: [services, packages]
|
tags: [services, packages]
|
||||||
community.general.ufw:
|
community.general.ufw:
|
||||||
@@ -149,7 +154,16 @@
|
|||||||
name: "{{ item.name | default(omit) }}"
|
name: "{{ item.name | default(omit) }}"
|
||||||
port: "{{ item.port | default(omit) }}"
|
port: "{{ item.port | default(omit) }}"
|
||||||
proto: "{{ item.proto | default(omit) }}"
|
proto: "{{ item.proto | default(omit) }}"
|
||||||
loop: "{{ host_ufw_rules | default([]) }}"
|
from_ip: "{{ item.src | default(omit) }}"
|
||||||
|
to_ip: "{{ item.dest | default(omit) }}"
|
||||||
|
from_port: "{{ item.from_port | default(omit) }}"
|
||||||
|
direction: "{{ item.direction | default(omit) }}"
|
||||||
|
interface: "{{ item.interface | default(omit) }}"
|
||||||
|
interface_in: "{{ item.interface_in | default(omit) }}"
|
||||||
|
interface_out: "{{ item.interface_out | default(omit) }}"
|
||||||
|
route: "{{ item.route | default(omit) }}"
|
||||||
|
comment: "{{ item.comment | default(omit) }}"
|
||||||
|
loop: "{{ desktop_ufw_rules_effective }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
label: "{{ item.name | default(item.port) }}"
|
label: "{{ item.name | default(item.port) }}"
|
||||||
|
|
||||||
@@ -157,7 +171,7 @@
|
|||||||
tags: [services, packages]
|
tags: [services, packages]
|
||||||
community.general.ufw:
|
community.general.ufw:
|
||||||
state: enabled
|
state: enabled
|
||||||
when: (host_ufw_rules | default([])) | length > 0
|
when: (desktop_ufw_rules_effective | default([])) | length > 0
|
||||||
|
|
||||||
- name: Check whether libvirt service directory exists
|
- name: Check whether libvirt service directory exists
|
||||||
tags: [packages, services]
|
tags: [packages, services]
|
||||||
|
|||||||
@@ -68,6 +68,11 @@
|
|||||||
notify: Reload SSH service
|
notify: Reload SSH service
|
||||||
when: (server_sshd_allow_users | default([])) | length > 0
|
when: (server_sshd_allow_users | default([])) | length > 0
|
||||||
|
|
||||||
|
- name: Define effective server UFW rules
|
||||||
|
tags: [services, packages]
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
server_ufw_rules_effective: "{{ server_ufw_rules | default([]) }}"
|
||||||
|
|
||||||
- name: Apply server UFW rules
|
- name: Apply server UFW rules
|
||||||
tags: [services, packages]
|
tags: [services, packages]
|
||||||
community.general.ufw:
|
community.general.ufw:
|
||||||
@@ -75,7 +80,16 @@
|
|||||||
name: "{{ item.name | default(omit) }}"
|
name: "{{ item.name | default(omit) }}"
|
||||||
port: "{{ item.port | default(omit) }}"
|
port: "{{ item.port | default(omit) }}"
|
||||||
proto: "{{ item.proto | default(omit) }}"
|
proto: "{{ item.proto | default(omit) }}"
|
||||||
loop: "{{ server_ufw_rules | default([]) }}"
|
from_ip: "{{ item.src | default(omit) }}"
|
||||||
|
to_ip: "{{ item.dest | default(omit) }}"
|
||||||
|
from_port: "{{ item.from_port | default(omit) }}"
|
||||||
|
direction: "{{ item.direction | default(omit) }}"
|
||||||
|
interface: "{{ item.interface | default(omit) }}"
|
||||||
|
interface_in: "{{ item.interface_in | default(omit) }}"
|
||||||
|
interface_out: "{{ item.interface_out | default(omit) }}"
|
||||||
|
route: "{{ item.route | default(omit) }}"
|
||||||
|
comment: "{{ item.comment | default(omit) }}"
|
||||||
|
loop: "{{ server_ufw_rules_effective }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
label: "{{ item.name | default(item.port) }}"
|
label: "{{ item.name | default(item.port) }}"
|
||||||
|
|
||||||
@@ -83,3 +97,4 @@
|
|||||||
tags: [services, packages]
|
tags: [services, packages]
|
||||||
community.general.ufw:
|
community.general.ufw:
|
||||||
state: enabled
|
state: enabled
|
||||||
|
when: (server_ufw_rules_effective | default([])) | length > 0
|
||||||
|
|||||||
Reference in New Issue
Block a user