--- - name: "Include distribution vars" ansible.builtin.include_vars: "{{ ansible_facts['distribution'] | lower }}.yml" - name: "Ensure install dependencies are installed on live environment" ansible.builtin.apt: state: "present" update_cache: true pkg: - "debootstrap" - "arch-install-scripts" - "bash" - name: "Run debootstrap" ansible.builtin.command: cmd: "debootstrap {{ bootstrap_opts }} {{ bootstrap_distro.name }} {{ mnt_root_path }} {{ bootstrap_distro.mirror_url }}" 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 apt in chroot" ansible.builtin.copy: dest: "{{ item.dest }}" mode: "0640" content: "{{ item.content }}" loop: - dest: "{{ mnt_root_path }}/etc/apt/preferences.d/ignored-package" content: "{{ bootstrap_apt_ignored_preferences }}" - dest: "{{ mnt_root_path }}/etc/apt/sources.list" content: "{{ bootstrap_apt_sources }}" - name: "Ensure DNS works in chroot" # debootstrap seeds /etc/resolv.conf as a symlink to the systemd-resolved stub (127.0.0.53), # which is broken when /run is a tmpfs (e.g. in Docker/molecule) ansible.builtin.copy: src: "/etc/resolv.conf" dest: "{{ mnt_root_path }}/etc/resolv.conf" follow: false force: true mode: "0644" - name: "Configure system in chroot" ansible.builtin.command: cmd: "arch-chroot {{ mnt_root_path }} {{ item }}" changed_when: true loop: - "apt-get update" - "apt-get install -y {{ bootstrap_distro.packages | join(' ') }}" - name: "Replace sudo-rs with sudo in chroot" ansible.builtin.command: cmd: "arch-chroot {{ mnt_root_path }} apt-get install -y --allow-remove-essential sudo sudo-rs-" changed_when: true - name: "Ensure rEFInd package installed" ansible.builtin.command: cmd: "arch-chroot {{ mnt_root_path }} apt-get install -y 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 ubuntu EFI boot directory exists" ansible.builtin.file: path: "{{ mnt_boot_path }}/EFI/ubuntu" state: directory mode: "0755" - name: "Copy kernel to EFI partition" ansible.builtin.copy: src: "{{ mnt_root_path }}/boot/{{ item }}" dest: "{{ mnt_boot_path }}/EFI/ubuntu/{{ item }}" remote_src: true follow: true mode: "0644" loop: - "vmlinuz" - "initrd.img" - name: "Configure Ubuntu boot entries" ansible.builtin.template: src: "ubuntu/ubuntu.conf.j2" dest: "{{ mnt_boot_path }}/EFI/BOOT/ubuntu.conf" mode: "0644" # NOTE: this is skipped because the docker test doesn't have proper EFI/BOOT directory created tags: ["molecule-notest"] - name: "Ensure kernel post-install hook directory exists" ansible.builtin.file: path: "{{ mnt_root_path }}/etc/kernel/postinst.d" state: directory mode: "0755" - name: "Install kernel sync script for EFI partition" ansible.builtin.template: src: "ubuntu/refind-sync-kernel.j2" dest: "{{ mnt_root_path }}/etc/kernel/postinst.d/refind-sync-kernel" mode: "0755"