refactor(configuration): convert services.yml to list-based loop

This commit is contained in:
2026-02-20 21:16:37 +01:00
parent ba6be037ac
commit ef8bfeaf84

View File

@@ -1,21 +1,19 @@
--- ---
# Single systemctl enable — atomic; individual failures abort the command - name: Enable systemd services
- name: Enable Systemd Services
when: os not in ['alpine', 'void'] when: os not in ['alpine', 'void']
ansible.builtin.command: > vars:
{{ chroot_command }} systemctl enable NetworkManager configuration_systemd_services: >-
{{ ' firewalld' if system_cfg.features.firewall.backend == 'firewalld' and system_cfg.features.firewall.enabled | bool else '' }} {{
{{ ' ufw' if system_cfg.features.firewall.backend == 'ufw' and system_cfg.features.firewall.enabled | bool else '' }} ['NetworkManager']
{{ + (['firewalld'] if system_cfg.features.firewall.backend == 'firewalld' and system_cfg.features.firewall.enabled | bool else [])
(' ssh' if is_debian | bool else ' sshd') + (['ufw'] if system_cfg.features.firewall.backend == 'ufw' and system_cfg.features.firewall.enabled | bool else [])
if system_cfg.features.ssh.enabled | bool else '' + ([('ssh' if is_debian | bool else 'sshd')] if system_cfg.features.ssh.enabled | bool else [])
}} + (['logrotate', 'systemd-timesyncd'] if os == 'archlinux' else [])
{{ }}
' logrotate systemd-timesyncd' ansible.builtin.command: "{{ chroot_command }} systemctl enable {{ item }}"
if os == 'archlinux' else '' loop: "{{ configuration_systemd_services }}"
}} register: configuration_enable_service_result
register: configuration_enable_services_result changed_when: configuration_enable_service_result.rc == 0
changed_when: configuration_enable_services_result.rc == 0
- name: Enable OpenRC services - name: Enable OpenRC services
when: os == 'alpine' when: os == 'alpine'