From 8f6b8b1e9a26419aa7ba253c2c210cac032f50e7 Mon Sep 17 00:00:00 2001 From: Jason Rothstein Date: Mon, 8 Feb 2021 22:41:16 -0600 Subject: [PATCH] Use ansible_cmdline to detect cgroup status --- tasks/main.yml | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index b778e6f..a5a4afe 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -61,29 +61,25 @@ notify: - 'ensure_docker.package_facts' - 'ensure_docker.service_facts' -- name: 'Fetch kernel command line' +- name: 'Ensure cgroups are v1 only' when: - ansible_system == 'Linux' - ensure_docker is defined - ansible_distribution == 'Fedora' - ansible_distribution_major_version is version('32', '>=') - shell: | - cat /proc/cmdline - register: 'results' - changed_when: 'false' -- name: 'Add cgroups v1 if disabled' - when: - - results is defined - - results.stdout is defined - - ' "systemd.unified_cgroup_hierarchy=0" not in results.stdout ' + - ansible_cmdline is defined + - ansible_cmdline['systemd.unified_cgroup_hierarchy'] is not defined shell: cmd: | grubby --update-kernel=ALL --args=systemd.unified_cgroup_hierarchy=0 - name: 'Reboot to enable cgroups v1' when: - - results is defined - - results.stdout is defined - - ' "systemd.unified_cgroup_hierarchy=0" not in results.stdout ' + - ansible_system == 'Linux' + - ensure_docker is defined + - ansible_distribution == 'Fedora' + - ansible_distribution_major_version is version('32', '>=') + - ansible_cmdline is defined + - ansible_cmdline['systemd.unified_cgroup_hierarchy'] is not defined reboot: - name: 'flush handlers' meta: 'flush_handlers'