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