diff options
| author | Ahmed Abdelhalim <[email protected]> | 2025-08-11 00:33:33 +0200 |
|---|---|---|
| committer | Ahmed Abdelhalim <[email protected]> | 2025-08-11 00:33:33 +0200 |
| commit | b94d56f916c275ba73e4cd668629652993a96107 (patch) | |
| tree | 7b265cb5c6d94e51eecfcb1cb805aa46a845dbf3 /roles/bootstrap/tasks | |
| parent | d3e78a37b6d907ecbfc817db6ba4c7a71f8a96c3 (diff) | |
Add Raspberry Pi5 support to bootstrap
Diffstat (limited to 'roles/bootstrap/tasks')
| -rw-r--r-- | roles/bootstrap/tasks/install-archlinux.yml | 6 | ||||
| -rw-r--r-- | roles/bootstrap/tasks/install-raspberry.yml | 84 | ||||
| -rw-r--r-- | roles/bootstrap/tasks/install-ubuntu.yml | 17 | ||||
| -rw-r--r-- | roles/bootstrap/tasks/main.yml | 24 |
4 files changed, 105 insertions, 26 deletions
diff --git a/roles/bootstrap/tasks/install-archlinux.yml b/roles/bootstrap/tasks/install-archlinux.yml index c467be8..f91b1eb 100644 --- a/roles/bootstrap/tasks/install-archlinux.yml +++ b/roles/bootstrap/tasks/install-archlinux.yml @@ -2,14 +2,8 @@ - name: "Run pacstrap" ansible.builtin.command: cmd: "pacstrap -K {{ mnt_root_path }} base linux linux-firmware" - register: bootstrap_result changed_when: true -- name: "Display bootstrap output" - ansible.builtin.debug: - var: bootstrap_result.stdout_lines - verbosity: 1 - - name: "Generate fstab" ansible.builtin.shell: cmd: "genfstab -t PARTLABEL {{ mnt_root_path }} > {{ mnt_root_path }}/etc/fstab" diff --git a/roles/bootstrap/tasks/install-raspberry.yml b/roles/bootstrap/tasks/install-raspberry.yml new file mode 100644 index 0000000..f19b104 --- /dev/null +++ b/roles/bootstrap/tasks/install-raspberry.yml @@ -0,0 +1,84 @@ +--- +- name: "Include distribution vars" + ansible.builtin.include_vars: "{{ ansible_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" + - "gnupg" + - "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 }}" + with_items: + - 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: "Download signing key" + ansible.builtin.get_url: + url: "https://archive.raspberrypi.org/debian/raspberrypi.gpg.key" + dest: "/opt/raspberrypi.gpg.key" + force: true + mode: "0644" + +- name: "Dearmor signing key" + ansible.builtin.command: + cmd: "gpg -o {{ mnt_root_path }}/usr/share/keyrings/raspberrypi.gpg --dearmor /opt/raspberrypi.gpg.key" + changed_when: true + +- name: "Configure system in chroot" + ansible.builtin.command: + cmd: "arch-chroot {{ mnt_root_path }} {{ item }}" + changed_when: true + with_items: + - "apt-get update" + - "apt-get install -y {{ bootstrap_distro.packages | join(' ') }}" + +- name: "Copy kernel to boot partition" + # NOTE: Copying {{ mnt_root_path }}/boot/ doesn't work + # NOTE: Alternative, download latest fresh from https://github.com/raspberrypi/firmware/archive/refs/heads/master.zip + ansible.builtin.shell: | + cp -r /boot/firmware/* {{ mnt_boot_path }}/ + changed_when: true + +- name: "Configure bootloader" + ansible.builtin.template: + src: "{{ item.src }}" + dest: "{{ item.dest }}" + mode: "0644" + with_items: + - src: "raspberry.config.j2" + dest: "{{ mnt_boot_path }}/config.txt" + - src: "raspberry.cmdline.j2" + dest: "{{ mnt_boot_path }}/cmdline.txt" + +- name: "Configure boot order" + ansible.builtin.shell: | + set -eo pipefail + rpi-eeprom-config --apply <(rpi-eeprom-config | sed 's/^BOOT_ORDER=.*/BOOT_ORDER={{ bootstrap_boot_order }}/') + args: + executable: "bash" + changed_when: true diff --git a/roles/bootstrap/tasks/install-ubuntu.yml b/roles/bootstrap/tasks/install-ubuntu.yml index 9e6801f..f1c28d7 100644 --- a/roles/bootstrap/tasks/install-ubuntu.yml +++ b/roles/bootstrap/tasks/install-ubuntu.yml @@ -18,14 +18,8 @@ {{ bootstrap_distro.name }} {{ mnt_root_path }} {{ bootstrap_distro.mirror_url }}" - register: bootstrap_result changed_when: true -- name: "Display bootstrap output" - ansible.builtin.debug: - var: bootstrap_result.stdout_lines - verbosity: 1 - - name: "Generate fstab" ansible.builtin.shell: cmd: "genfstab -t PARTLABEL {{ mnt_root_path }} > {{ mnt_root_path }}/etc/fstab" @@ -104,14 +98,3 @@ with_items: - "{{ mnt_boot_path }}/{{ bootstrap_machine_id.stdout }}" - "{{ mnt_boot_path }}/loader/entries/{{ bootstrap_machine_id.stdout }}-{{ bootstrap_kernel_version.stdout }}.conf" - -- name: "Configure hostname in chroot" - ansible.builtin.copy: - dest: "{{ mnt_root_path }}/etc/hostname" - mode: "0644" - content: "{{ hostname }}" - -- name: "Ensure ansible dependencies are installed in chroot" - ansible.builtin.command: - cmd: "arch-chroot {{ mnt_root_path }} apt-get install -y python3" - changed_when: true diff --git a/roles/bootstrap/tasks/main.yml b/roles/bootstrap/tasks/main.yml index 723561d..3c239bf 100644 --- a/roles/bootstrap/tasks/main.yml +++ b/roles/bootstrap/tasks/main.yml @@ -9,6 +9,24 @@ ansible.builtin.include_tasks: "install-archlinux.yml" when: ansible_os_family == "Archlinux" -- name: "Install ubuntu" - ansible.builtin.include_tasks: "install-ubuntu.yml" - when: ansible_os_distribution == "Ubuntu" +- name: "Install debian" + when: ansible_os_family == "Debian" + block: + - name: "Install ubuntu" + ansible.builtin.include_tasks: "install-ubuntu.yml" + when: ansible_distribution == "Ubuntu" + + - name: "Install raspberry" + ansible.builtin.include_tasks: "install-raspberry.yml" + when: ansible_distribution == "Debian" + + - name: "Configure hostname in chroot" + ansible.builtin.copy: + dest: "{{ mnt_root_path }}/etc/hostname" + mode: "0644" + content: "{{ hostname }}" + + - name: "Ensure ansible dependencies are installed in chroot" + ansible.builtin.command: + cmd: "arch-chroot {{ mnt_root_path }} apt-get install -y python3" + changed_when: true |
