More flexible cgroup settings (#352)

* More flexible cgroup settings

If there are already required cgroup boot parameters present but in a
different order than specified, the script will add them again. It is
better to test for the individual parameter in a loop and selectively
add them as necessary.

Signed-off-by: Marko Vukovic <anonsoftware@gmail.com>

Signed-off-by: Marko Vukovic <anonsoftware@gmail.com>
Signed-off-by: Marko Vukovic <8951449+anon-software@users.noreply.github.com>
This commit is contained in:
anon-software
2024-08-15 10:32:22 -07:00
committed by GitHub
parent b6e4c8b31e
commit 04c8ae9a57
5 changed files with 45 additions and 20 deletions

View File

@@ -1,8 +1,13 @@
--- ---
- name: Enable cgroup via boot commandline if not already enabled - name: Enable cgroup via boot commandline if not already enabled
ansible.builtin.lineinfile: ansible.builtin.replace:
path: /boot/boot.txt path: /boot/boot.txt
regexp: '^(setenv bootargs console=ttyS1,115200 console=tty0 root=PARTUUID=\${uuid} rw rootwait smsc95xx.macaddr="\${usbethaddr}")' regexp: '^(setenv bootargs console=ttyS1,115200 console=tty0 root=PARTUUID=\${uuid} rw rootwait smsc95xx.macaddr="\${usbethaddr}"(?!.*\b{{ cgroup_item }}\b).*)$'
line: '\1 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory' replace: '\1 {{ cgroup_item }}'
backrefs: true with_items:
- "cgroup_enable=cpuset"
- "cgroup_memory=1"
- "cgroup_enable=memory"
loop_control:
loop_var: cgroup_item
notify: Regenerate bootloader image notify: Regenerate bootloader image

View File

@@ -1,8 +1,13 @@
--- ---
- name: Enable cgroup via boot commandline if not already enabled - name: Enable cgroup via boot commandline if not already enabled
ansible.builtin.lineinfile: ansible.builtin.replace:
path: /boot/cmdline.txt path: /boot/cmdline.txt
backrefs: true regexp: '^([\w](?!.*\b{{ cgroup_item }}\b).*)$'
regexp: '^((?!.*\bcgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory\b).*)$' replace: '\1 {{ cgroup_item }}'
line: '\1 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory' with_items:
- "cgroup_enable=cpuset"
- "cgroup_memory=1"
- "cgroup_enable=memory"
loop_control:
loop_var: cgroup_item
notify: Reboot Pi notify: Reboot Pi

View File

@@ -5,11 +5,16 @@
register: boot_firmware_cmdline_txt register: boot_firmware_cmdline_txt
- name: Enable cgroup via boot commandline if not already enabled - 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') }}" path: "{{ (boot_firmware_cmdline_txt.stat.exists) | ternary('/boot/firmware/cmdline.txt', '/boot/cmdline.txt') }}"
backrefs: true regexp: '^([\w](?!.*\b{{ cgroup_item }}\b).*)$'
regexp: '^((?!.*\bcgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory\b).*)$' replace: '\1 {{ cgroup_item }}'
line: '\1 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory' with_items:
- "cgroup_enable=cpuset"
- "cgroup_memory=1"
- "cgroup_enable=memory"
loop_control:
loop_var: cgroup_item
notify: Reboot Pi notify: Reboot Pi
- name: Gather the package facts - name: Gather the package facts

View File

@@ -1,10 +1,15 @@
--- ---
- name: Enable cgroup via boot commandline if not already enabled - name: Enable cgroup via boot commandline if not already enabled
ansible.builtin.lineinfile: ansible.builtin.replace:
path: /boot/cmdline.txt path: /boot/cmdline.txt
backrefs: true regexp: '^([\w](?!.*\b{{ cgroup_item }}\b).*)$'
regexp: '^((?!.*\bcgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory\b).*)$' replace: '\1 {{ cgroup_item }}'
line: '\1 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory' with_items:
- "cgroup_enable=cpuset"
- "cgroup_memory=1"
- "cgroup_enable=memory"
loop_control:
loop_var: cgroup_item
notify: Reboot Pi notify: Reboot Pi
- name: Gather the package facts - name: Gather the package facts

View File

@@ -1,11 +1,16 @@
--- ---
- name: Enable cgroup via boot commandline if not already enabled - name: Enable cgroup via boot commandline if not already enabled
when: lookup('fileglob', '/boot/firmware/cmdline.txt', errors='warn') | length > 0 when: lookup('fileglob', '/boot/firmware/cmdline.txt', errors='warn') | length > 0
ansible.builtin.lineinfile: ansible.builtin.replace:
path: /boot/firmware/cmdline.txt path: /boot/firmware/cmdline.txt
backrefs: true regexp: '^([\w](?!.*\b{{ cgroup_item }}\b).*)$'
regexp: '^((?!.*\bcgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory\b).*)$' replace: '\1 {{ cgroup_item }}'
line: '\1 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory' with_items:
- "cgroup_enable=cpuset"
- "cgroup_memory=1"
- "cgroup_enable=memory"
loop_control:
loop_var: cgroup_item
notify: Reboot Pi notify: Reboot Pi
- name: Install Ubuntu Raspi Extra Packages - name: Install Ubuntu Raspi Extra Packages