From 139ba7504a4adfd73367c8514a38296b9cd3acaa Mon Sep 17 00:00:00 2001 From: Marius Melzer Date: Sat, 20 Apr 2024 15:23:38 +0200 Subject: [PATCH 01/11] Add system-basics role - set time zone - limit journal size - set vim as editor - limit ssh login to pubkey --- roles/system-basics/handlers/main.json | 17 +++++++++++++ roles/system-basics/tasks/main.json | 33 ++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 roles/system-basics/handlers/main.json create mode 100644 roles/system-basics/tasks/main.json diff --git a/roles/system-basics/handlers/main.json b/roles/system-basics/handlers/main.json new file mode 100644 index 0000000..1da98d3 --- /dev/null +++ b/roles/system-basics/handlers/main.json @@ -0,0 +1,17 @@ +[ + { + "name": "restart sshd", + "service": { + "name": "sshd", + "state": "restarted" + } + }, + { + "name": "restart journal", + "service": { + "name": "systemd-journald", + "state": "restarted", + "enabled": "yes" + } + } +] diff --git a/roles/system-basics/tasks/main.json b/roles/system-basics/tasks/main.json new file mode 100644 index 0000000..1b87040 --- /dev/null +++ b/roles/system-basics/tasks/main.json @@ -0,0 +1,33 @@ +[ + { + "name": "Set timezone to Berlin", + "community.general.timezone": { + "name": "Europe/Berlin" + } + }, + { + "name": "Limit syslogs", + "lineinfile": { + "dest": "/etc/systemd/journald.conf", + "regexp": "^#?\\s*SystemMaxFileSize", + "line": "SystemMaxFileSize=2G" + }, + "notify": "restart journal" + }, + { + "name": "Set vim as default editor", + "alternatives": { + "name": "editor", + "path": "/usr/bin/vim.basic" + } + }, + { + "name": "Disable root login without key", + "lineinfile": { + "dest": "/etc/ssh/sshd_config", + "regexp": "^#?PermitRootLogin ", + "line": "PermitRootLogin without-password" + }, + "notify": "restart sshd" + } +] From fcad5b93547d48d9a897e9abdd371e19a8c27703 Mon Sep 17 00:00:00 2001 From: Marius Melzer Date: Sat, 20 Apr 2024 15:24:38 +0200 Subject: [PATCH 02/11] Add unattended upgrades Enable unattended upgrades and triggers unattended reboots (23:55 after an upgrade which needs reboot). Attention: this is specific to debian-style linux systems (Debian, Ubuntu,...). --- .../unattended-upgrades/files/20auto-upgrades | 2 ++ roles/unattended-upgrades/tasks/main.json | 33 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 roles/unattended-upgrades/files/20auto-upgrades create mode 100644 roles/unattended-upgrades/tasks/main.json diff --git a/roles/unattended-upgrades/files/20auto-upgrades b/roles/unattended-upgrades/files/20auto-upgrades new file mode 100644 index 0000000..8d6d7c8 --- /dev/null +++ b/roles/unattended-upgrades/files/20auto-upgrades @@ -0,0 +1,2 @@ +APT::Periodic::Update-Package-Lists "1"; +APT::Periodic::Unattended-Upgrade "1"; diff --git a/roles/unattended-upgrades/tasks/main.json b/roles/unattended-upgrades/tasks/main.json new file mode 100644 index 0000000..7706bc3 --- /dev/null +++ b/roles/unattended-upgrades/tasks/main.json @@ -0,0 +1,33 @@ +[ + { + "name": "Allow unattended reboots (1)", + "lineinfile": { + "dest": "/etc/apt/apt.conf.d/50unattended-upgrades", + "regexp": "^(//)?Unattended-Upgrade::Automatic-Reboot ", + "line": "Unattended-Upgrade::Automatic-Reboot \"true\";" + } + }, + { + "name": "Allow unattended reboots (2)", + "lineinfile": { + "dest": "/etc/apt/apt.conf.d/50unattended-upgrades", + "regexp": "^(//)?Unattended-Upgrade::Automatic-Reboot-Time ", + "line": "Unattended-Upgrade::Automatic-Reboot-Time \"23:55\";" + } + }, + { + "name": "Allow more origins for updates", + "lineinfile": { + "dest": "/etc/apt/apt.conf.d/50unattended-upgrades", + "regexp": "^(//\\s*)?\"\\$\\{distro_id\\}:\\$\\{distro_codename\\}-updates\";", + "line": "\"${distro_id}:${distro_codename}-updates\";" + } + }, + { + "name": "Enable unattended upgrades", + "copy": { + "src": "20auto-upgrades", + "dest": "/etc/apt/apt.conf.d/20auto-upgrades" + } + } +] From 65b00c88400a774d0cbc40459c0d1e80bc31cbb4 Mon Sep 17 00:00:00 2001 From: Marius Melzer Date: Sat, 20 Apr 2024 17:08:39 +0200 Subject: [PATCH 03/11] Add ufw role - Enable ufw and by default deny incoming traffic - in other roles: if ufw (role) is enabled, then allow necessary ports --- roles/lighttpd/tasks/main.json | 26 +++++++++++++++++++++ roles/murmur/tasks/main.json | 17 ++++++++++++++ roles/nginx/tasks/main.json | 26 +++++++++++++++++++++ roles/proftpd/tasks/main.json | 26 +++++++++++++++++++++ roles/synapse/tasks/main.json | 17 ++++++++++++++ roles/ufw/tasks/main.json | 41 ++++++++++++++++++++++++++++++++++ 6 files changed, 153 insertions(+) create mode 100644 roles/ufw/tasks/main.json diff --git a/roles/lighttpd/tasks/main.json b/roles/lighttpd/tasks/main.json index 1b6af91..8e85d43 100644 --- a/roles/lighttpd/tasks/main.json +++ b/roles/lighttpd/tasks/main.json @@ -27,6 +27,32 @@ "dest": "/etc/lighttpd/conf-enabled/10-ssl-custom.conf" } }, + { + "name": "Check wether enabling UFW would be considered a changed", + "check_mode": true, + "community.general.ufw": { + "state": "enabled", + "register": "ufw_enable_check" + } + }, + { + "name": "Allow port 80 in ufw", + "community.general.ufw": { + "rule": "allow", + "port": "80", + "proto": "tcp" + }, + "when": "not ufw_enable_check.changed" + }, + { + "name": "Allow port 443 in ufw", + "community.general.ufw": { + "rule": "allow", + "port": "443", + "proto": "tcp" + }, + "when": "not ufw_enable_check.changed" + }, { "name": "restart service", "become": true, diff --git a/roles/murmur/tasks/main.json b/roles/murmur/tasks/main.json index 7341ac8..b8303b2 100644 --- a/roles/murmur/tasks/main.json +++ b/roles/murmur/tasks/main.json @@ -25,6 +25,23 @@ "cmd": "murmurd -ini /etc/mumble-server.ini -supw {{var_murmur_admin_password}}" } }, + { + "name": "Check wether enabling UFW would be considered a changed", + "check_mode": true, + "community.general.ufw": { + "state": "enabled", + "register": "ufw_enable_check" + } + }, + { + "name": "Allow port in ufw", + "community.general.ufw": { + "rule": "allow", + "port": "{{ var_murmur_port }}", + "proto": "tcp" + }, + "when": "not ufw_enable_check.changed" + }, { "name": "service", "become": true, diff --git a/roles/nginx/tasks/main.json b/roles/nginx/tasks/main.json index c8e2b40..39a68de 100644 --- a/roles/nginx/tasks/main.json +++ b/roles/nginx/tasks/main.json @@ -9,6 +9,32 @@ ] } }, + { + "name": "Check wether enabling UFW would be considered a changed", + "check_mode": true, + "community.general.ufw": { + "state": "enabled", + "register": "ufw_enable_check" + } + }, + { + "name": "Allow port 80 in ufw", + "community.general.ufw": { + "rule": "allow", + "port": "80", + "proto": "tcp" + }, + "when": "not ufw_enable_check.changed" + }, + { + "name": "Allow port 443 in ufw", + "community.general.ufw": { + "rule": "allow", + "port": "443", + "proto": "tcp" + }, + "when": "not ufw_enable_check.changed" + }, { "name": "restart service", "become": true, diff --git a/roles/proftpd/tasks/main.json b/roles/proftpd/tasks/main.json index d277bc0..53374a6 100644 --- a/roles/proftpd/tasks/main.json +++ b/roles/proftpd/tasks/main.json @@ -8,5 +8,31 @@ "proftpd-core" ] } + }, + { + "name": "Check wether enabling UFW would be considered a changed", + "check_mode": true, + "community.general.ufw": { + "state": "enabled", + "register": "ufw_enable_check" + } + }, + { + "name": "Allow FTP port 20 in ufw", + "community.general.ufw": { + "rule": "allow", + "port": "20", + "proto": "tcp" + }, + "when": "not ufw_enable_check.changed" + }, + { + "name": "Allow FTP port 21 in ufw", + "community.general.ufw": { + "rule": "allow", + "port": "21", + "proto": "tcp" + }, + "when": "not ufw_enable_check.changed" } ] diff --git a/roles/synapse/tasks/main.json b/roles/synapse/tasks/main.json index fd44ce1..ef5c79c 100644 --- a/roles/synapse/tasks/main.json +++ b/roles/synapse/tasks/main.json @@ -58,6 +58,23 @@ "dest": "/etc/matrix-synapse/homeserver.yaml" } }, + { + "name": "Check wether enabling UFW would be considered a changed", + "check_mode": true, + "community.general.ufw": { + "state": "enabled", + "register": "ufw_enable_check" + } + }, + { + "name": "Allow matrix federation port in ufw", + "community.general.ufw": { + "rule": "allow", + "port": "8448", + "proto": "tcp" + }, + "when": "not ufw_enable_check.changed" + }, { "name": "restart service", "become": true, diff --git a/roles/ufw/tasks/main.json b/roles/ufw/tasks/main.json new file mode 100644 index 0000000..b3ed847 --- /dev/null +++ b/roles/ufw/tasks/main.json @@ -0,0 +1,41 @@ +[ + { + "name": "install ufw", + "become": true, + "ansible.builtin.apt": { + "update_cache": true, + "pkg": [ + "ufw" + ] + } + }, + { + "name": "ufw deny incoming", + "ufw": { + "direction": "incoming", + "proto": "any", + "policy": "deny" + } + }, + { + "name": "ufw allow outgoing", + "ufw": { + "direction": "outgoing", + "proto": "any", + "policy": "allow" + } + }, + { + "name": "ufw allow and rate-limit ssh", + "ufw": { + "rule": "limit", + "name": "ssh" + } + }, + { + "name": "enable ufw service", + "ufw": { + "state": "enabled" + } + } +] From e70ab02fed0fa6c3a987b36fd911f0982f25344f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Fra=C3=9F?= Date: Wed, 24 Apr 2024 17:38:11 +0000 Subject: [PATCH 04/11] Apply 6 suggestion(s) to 2 file(s) --- roles/system-basics/handlers/main.json | 6 +++--- roles/system-basics/tasks/main.json | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/roles/system-basics/handlers/main.json b/roles/system-basics/handlers/main.json index 1da98d3..ba5eace 100644 --- a/roles/system-basics/handlers/main.json +++ b/roles/system-basics/handlers/main.json @@ -1,17 +1,17 @@ [ { "name": "restart sshd", - "service": { + "ansible.builtin.service": { "name": "sshd", "state": "restarted" } }, { "name": "restart journal", - "service": { + "ansible.builtin.service": { "name": "systemd-journald", "state": "restarted", - "enabled": "yes" + "enabled": true } } ] diff --git a/roles/system-basics/tasks/main.json b/roles/system-basics/tasks/main.json index 1b87040..707b1f1 100644 --- a/roles/system-basics/tasks/main.json +++ b/roles/system-basics/tasks/main.json @@ -7,7 +7,7 @@ }, { "name": "Limit syslogs", - "lineinfile": { + "ansible.builtin.lineinfile": { "dest": "/etc/systemd/journald.conf", "regexp": "^#?\\s*SystemMaxFileSize", "line": "SystemMaxFileSize=2G" @@ -16,14 +16,14 @@ }, { "name": "Set vim as default editor", - "alternatives": { + "community.general.alternatives": { "name": "editor", "path": "/usr/bin/vim.basic" } }, { "name": "Disable root login without key", - "lineinfile": { + "ansible.builtin.lineinfile": { "dest": "/etc/ssh/sshd_config", "regexp": "^#?PermitRootLogin ", "line": "PermitRootLogin without-password" From 389b171401bbef40b021e74e8c9249f172d2ca8b Mon Sep 17 00:00:00 2001 From: Marius Melzer Date: Wed, 24 Apr 2024 20:02:51 +0200 Subject: [PATCH 05/11] Apply review comments --- roles/system-basics/tasks/main.json | 9 ++++ roles/unattended-upgrades/tasks/main.json | 62 +++++++++++------------ 2 files changed, 40 insertions(+), 31 deletions(-) diff --git a/roles/system-basics/tasks/main.json b/roles/system-basics/tasks/main.json index 707b1f1..08c35fe 100644 --- a/roles/system-basics/tasks/main.json +++ b/roles/system-basics/tasks/main.json @@ -14,6 +14,15 @@ }, "notify": "restart journal" }, + { + "name": "Install vim", + "become": true, + "ansible.builtin.apt": { + "pkg": [ + "vim" + ] + } + }, { "name": "Set vim as default editor", "community.general.alternatives": { diff --git a/roles/unattended-upgrades/tasks/main.json b/roles/unattended-upgrades/tasks/main.json index 7706bc3..4098ae9 100644 --- a/roles/unattended-upgrades/tasks/main.json +++ b/roles/unattended-upgrades/tasks/main.json @@ -1,33 +1,33 @@ [ - { - "name": "Allow unattended reboots (1)", - "lineinfile": { - "dest": "/etc/apt/apt.conf.d/50unattended-upgrades", - "regexp": "^(//)?Unattended-Upgrade::Automatic-Reboot ", - "line": "Unattended-Upgrade::Automatic-Reboot \"true\";" - } - }, - { - "name": "Allow unattended reboots (2)", - "lineinfile": { - "dest": "/etc/apt/apt.conf.d/50unattended-upgrades", - "regexp": "^(//)?Unattended-Upgrade::Automatic-Reboot-Time ", - "line": "Unattended-Upgrade::Automatic-Reboot-Time \"23:55\";" - } - }, - { - "name": "Allow more origins for updates", - "lineinfile": { - "dest": "/etc/apt/apt.conf.d/50unattended-upgrades", - "regexp": "^(//\\s*)?\"\\$\\{distro_id\\}:\\$\\{distro_codename\\}-updates\";", - "line": "\"${distro_id}:${distro_codename}-updates\";" - } - }, - { - "name": "Enable unattended upgrades", - "copy": { - "src": "20auto-upgrades", - "dest": "/etc/apt/apt.conf.d/20auto-upgrades" - } - } + { + "name": "Allow unattended reboots (1)", + "lineinfile": { + "dest": "/etc/apt/apt.conf.d/50unattended-upgrades", + "regexp": "^(//)?Unattended-Upgrade::Automatic-Reboot ", + "line": "Unattended-Upgrade::Automatic-Reboot \"true\";" + } + }, + { + "name": "Allow unattended reboots (2)", + "lineinfile": { + "dest": "/etc/apt/apt.conf.d/50unattended-upgrades", + "regexp": "^(//)?Unattended-Upgrade::Automatic-Reboot-Time ", + "line": "Unattended-Upgrade::Automatic-Reboot-Time \"23:55\";" + } + }, + { + "name": "Allow more origins for updates", + "lineinfile": { + "dest": "/etc/apt/apt.conf.d/50unattended-upgrades", + "regexp": "^(//\\s*)?\"\\$\\{distro_id\\}:\\$\\{distro_codename\\}-updates\";", + "line": "\"${distro_id}:${distro_codename}-updates\";" + } + }, + { + "name": "Enable unattended upgrades", + "copy": { + "src": "20auto-upgrades", + "dest": "/etc/apt/apt.conf.d/20auto-upgrades" + } + } ] From 715d39716c6c903ee8bfdf7fbec9f96f05c22548 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Fra=C3=9F?= Date: Sat, 1 Jun 2024 13:43:40 +0200 Subject: [PATCH 06/11] [fix] install required packages [fix] add missing become:true directives [mod] use fully qualified names for ansible tasks --- roles/unattended-upgrades/tasks/main.json | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/roles/unattended-upgrades/tasks/main.json b/roles/unattended-upgrades/tasks/main.json index 4098ae9..014209d 100644 --- a/roles/unattended-upgrades/tasks/main.json +++ b/roles/unattended-upgrades/tasks/main.json @@ -1,7 +1,19 @@ [ + { + "name": "install packages", + "become": true, + "ansible.builtin.apt": { + "update_cache": true, + "pkg": [ + "unattended-upgrades", + "apt-listchanges" + ] + } + }, { "name": "Allow unattended reboots (1)", - "lineinfile": { + "become": true, + "ansible.builtin.lineinfile": { "dest": "/etc/apt/apt.conf.d/50unattended-upgrades", "regexp": "^(//)?Unattended-Upgrade::Automatic-Reboot ", "line": "Unattended-Upgrade::Automatic-Reboot \"true\";" @@ -9,7 +21,8 @@ }, { "name": "Allow unattended reboots (2)", - "lineinfile": { + "become": true, + "ansible.builtin.lineinfile": { "dest": "/etc/apt/apt.conf.d/50unattended-upgrades", "regexp": "^(//)?Unattended-Upgrade::Automatic-Reboot-Time ", "line": "Unattended-Upgrade::Automatic-Reboot-Time \"23:55\";" @@ -17,7 +30,8 @@ }, { "name": "Allow more origins for updates", - "lineinfile": { + "become": true, + "ansible.builtin.lineinfile": { "dest": "/etc/apt/apt.conf.d/50unattended-upgrades", "regexp": "^(//\\s*)?\"\\$\\{distro_id\\}:\\$\\{distro_codename\\}-updates\";", "line": "\"${distro_id}:${distro_codename}-updates\";" @@ -25,7 +39,8 @@ }, { "name": "Enable unattended upgrades", - "copy": { + "become": true, + "ansible.builtin.copy": { "src": "20auto-upgrades", "dest": "/etc/apt/apt.conf.d/20auto-upgrades" } From 8d57e57df82096477ec666310545f7c9dc269f13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Fra=C3=9F?= Date: Sat, 1 Jun 2024 13:44:51 +0200 Subject: [PATCH 07/11] [mod] role:unattended-upgrades renamed to unattended_upgrades --- .../files/20auto-upgrades | 0 .../{unattended-upgrades => unattended_upgrades}/tasks/main.json | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename roles/{unattended-upgrades => unattended_upgrades}/files/20auto-upgrades (100%) rename roles/{unattended-upgrades => unattended_upgrades}/tasks/main.json (100%) diff --git a/roles/unattended-upgrades/files/20auto-upgrades b/roles/unattended_upgrades/files/20auto-upgrades similarity index 100% rename from roles/unattended-upgrades/files/20auto-upgrades rename to roles/unattended_upgrades/files/20auto-upgrades diff --git a/roles/unattended-upgrades/tasks/main.json b/roles/unattended_upgrades/tasks/main.json similarity index 100% rename from roles/unattended-upgrades/tasks/main.json rename to roles/unattended_upgrades/tasks/main.json From 0e913099e67b47e9a4362d40e958fac1675ba72f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Fra=C3=9F?= Date: Sat, 1 Jun 2024 13:47:20 +0200 Subject: [PATCH 08/11] [fix] role:system-basics:add missing become:true directives [mod] role:system-basisc:also install htop and tmux --- roles/system-basics/tasks/main.json | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/roles/system-basics/tasks/main.json b/roles/system-basics/tasks/main.json index 08c35fe..11a8792 100644 --- a/roles/system-basics/tasks/main.json +++ b/roles/system-basics/tasks/main.json @@ -1,12 +1,14 @@ [ { "name": "Set timezone to Berlin", + "become": true, "community.general.timezone": { "name": "Europe/Berlin" } }, { "name": "Limit syslogs", + "become": true, "ansible.builtin.lineinfile": { "dest": "/etc/systemd/journald.conf", "regexp": "^#?\\s*SystemMaxFileSize", @@ -15,16 +17,19 @@ "notify": "restart journal" }, { - "name": "Install vim", + "name": "install packages", "become": true, "ansible.builtin.apt": { "pkg": [ - "vim" + "vim", + "htop", + "tmux" ] } }, { "name": "Set vim as default editor", + "become": true, "community.general.alternatives": { "name": "editor", "path": "/usr/bin/vim.basic" @@ -32,6 +37,7 @@ }, { "name": "Disable root login without key", + "become": true, "ansible.builtin.lineinfile": { "dest": "/etc/ssh/sshd_config", "regexp": "^#?PermitRootLogin ", From 434c90117317c9b9c5a8bd6e3fdadad355ee746a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Fra=C3=9F?= Date: Sat, 1 Jun 2024 13:47:47 +0200 Subject: [PATCH 09/11] [mod] role:system-basics renamed to system_basics --- roles/{system-basics => system_basics}/handlers/main.json | 0 roles/{system-basics => system_basics}/tasks/main.json | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename roles/{system-basics => system_basics}/handlers/main.json (100%) rename roles/{system-basics => system_basics}/tasks/main.json (100%) diff --git a/roles/system-basics/handlers/main.json b/roles/system_basics/handlers/main.json similarity index 100% rename from roles/system-basics/handlers/main.json rename to roles/system_basics/handlers/main.json diff --git a/roles/system-basics/tasks/main.json b/roles/system_basics/tasks/main.json similarity index 100% rename from roles/system-basics/tasks/main.json rename to roles/system_basics/tasks/main.json From 2ac8c9c4c3a75b5e20f7fae4416885814b07a5fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Fra=C3=9F?= Date: Sat, 1 Jun 2024 13:49:11 +0200 Subject: [PATCH 10/11] [fix] role:ufw:add missing become:true directives [mod] role:ufw:use fully qualified names for ansible tasks --- roles/ufw/tasks/main.json | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/roles/ufw/tasks/main.json b/roles/ufw/tasks/main.json index b3ed847..003e4b6 100644 --- a/roles/ufw/tasks/main.json +++ b/roles/ufw/tasks/main.json @@ -11,7 +11,8 @@ }, { "name": "ufw deny incoming", - "ufw": { + "become": true, + "community.general.ufw": { "direction": "incoming", "proto": "any", "policy": "deny" @@ -19,7 +20,8 @@ }, { "name": "ufw allow outgoing", - "ufw": { + "become": true, + "community.general.ufw": { "direction": "outgoing", "proto": "any", "policy": "allow" @@ -27,14 +29,16 @@ }, { "name": "ufw allow and rate-limit ssh", - "ufw": { + "become": true, + "community.general.ufw": { "rule": "limit", "name": "ssh" } }, { "name": "enable ufw service", - "ufw": { + "become": true, + "community.general.ufw": { "state": "enabled" } } From c7c9e6895cd6df181707e023434b485967ed375b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Fra=C3=9F?= Date: Sat, 1 Jun 2024 17:56:28 +0200 Subject: [PATCH 11/11] [fix] roles with ufw incocation --- roles/lighttpd/tasks/main.json | 23 +++++++++++++---------- roles/murmur/tasks/main.json | 18 ++++++++++-------- roles/nginx/tasks/main.json | 23 +++++++++++++---------- roles/proftpd/tasks/main.json | 23 +++++++++++++---------- roles/synapse/tasks/main.json | 16 +++++++++------- 5 files changed, 58 insertions(+), 45 deletions(-) diff --git a/roles/lighttpd/tasks/main.json b/roles/lighttpd/tasks/main.json index 8e85d43..d29fcdf 100644 --- a/roles/lighttpd/tasks/main.json +++ b/roles/lighttpd/tasks/main.json @@ -28,30 +28,33 @@ } }, { - "name": "Check wether enabling UFW would be considered a changed", + "name": "ufw | check", "check_mode": true, + "become": true, "community.general.ufw": { - "state": "enabled", - "register": "ufw_enable_check" - } + "state": "enabled" + }, + "register": "ufw_enable_check" }, { - "name": "Allow port 80 in ufw", + "name": "ufw | allow port 80", + "when": "not ufw_enable_check.changed", + "become": true, "community.general.ufw": { "rule": "allow", "port": "80", "proto": "tcp" - }, - "when": "not ufw_enable_check.changed" + } }, { - "name": "Allow port 443 in ufw", + "name": "ufw | allow port 443", + "when": "not ufw_enable_check.changed", + "become": true, "community.general.ufw": { "rule": "allow", "port": "443", "proto": "tcp" - }, - "when": "not ufw_enable_check.changed" + } }, { "name": "restart service", diff --git a/roles/murmur/tasks/main.json b/roles/murmur/tasks/main.json index b8303b2..1b9ed12 100644 --- a/roles/murmur/tasks/main.json +++ b/roles/murmur/tasks/main.json @@ -26,21 +26,23 @@ } }, { - "name": "Check wether enabling UFW would be considered a changed", + "name": "ufw | check", "check_mode": true, + "become": true, "community.general.ufw": { - "state": "enabled", - "register": "ufw_enable_check" - } + "state": "enabled" + }, + "register": "ufw_enable_check" }, { - "name": "Allow port in ufw", + "name": "ufw | allow port", + "when": "not ufw_enable_check.changed", + "become": true, "community.general.ufw": { "rule": "allow", - "port": "{{ var_murmur_port }}", + "port": "{{var_murmur_port | string}}", "proto": "tcp" - }, - "when": "not ufw_enable_check.changed" + } }, { "name": "service", diff --git a/roles/nginx/tasks/main.json b/roles/nginx/tasks/main.json index 39a68de..2fe467c 100644 --- a/roles/nginx/tasks/main.json +++ b/roles/nginx/tasks/main.json @@ -10,30 +10,33 @@ } }, { - "name": "Check wether enabling UFW would be considered a changed", + "name": "ufw | check", + "become": true, "check_mode": true, "community.general.ufw": { - "state": "enabled", - "register": "ufw_enable_check" - } + "state": "enabled" + }, + "register": "ufw_enable_check" }, { - "name": "Allow port 80 in ufw", + "name": "ufw | allow port 80", + "when": "not ufw_enable_check.changed", + "become": true, "community.general.ufw": { "rule": "allow", "port": "80", "proto": "tcp" - }, - "when": "not ufw_enable_check.changed" + } }, { - "name": "Allow port 443 in ufw", + "name": "ufw | allow port 443", + "when": "not ufw_enable_check.changed", + "become": true, "community.general.ufw": { "rule": "allow", "port": "443", "proto": "tcp" - }, - "when": "not ufw_enable_check.changed" + } }, { "name": "restart service", diff --git a/roles/proftpd/tasks/main.json b/roles/proftpd/tasks/main.json index 53374a6..e5bf9a0 100644 --- a/roles/proftpd/tasks/main.json +++ b/roles/proftpd/tasks/main.json @@ -10,29 +10,32 @@ } }, { - "name": "Check wether enabling UFW would be considered a changed", + "name": "ufw | check", "check_mode": true, + "become": true, "community.general.ufw": { - "state": "enabled", - "register": "ufw_enable_check" - } + "state": "enabled" + }, + "register": "ufw_enable_check" }, { - "name": "Allow FTP port 20 in ufw", + "name": "ufw | allow port 20", + "when": "not ufw_enable_check.changed", + "become": true, "community.general.ufw": { "rule": "allow", "port": "20", "proto": "tcp" - }, - "when": "not ufw_enable_check.changed" + } }, { - "name": "Allow FTP port 21 in ufw", + "name": "ufw | allow port 21", + "when": "not ufw_enable_check.changed", + "become": true, "community.general.ufw": { "rule": "allow", "port": "21", "proto": "tcp" - }, - "when": "not ufw_enable_check.changed" + } } ] diff --git a/roles/synapse/tasks/main.json b/roles/synapse/tasks/main.json index ef5c79c..63e0e78 100644 --- a/roles/synapse/tasks/main.json +++ b/roles/synapse/tasks/main.json @@ -59,21 +59,23 @@ } }, { - "name": "Check wether enabling UFW would be considered a changed", + "name": "ufw | check", + "become": true, "check_mode": true, "community.general.ufw": { - "state": "enabled", - "register": "ufw_enable_check" - } + "state": "enabled" + }, + "register": "ufw_enable_check" }, { - "name": "Allow matrix federation port in ufw", + "name": "ufw | allow port", + "when": "not ufw_enable_check.changed", + "become": true, "community.general.ufw": { "rule": "allow", "port": "8448", "proto": "tcp" - }, - "when": "not ufw_enable_check.changed" + } }, { "name": "restart service",