From 7db9f5bd9bf017c959148e57d628a7cb005c11be Mon Sep 17 00:00:00 2001 From: Daniel San Pedro Date: Sat, 24 Feb 2024 21:25:55 -0500 Subject: [PATCH] Add check and variable so that we write to the correct file --- roles/raspberrypi/tasks/setup/Raspbian.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/roles/raspberrypi/tasks/setup/Raspbian.yml b/roles/raspberrypi/tasks/setup/Raspbian.yml index e4af193..8860d85 100644 --- a/roles/raspberrypi/tasks/setup/Raspbian.yml +++ b/roles/raspberrypi/tasks/setup/Raspbian.yml @@ -1,7 +1,17 @@ --- +- name: Test for cmdline path + command: grep -E "console=|rootfstype" /boot/cmdline.txt + register: boot_cmdline_path + failed_when: false + changed_when: false + +- name: Set path to cmdline based on test + set_fact: + cmdline_path: "{{ (boot_cmdline_path.rc == 0) | ternary('/boot/cmdline.txt', '/boot/firmware/cmdline.txt') }}" + - name: Activating cgroup support lineinfile: - path: /boot/firmware/cmdline.txt + path: "{{ cmdline_path }}" regexp: '^((?!.*\bcgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory\b).*)$' line: '\1 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory' backrefs: true