diff --git a/roles/raspberrypi/tasks/prereq/Archlinux.yml b/roles/raspberrypi/tasks/prereq/Archlinux.yml index c70756869..fe6dc6d98 100644 --- a/roles/raspberrypi/tasks/prereq/Archlinux.yml +++ b/roles/raspberrypi/tasks/prereq/Archlinux.yml @@ -1,8 +1,13 @@ --- - name: Enable cgroup via boot commandline if not already enabled - ansible.builtin.lineinfile: + ansible.builtin.replace: path: /boot/boot.txt - regexp: '^(setenv bootargs console=ttyS1,115200 console=tty0 root=PARTUUID=\${uuid} rw rootwait smsc95xx.macaddr="\${usbethaddr}")' - line: '\1 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory' - backrefs: true + 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 notify: Regenerate bootloader image diff --git a/roles/raspberrypi/tasks/prereq/CentOS.yml b/roles/raspberrypi/tasks/prereq/CentOS.yml index 30043d2db..039032e0d 100644 --- a/roles/raspberrypi/tasks/prereq/CentOS.yml +++ b/roles/raspberrypi/tasks/prereq/CentOS.yml @@ -2,7 +2,12 @@ - name: Enable cgroup via boot commandline if not already enabled ansible.builtin.lineinfile: path: /boot/cmdline.txt - backrefs: true - regexp: '^((?!.*\bcgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory\b).*)$' - line: '\1 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory' + regexp: '^([\w](?!.*\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 notify: Reboot Pi diff --git a/roles/raspberrypi/tasks/prereq/Debian.yml b/roles/raspberrypi/tasks/prereq/Debian.yml index aa003e3eb..8dc260da5 100644 --- a/roles/raspberrypi/tasks/prereq/Debian.yml +++ b/roles/raspberrypi/tasks/prereq/Debian.yml @@ -5,11 +5,16 @@ register: boot_firmware_cmdline_txt - name: Enable cgroup via boot commandline if not already enabled - ansible.builtin.lineinfile: + ansible.builtin.replace: path: "{{ (boot_firmware_cmdline_txt.stat.exists) | ternary('/boot/firmware/cmdline.txt', '/boot/cmdline.txt') }}" - backrefs: true - regexp: '^((?!.*\bcgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory\b).*)$' - line: '\1 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory' + regexp: '^([\w](?!.*\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 notify: Reboot Pi - name: Gather the package facts diff --git a/roles/raspberrypi/tasks/prereq/Raspbian.yml b/roles/raspberrypi/tasks/prereq/Raspbian.yml index 1ce8d5bf7..6e63d0667 100644 --- a/roles/raspberrypi/tasks/prereq/Raspbian.yml +++ b/roles/raspberrypi/tasks/prereq/Raspbian.yml @@ -2,9 +2,14 @@ - name: Enable cgroup via boot commandline if not already enabled ansible.builtin.lineinfile: path: /boot/cmdline.txt - backrefs: true - regexp: '^((?!.*\bcgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory\b).*)$' - line: '\1 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory' + regexp: '^([\w](?!.*\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 notify: Reboot Pi - name: Gather the package facts diff --git a/roles/raspberrypi/tasks/prereq/Ubuntu.yml b/roles/raspberrypi/tasks/prereq/Ubuntu.yml index 71cc24b58..e9191fdf7 100644 --- a/roles/raspberrypi/tasks/prereq/Ubuntu.yml +++ b/roles/raspberrypi/tasks/prereq/Ubuntu.yml @@ -3,9 +3,14 @@ when: lookup('fileglob', '/boot/firmware/cmdline.txt', errors='warn') | length > 0 ansible.builtin.lineinfile: path: /boot/firmware/cmdline.txt - backrefs: true - regexp: '^((?!.*\bcgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory\b).*)$' - line: '\1 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory' + regexp: '^([\w](?!.*\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 notify: Reboot Pi - name: Install Ubuntu Raspi Extra Packages