Skip to content
main.yml 1018 B
Newer Older
David Putzolu's avatar
David Putzolu committed
---
- name: Check if cgroups enabled
David Putzolu's avatar
David Putzolu committed
  shell: cat /boot/firmware/cmdline.txt | grep cgroup
  register: cgroup_enabled
  when: ansible_distribution == 'Ubuntu'
  # grep will exit with 1 when no results found.
  # ignore_errors causes the task not to halt play.
  ignore_errors: true

- name: Enable cgroup via boot commandline if not already enabled
David Putzolu's avatar
David Putzolu committed
  lineinfile:
    path: /boot/firmware/cmdline.txt
    backrefs: yes
    regexp: "(.*)$"
    line: '\1 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory'
  when:
    - ansible_distribution == 'Ubuntu'
    - cgroup_enabled.stdout == ""
David Putzolu's avatar
David Putzolu committed

- name: Check if cgroups already running
  shell: cat /proc/cmdline | grep cgroup
  register: cgroup_running
  when:
    ansible_distribution == 'Ubuntu'
  # grep will exit with 1 when no results found.
  # ignore_errors causes the task not to halt play.
  ignore_errors: true

- name: Reboot to enable cgroups if not already running
David Putzolu's avatar
David Putzolu committed
  reboot:
  when:
    - ansible_distribution == 'Ubuntu'
    - cgroup_running.stdout == ""