Compare commits

4 Commits

Author SHA1 Message Date
602734acce roles: update ansible.builtin.systemd builtin
Use ansible.builtin.systemd_service instead.
2025-09-23 10:33:11 +03:00
0db7911b70 roles/common: remove sudoers.d
We are not using this.
2025-09-21 23:09:40 +03:00
ee4c62e5f9 roles: remove tests for Debian
We only run on Debian now.
2025-09-21 22:20:31 +03:00
a315db8a7c roles/common: use ansible_distribution_version
In most cases it is enough to use the full version (ie 12.12) since
we use Ansible's version comparison function. We rarely need to use
the major version (ie 12) directly.
2025-09-21 22:19:00 +03:00
17 changed files with 25 additions and 26 deletions

View File

@@ -3,7 +3,7 @@
# I'm currently not sure when we need to restart versus reload # I'm currently not sure when we need to restart versus reload
- name: reload caddy - name: reload caddy
ansible.builtin.systemd: ansible.builtin.systemd_service:
name: caddy name: caddy
state: reloaded state: reloaded

View File

@@ -36,7 +36,7 @@
{% elif has_wordpress -%} {% elif has_wordpress -%}
root * {{ document_root }} root * {{ document_root }}
encode encode
{% if ansible_distribution == 'Debian' and ansible_distribution_major_version is version('12', '==') -%} {% if ansible_distribution_major_version is version('12', '==') -%}
php_fastcgi unix//run/php/php8.2-fpm-{{ domain_name }}.sock php_fastcgi unix//run/php/php8.2-fpm-{{ domain_name }}.sock
{% endif -%} {% endif -%}
file_server file_server

View File

@@ -1 +0,0 @@
provisioning ALL=(ALL) ALL

View File

@@ -2,7 +2,7 @@
# ansible.builtin.file: roles/common/handlers/main.yml # ansible.builtin.file: roles/common/handlers/main.yml
- name: Reload sshd - name: Reload sshd
ansible.builtin.systemd: ansible.builtin.systemd_service:
name: "{{ sshd_service_name }}" name: "{{ sshd_service_name }}"
state: reloaded state: reloaded
@@ -10,11 +10,11 @@
ansible.builtin.command: sysctl -p /etc/sysctl.conf ansible.builtin.command: sysctl -p /etc/sysctl.conf
- name: Reload systemd - name: Reload systemd
ansible.builtin.systemd: ansible.builtin.systemd_service:
daemon_reload: true daemon_reload: true
- name: Restart nftables - name: Restart nftables
ansible.builtin.systemd: ansible.builtin.systemd_service:
name: nftables name: nftables
state: restarted state: restarted
@@ -22,6 +22,6 @@
# in the order they are defined, not in the order they are listed in the task's # in the order they are defined, not in the order they are listed in the task's
# notify statement and we must restart fail2ban after updating the firewall. # notify statement and we must restart fail2ban after updating the firewall.
- name: Restart fail2ban - name: Restart fail2ban
ansible.builtin.systemd: ansible.builtin.systemd_service:
name: fail2ban name: fail2ban
state: restarted state: restarted

View File

@@ -1,6 +1,6 @@
--- ---
- name: Install fail2ban - name: Install fail2ban
when: ansible_distribution_major_version is version('11', '>=') when: ansible_distribution_version is version('11', '>=')
ansible.builtin.apt: ansible.builtin.apt:
name: name:
- fail2ban - fail2ban
@@ -47,7 +47,7 @@
- Restart fail2ban - Restart fail2ban
- name: Start and enable fail2ban service - name: Start and enable fail2ban service
ansible.builtin.systemd: ansible.builtin.systemd_service:
name: fail2ban name: fail2ban
state: started state: started
enabled: true enabled: true

View File

@@ -2,14 +2,14 @@
# Debian 11+ will use nftables directly, with no firewalld. # Debian 11+ will use nftables directly, with no firewalld.
- name: Install Debian firewall packages - name: Install Debian firewall packages
when: ansible_distribution_major_version is version('11', '>=') when: ansible_distribution_version is version('11', '>=')
ansible.builtin.apt: ansible.builtin.apt:
name: nftables name: nftables
state: present state: present
cache_valid_time: 3600 cache_valid_time: 3600
- name: Remove iptables on newer Debian - name: Remove iptables on newer Debian
when: ansible_distribution_major_version is version('11', '>=') when: ansible_distribution_version is version('11', '>=')
ansible.builtin.apt: ansible.builtin.apt:
pkg: iptables pkg: iptables
state: absent state: absent
@@ -19,7 +19,7 @@
ansible.builtin.include_tasks: nftables.yml ansible.builtin.include_tasks: nftables.yml
- name: Configure fail2ban - name: Configure fail2ban
when: ansible_distribution_major_version is version('9', '>=') when: ansible_distribution_version is version('9', '>=')
ansible.builtin.include_tasks: fail2ban.yml ansible.builtin.include_tasks: fail2ban.yml
# vim: set sw=2 ts=2: # vim: set sw=2 ts=2:

View File

