---

- name: Activating cgroup on Raspbian
  lineinfile:
    path: /boot/cmdline.txt
    regexp: '^(.*rootwait)$'
    line: '\1 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory'
    backrefs: true
  when: ( ansible_facts.architecture is search "arm" )

- name: Rebooting on Raspbian 
  shell: reboot now
  ignore_errors: true
  when: ( ansible_facts.architecture is search "arm" )

---

- name: Test for Raspbian
  stat:
    path: /boot/cmdline.txt
  register: cmdline

- name: Activating cgroup on Raspbian
  lineinfile:
    path: /boot/cmdline.txt
    regexp: '^(.*rootwait)$'
    line: '\1 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory'
    backrefs: true
  when: ( cmdline.stat.path is defined )
          and
        ( ansible_facts.architecture is search("arm") )
  register: boot_cmdline

- name: Rebooting on Raspbian 
  shell: reboot now
  ignore_errors: true
  when: ( boot_cmdline | changed )
          and
        ( ansible_facts.architecture is search("arm") )

Test for Raspbian before assuming
Test for Raspbian before assuming
