fix(partitioning,network): swapon idempotency, DNS search domains, tune2fs changed_when

This commit is contained in:
2026-02-22 01:58:56 +01:00
parent 6985235e70
commit a2b206127f
4 changed files with 15 additions and 2 deletions

View File

@@ -27,11 +27,15 @@
- name: Set Alpine DNS resolvers - name: Set Alpine DNS resolvers
vars: vars:
configuration_dns_list: "{{ system_cfg.network.dns.servers | default([]) }}" configuration_dns_list: "{{ system_cfg.network.dns.servers | default([]) }}"
when: configuration_dns_list | length > 0 configuration_dns_search: "{{ system_cfg.network.dns.search | default([]) }}"
when: configuration_dns_list | length > 0 or configuration_dns_search | length > 0
ansible.builtin.copy: ansible.builtin.copy:
dest: /mnt/etc/resolv.conf dest: /mnt/etc/resolv.conf
mode: "0644" mode: "0644"
content: | content: |
{% if configuration_dns_search | length > 0 %}
search {{ configuration_dns_search | join(' ') }}
{% endif %}
{% for resolver in configuration_dns_list %} {% for resolver in configuration_dns_list %}
nameserver {{ resolver }} nameserver {{ resolver }}
{% endfor %} {% endfor %}

View File

@@ -2,6 +2,7 @@
- name: Write dhcpcd configuration - name: Write dhcpcd configuration
vars: vars:
configuration_dns_list: "{{ system_cfg.network.dns.servers | default([]) }}" configuration_dns_list: "{{ system_cfg.network.dns.servers | default([]) }}"
configuration_dns_search: "{{ system_cfg.network.dns.search | default([]) }}"
ansible.builtin.copy: ansible.builtin.copy:
dest: /mnt/etc/dhcpcd.conf dest: /mnt/etc/dhcpcd.conf
mode: "0644" mode: "0644"
@@ -20,6 +21,9 @@
{% if loop.index0 == 0 and configuration_dns_list | length > 0 %} {% if loop.index0 == 0 and configuration_dns_list | length > 0 %}
static domain_name_servers={{ configuration_dns_list | join(' ') }} static domain_name_servers={{ configuration_dns_list | join(' ') }}
{% endif %} {% endif %}
{% if loop.index0 == 0 and configuration_dns_search | length > 0 %}
static domain_search={{ configuration_dns_search | join(' ') }}
{% endif %}
{% endif %} {% endif %}
{% endfor %} {% endfor %}

View File

@@ -25,7 +25,7 @@
tune2fs -O "^orphan_file,^metadata_csum_seed" tune2fs -O "^orphan_file,^metadata_csum_seed"
"{{ install_drive }}{{ partitioning_boot_fs_partition_suffix }}" "{{ install_drive }}{{ partitioning_boot_fs_partition_suffix }}"
register: partitioning_boot_ext4_tune_result register: partitioning_boot_ext4_tune_result
changed_when: partitioning_boot_ext4_tune_result.rc == 0 changed_when: false
- name: Create swap filesystem - name: Create swap filesystem
when: when:

View File

@@ -1,6 +1,9 @@
--- ---
- name: Mount filesystems - name: Mount filesystems
block: block:
# CIS mode: mount all paths (separate partitions for /home, /var, etc.)
# Non-CIS btrfs: only mount subvolume paths (/home, /var/log, /var/cache/pacman/pkg)
# Non-CIS LVM: skip CIS-only paths (/home, /var, /var/log, /var/log/audit, /var/cache/pacman/pkg)
- name: Mount filesystems and subvolumes - name: Mount filesystems and subvolumes
when: when:
- >- - >-
@@ -121,4 +124,6 @@
{{ 'swapon /mnt/swap/swapfile' if system_cfg.filesystem == 'btrfs' else 'swapon -U ' + partitioning_uuid_swap[0] }} {{ 'swapon /mnt/swap/swapfile' if system_cfg.filesystem == 'btrfs' else 'swapon -U ' + partitioning_uuid_swap[0] }}
ansible.builtin.command: "{{ partitioning_swap_cmd }}" ansible.builtin.command: "{{ partitioning_swap_cmd }}"
register: partitioning_swap_activate_result register: partitioning_swap_activate_result
# swapon returns 255 if swap is already active
failed_when: partitioning_swap_activate_result.rc not in [0, 255]
changed_when: partitioning_swap_activate_result.rc == 0 changed_when: partitioning_swap_activate_result.rc == 0