@@ -76,11 +76,11 @@
# need to reload to pick up service/timer/environment changes # need to reload to pick up service/timer/environment changes
- name: Reload systemd daemon - name: Reload systemd daemon
when: nftables_systemd_units is changed when: nftables_systemd_units is changed
ansible.builtin.systemd: # noqa no-handler ansible.builtin.systemd_service: # noqa no-handler
daemon_reload: true daemon_reload: true
- name: Start and enable nftables update timers - name: Start and enable nftables update timers
ansible.builtin.systemd: ansible.builtin.systemd_service:
name: "{{ item }}" name: "{{ item }}"
state: started state: started
enabled: true enabled: true
@@ -88,7 +88,7 @@
- update-firehol-nftables.timer - update-firehol-nftables.timer
- name: Start and enable nftables - name: Start and enable nftables
ansible.builtin.systemd: ansible.builtin.systemd_service:
name: nftables name: nftables
state: started state: started
enabled: true enabled: true

View File

@@ -22,7 +22,7 @@
- name: Start and enable systemd's NTP client - name: Start and enable systemd's NTP client
when: ansible_service_mgr == 'systemd' when: ansible_service_mgr == 'systemd'
ansible.builtin.systemd: ansible.builtin.systemd_service:
name: systemd-timesyncd name: systemd-timesyncd
state: started state: started
enabled: true enabled: true

View File

@@ -6,14 +6,14 @@ PartOf=nftables.service
PrivateDevices=yes PrivateDevices=yes
PrivateTmp=yes PrivateTmp=yes
ProtectHome=read-only ProtectHome=read-only
{% if ansible_distribution == 'Debian' and ansible_distribution_major_version is version('11','>=') %} {% if ansible_distribution_version is version('11','>=') %}
ProtectSystem=strict ProtectSystem=strict
{% else %} {% else %}
{# Older systemd versions don't have ProtectSystem=strict #} {# Older systemd versions don't have ProtectSystem=strict #}
ProtectSystem=full ProtectSystem=full
{% endif %} {% endif %}
NoNewPrivileges=yes NoNewPrivileges=yes
{% if ansible_distribution == 'Debian' and ansible_distribution_major_version is version('11','>=') %} {% if ansible_distribution_version is version('11','>=') %}
ReadWritePaths=-/var/run/fail2ban ReadWritePaths=-/var/run/fail2ban
ReadWritePaths=-/var/lib/fail2ban ReadWritePaths=-/var/lib/fail2ban
ReadWritePaths=-/var/log/fail2ban.log ReadWritePaths=-/var/log/fail2ban.log

View File

@@ -1,6 +1,6 @@
--- ---
- name: restart mariadb - name: restart mariadb
ansible.builtin.systemd: ansible.builtin.systemd_service:
name: mariadb name: mariadb
state: restarted state: restarted

View File

@@ -1,4 +1,4 @@
--- ---
# ansible.builtin.file: roles/munin/handlers/main.yml # ansible.builtin.file: roles/munin/handlers/main.yml
- name: restart munin-node - name: restart munin-node
ansible.builtin.systemd: name=munin-node state=restarted ansible.builtin.systemd_service: name=munin-node state=restarted

View File

@@ -26,7 +26,7 @@
- restart munin-node - restart munin-node
- name: Start munin-node - name: Start munin-node
ansible.builtin.systemd: ansible.builtin.systemd_service:
name: munin-node name: munin-node
state: started state: started
enabled: true enabled: true

View File

@@ -1,6 +1,6 @@
--- ---
- name: Reload nginx - name: Reload nginx
ansible.builtin.systemd: ansible.builtin.systemd_service:
name: nginx name: nginx
state: reloaded state: reloaded

View File

@@ -82,7 +82,7 @@
# always issues daemon-reload just in case the service/timer changed # always issues daemon-reload just in case the service/timer changed
- name: Start and enable systemd timer to renew Let's Encrypt certs - name: Start and enable systemd timer to renew Let's Encrypt certs
ansible.builtin.systemd: ansible.builtin.systemd_service:
name: renew-letsencrypt.timer name: renew-letsencrypt.timer
state: started state: started
enabled: true enabled: true

View File

@@ -119,7 +119,7 @@
tags: nginx tags: nginx
- name: Start and enable nginx service - name: Start and enable nginx service
ansible.builtin.systemd: ansible.builtin.systemd_service:
name: nginx name: nginx
state: started state: started
enabled: true enabled: true

View File

@@ -77,7 +77,7 @@ server {
# See: https://httpoxy.org/ # See: https://httpoxy.org/
fastcgi_param HTTP_PROXY ""; fastcgi_param HTTP_PROXY "";
{% if ansible_distribution == 'Debian' and ansible_distribution_major_version is version('12', '==') %} {% if ansible_distribution_major_version is version('12', '==') %}
fastcgi_pass unix:/run/php/php8.2-fpm-{{ domain_name }}.sock; fastcgi_pass unix:/run/php/php8.2-fpm-{{ domain_name }}.sock;
{% endif %} {% endif %}
fastcgi_index index.php; fastcgi_index index.php;

View File

@@ -1,7 +1,7 @@
--- ---
# For Debian 12 # For Debian 12
- name: Reload php8.2-fpm - name: Reload php8.2-fpm
ansible.builtin.systemd: ansible.builtin.systemd_service:
name: php8.2-fpm name: php8.2-fpm
state: reloaded state: reloaded