mirror of
https://github.com/k3s-io/k3s-ansible.git
synced 2026-03-10 12:12:12 +01:00
41 lines
1.3 KiB
YAML
41 lines
1.3 KiB
YAML
---
|
|
- name: Check for boot configuration files
|
|
ansible.builtin.stat:
|
|
path: "{{ item }}"
|
|
loop:
|
|
- /boot/boot.txt
|
|
- /boot/cmdline.txt
|
|
register: boot_files
|
|
|
|
- name: Set boot_file fact
|
|
ansible.builtin.set_fact:
|
|
rpi_boot_file: "{{ (boot_files.results | selectattr('stat.exists') | map(attribute='item') | list | first) | default('') }}"
|
|
|
|
- name: Enable cgroup via boot commandline (boot.txt)
|
|
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
|
|
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
|
|
when: rpi_boot_file == '/boot/cmdline.txt'
|
|
notify: Reboot Pi
|