--- - name: Enable cgroup via boot commandline if not already enabled 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 notify: Regenerate bootloader image