From 5f294fb58487cb3ff5d7d588378129ed8e554cfd Mon Sep 17 00:00:00 2001 From: Richard Lau Date: Fri, 14 May 2021 12:27:11 -0400 Subject: [PATCH] ansible: fix multiple register vars on Fedora Tasks registering variables in Ansible will alway set the variable regardless of any `when` clause(s). This means if more than one task registers the same variable, the last one "wins". Fix the bootstrap role on Fedora by correctly registering `has_libselinux` in both `fedora30` and non-`fedora30` cases. --- ansible/roles/bootstrap/tasks/partials/fedora.yml | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/ansible/roles/bootstrap/tasks/partials/fedora.yml b/ansible/roles/bootstrap/tasks/partials/fedora.yml index fdc8173a9..5e08221dc 100644 --- a/ansible/roles/bootstrap/tasks/partials/fedora.yml +++ b/ansible/roles/bootstrap/tasks/partials/fedora.yml @@ -20,15 +20,8 @@ when: os not in ("fedora30") raw: alternatives --install /usr/bin/python python /usr/bin/python2.7 1 && alternatives --set python /usr/bin/python2.7 -- name: check for libselinux-python bindings - when: os in ("fedora30") - raw: dnf info libselinux-python | grep Installed - register: has_libselinux - failed_when: has_libselinux.rc > 1 - -- name: check for python3-libselinux bindings - when: os not in ("fedora30") - raw: dnf info python3-libselinux | grep Installed +- name: check for {{ 'libselinux-python' if os in ("fedora30") else 'python3-libselinux' }} bindings + raw: dnf info {{ 'libselinux-python' if os in ("fedora30") else 'python3-libselinux' }} | grep Installed register: has_libselinux failed_when: has_libselinux.rc > 1 @@ -36,7 +29,7 @@ when: os in ("fedora30") and has_libselinux.rc == 1 raw: dnf install -y libselinux-python -- name: install python3-libselinux nbindings +- name: install python3-libselinux bindings when: os not in ("fedora30") and has_libselinux.rc == 1 raw: dnf install -y libselinux-python