diff --git a/roles/raspberrypi/tasks/prereq/Archlinux.yml b/roles/raspberrypi/tasks/prereq/Archlinux.yml index cd4f44d..9529070 100644 --- a/roles/raspberrypi/tasks/prereq/Archlinux.yml +++ b/roles/raspberrypi/tasks/prereq/Archlinux.yml @@ -1,6 +1,6 @@ --- - name: Check for boot configuration files - ansible.builtin.stat: + ansible.builtin.stat: # noqa var-naming[no-role-prefix] path: "{{ item }}" loop: - /boot/boot.txt @@ -9,25 +9,12 @@ - name: Set boot_file fact ansible.builtin.set_fact: - rpi_boot_file: "{{ (boot_files.results | selectattr('stat.exists') | map(attribute='item') | list | first) | default('') }}" + raspberrypi_boot_file: "{{ (boot_files.results | selectattr('stat.exists') | map(attribute='item') | list | first) | default('') }}" -- name: Enable cgroup via boot commandline (boot.txt) +# Arch ARM64 boots via /boot/boot.txt (UBoot), /boot/cmdline.txt only exists on legacy 32-bit systems +- name: Enable cgroup via boot commandline ansible.builtin.replace: - path: /boot/boot.txt - regexp: '^(setenv bootargs console=ttyS1,115200 console=tty0 root=PARTUUID=\${uuid} rw rootwait smsc95xx.macaddr="\${usbethaddr}"(?!.*\b{{ cgroup_item }}\b).*)$' - replace: '\1 {{ cgroup_item }}' - with_items: - - "cgroup_enable=cpuset" - - "cgroup_memory=1" - - "cgroup_enable=memory" - loop_control: - loop_var: cgroup_item - when: rpi_boot_file == '/boot/boot.txt' - notify: Regenerate bootloader image - -- name: Enable cgroup via boot commandline (cmdline.txt) - ansible.builtin.replace: - path: /boot/cmdline.txt + path: "{{ raspberrypi_boot_file }}" regexp: '^([\w](?!.*\b{{ cgroup_item }}\b).*)$' replace: '\1 {{ cgroup_item }}' with_items: @@ -36,5 +23,4 @@ - "cgroup_enable=memory" loop_control: loop_var: cgroup_item - when: rpi_boot_file == '/boot/cmdline.txt' - notify: Reboot Pi + notify: "{{ (raspberrypi_boot_file == '/boot/boot.txt') | ternary('Regenerate bootloader image', 'Reboot Pi') }}" diff --git a/roles/raspberrypi/tasks/prereq/Debian.yml b/roles/raspberrypi/tasks/prereq/Debian.yml index e965a32..1f7075d 100644 --- a/roles/raspberrypi/tasks/prereq/Debian.yml +++ b/roles/raspberrypi/tasks/prereq/Debian.yml @@ -2,11 +2,11 @@ - name: Check if /boot/firmware/cmdline.txt exists ansible.builtin.stat: path: /boot/firmware/cmdline.txt - register: boot_firmware_cmdline_txt + register: raspberrypi_boot_file - name: Enable cgroup via boot commandline if not already enabled ansible.builtin.replace: - path: "{{ (boot_firmware_cmdline_txt.stat.exists) | ternary('/boot/firmware/cmdline.txt', '/boot/cmdline.txt') }}" + path: "{{ (raspberrypi_boot_file.stat.exists) | ternary('/boot/firmware/cmdline.txt', '/boot/cmdline.txt') }}" regexp: '^([\w](?!.*\b{{ cgroup_item }}\b).*)$' replace: '\1 {{ cgroup_item }}' loop: @@ -41,10 +41,8 @@ community.general.alternatives: path: /usr/sbin/iptables-legacy name: iptables - register: ip4_legacy - name: Changing to ip6tables-legacy community.general.alternatives: path: /usr/sbin/ip6tables-legacy name: ip6tables - register: ip6_legacy diff --git a/roles/raspberrypi/tasks/prereq/Raspbian.yml b/roles/raspberrypi/tasks/prereq/Raspbian.yml index e965a32..1f7075d 100644 --- a/roles/raspberrypi/tasks/prereq/Raspbian.yml +++ b/roles/raspberrypi/tasks/prereq/Raspbian.yml @@ -2,11 +2,11 @@ - name: Check if /boot/firmware/cmdline.txt exists ansible.builtin.stat: path: /boot/firmware/cmdline.txt - register: boot_firmware_cmdline_txt + register: raspberrypi_boot_file - name: Enable cgroup via boot commandline if not already enabled ansible.builtin.replace: - path: "{{ (boot_firmware_cmdline_txt.stat.exists) | ternary('/boot/firmware/cmdline.txt', '/boot/cmdline.txt') }}" + path: "{{ (raspberrypi_boot_file.stat.exists) | ternary('/boot/firmware/cmdline.txt', '/boot/cmdline.txt') }}" regexp: '^([\w](?!.*\b{{ cgroup_item }}\b).*)$' replace: '\1 {{ cgroup_item }}' loop: @@ -41,10 +41,8 @@ community.general.alternatives: path: /usr/sbin/iptables-legacy name: iptables - register: ip4_legacy - name: Changing to ip6tables-legacy community.general.alternatives: path: /usr/sbin/ip6tables-legacy name: ip6tables - register: ip6_legacy diff --git a/roles/raspberrypi/tasks/prereq/Ubuntu.yml b/roles/raspberrypi/tasks/prereq/Ubuntu.yml index a02ed89..a985909 100644 --- a/roles/raspberrypi/tasks/prereq/Ubuntu.yml +++ b/roles/raspberrypi/tasks/prereq/Ubuntu.yml @@ -2,11 +2,11 @@ - name: Check if /boot/firmware/cmdline.txt exists ansible.builtin.stat: path: /boot/firmware/cmdline.txt - register: boot_firmware_cmdline_txt + register: raspberrypi_boot_file - name: Enable cgroup via boot commandline if not already enabled ansible.builtin.replace: - path: "{{ (boot_firmware_cmdline_txt.stat.exists) | ternary('/boot/firmware/cmdline.txt', '/boot/firmware/current/cmdline.txt') }}" + path: "{{ (raspberrypi_boot_file.stat.exists) | ternary('/boot/firmware/cmdline.txt', '/boot/firmware/current/cmdline.txt') }}" regexp: '^([\w](?!.*\b{{ cgroup_item }}\b).*)$' replace: '\1 {{ cgroup_item }}' loop: