--- - name: "Refresh mirrorlist" ansible.builtin.command: # CDN edges (e.g. fastly.mirror.pkgbuild.com) drop SSL on large downloads; pick working mirrors cmd: reflector --latest 5 --sort rate --protocol https --save /etc/pacman.d/mirrorlist changed_when: true - name: "Update live environment" ansible.builtin.command: cmd: "{{ item }}" loop: - "pacman -Sy --needed archlinux-keyring --noconfirm" changed_when: true - name: "Run pacstrap" ansible.builtin.command: cmd: "pacstrap -K {{ mnt_root_path }} base linux linux-firmware less nano" changed_when: true - name: "Generate fstab" ansible.builtin.shell: cmd: "genfstab -t PARTLABEL {{ mnt_root_path }} > {{ mnt_root_path }}/etc/fstab" changed_when: true - name: "Configure pacman in chroot" ansible.builtin.copy: src: "/etc/pacman.conf" dest: "{{ mnt_root_path }}/etc/pacman.conf" remote_src: true force: false mode: "0644" - name: "Configure system in chroot" ansible.builtin.command: cmd: "arch-chroot {{ mnt_root_path }} {{ item }}" changed_when: true loop: - "pacman-key --init" - "pacman-key --populate" - "pacman -Syyu --noconfirm" - name: "Ensure rEFInd package installed" ansible.builtin.command: cmd: "arch-chroot {{ mnt_root_path }} pacman -S --noconfirm refind" changed_when: true - name: "Install rEFInd to EFI partition" ansible.builtin.command: # NOTE: --usedefault installs to EFI/BOOT/ without NVRAM registration # This ensures consistent install location across refind versions (0.13.x installs to EFI/refind/ # via NVRAM, 0.14.x falls back to EFI/BOOT/ when NVRAM write fails in chroot) cmd: "arch-chroot {{ mnt_root_path }} refind-install --usedefault {{ partition_boot.dev }}" changed_when: true - name: "Configure rEFInd base settings" ansible.builtin.template: src: "refind.conf.j2" dest: "{{ mnt_boot_path }}/EFI/BOOT/refind.conf" mode: "0644" # NOTE: this is skipped because the docker test doesn't have proper EFI/BOOT directory created tags: ["molecule-notest"] - name: "Ensure arch EFI boot directory exists" ansible.builtin.file: path: "{{ mnt_boot_path }}/EFI/arch" state: directory mode: "0755" - name: "Copy kernel to EFI partition" ansible.builtin.copy: src: "{{ mnt_root_path }}/boot/{{ item }}" dest: "{{ mnt_boot_path }}/EFI/arch/{{ item }}" remote_src: true mode: "0644" loop: - "vmlinuz-linux" - "initramfs-linux.img" - name: "Configure Arch Linux boot entries" ansible.builtin.template: src: "archlinux/archlinux.conf.j2" dest: "{{ mnt_boot_path }}/EFI/BOOT/archlinux.conf" mode: "0644" # NOTE: this is skipped because the docker test doesn't have proper EFI/BOOT directory created tags: ["molecule-notest"] - name: "Install kernel sync script for EFI partition" ansible.builtin.template: src: "archlinux/refind-sync-kernel.j2" dest: "{{ mnt_root_path }}/usr/local/bin/refind-sync-kernel" mode: "0755" - name: "Configure pacman hook for rEFInd kernel updates" ansible.builtin.copy: dest: "{{ mnt_root_path }}/etc/pacman.d/100-refind.hook" mode: "0644" content: | [Trigger] Type = Package Operation = Install Operation = Upgrade Target = linux [Action] Description = Syncing kernel to EFI partition after kernel update When = PostTransaction Exec = /usr/local/bin/refind-sync-kernel - name: "Ensure ansible dependencies are installed in chroot" ansible.builtin.command: cmd: "arch-chroot {{ mnt_root_path }} pacman -S --noconfirm python3" changed_when: true