Clean up conditionals a bit

This commit is contained in:
David Putzolu 2020-05-22 11:11:00 -07:00
parent 61c0e513fc
commit 930f1b5586
1 changed files with 7 additions and 9 deletions

View File

@ -1,6 +1,6 @@
--- ---
- name: Check if cgroups enabled in /boot/firmware/cmdline.txt - name: Check if cgroups enabled
shell: cat /boot/firmware/cmdline.txt | grep cgroup shell: cat /boot/firmware/cmdline.txt | grep cgroup
register: cgroup_enabled register: cgroup_enabled
when: ansible_distribution == 'Ubuntu' when: ansible_distribution == 'Ubuntu'
@ -8,16 +8,15 @@
# ignore_errors causes the task not to halt play. # ignore_errors causes the task not to halt play.
ignore_errors: true ignore_errors: true
- name: Enable cgroup via boot commandline if not already present - name: Enable cgroup via boot commandline if not already enabled
lineinfile: lineinfile:
path: /boot/firmware/cmdline.txt path: /boot/firmware/cmdline.txt
backrefs: yes backrefs: yes
regexp: "(.*)$" regexp: "(.*)$"
line: '\1 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory' line: '\1 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory'
when: when:
( ansible_distribution == 'Ubuntu' ) - ansible_distribution == 'Ubuntu'
and - cgroup_enabled.stdout == ""
( cgroup_enabled.stdout == "" )
- name: Check if cgroups already running - name: Check if cgroups already running
shell: cat /proc/cmdline | grep cgroup shell: cat /proc/cmdline | grep cgroup
@ -28,10 +27,9 @@
# ignore_errors causes the task not to halt play. # ignore_errors causes the task not to halt play.
ignore_errors: true ignore_errors: true
- name: Rebooting to enable cgroups if not already running - name: Reboot to enable cgroups if not already running
reboot: reboot:
when: when:
( ansible_distribution == 'Ubuntu' ) - ansible_distribution == 'Ubuntu'
and - cgroup_running.stdout == ""
( cgroup_running.stdout == "" )