Skip to content

Commit

Permalink
Fix cgroups cmdline path (#456)
Browse files Browse the repository at this point in the history
* Fix cgroups cmdline path

* Add check and variable so that we write to the correct file

* Add LSB release checks. This is untested atm.

* Break test into multiple lines so that we can pass lint checks

* Flip logic on its head and check for existence only rather than content per contributor suggestion

---------

Co-authored-by: Techno Tim <[email protected]>
  • Loading branch information
yebo29 and timothystewart6 committed Mar 2, 2024
1 parent 3b74985 commit 955c6f6
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion roles/raspberrypi/tasks/setup/Raspbian.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
---
- name: Test for cmdline path
stat:
path: /boot/firmware/cmdline.txt
register: boot_cmdline_path
failed_when: false
changed_when: false

- name: Set cmdline path based on Debian version and command result
set_fact:
cmdline_path: >-
{{
(
boot_cmdline_path.stat.exists and
ansible_facts.lsb.description | default('') is match('Debian.*(?!(bookworm|sid))')
) | ternary(
'/boot/firmware/cmdline.txt',
'/boot/cmdline.txt'
)
}}
- name: Activating cgroup support
lineinfile:
path: /boot/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
Expand Down

0 comments on commit 955c6f6

Please sign in to comment.