summaryrefslogtreecommitdiffstats
path: root/roles/bootstrap/tasks/install-raspberry.yml
blob: 179b6a82a4b14dd1fba9c7c765616e4c58f5723d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
---
- name: "Include Raspberry vars"
  ansible.builtin.include_vars: "raspberry.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 }}"
  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: "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
  loop:
    - "apt-get update"
    - "apt-get install -y {{ bootstrap_distro.packages | join(' ') }}"

- name: "Update rpi kernel and firmware"
  ansible.builtin.command:
    cmd: "arch-chroot {{ mnt_root_path }} rpi-update"
  environment:
    SKIP_BACKUP: "1"
    WANT_64BIT: "1"
    WANT_PI5: "1"
    SKIP_WARNING: "1"
    SKIP_CHECK_PARTITION: "1"
  changed_when: true
  tags: ["molecule-notest"]

- name: "Configure bootloader"
  ansible.builtin.template:
    src: "{{ item.src }}"
    dest: "{{ item.dest }}"
    mode: "0644"
  loop:
    - src: "raspberry/raspberry.config.j2"
      dest: "{{ mnt_boot_path }}/config.txt"
    - src: "raspberry/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
  tags: ["molecule-notest"]