From bf383c0ab227ac83c01fc831995e6f9218ced2c5 Mon Sep 17 00:00:00 2001 From: Bruno Goncalves Date: Feb 16 2018 13:39:06 +0000 Subject: fix python interpreter on RHEL-8 --- diff --git a/roles/str-common/tasks/inspect.yml b/roles/str-common/tasks/inspect.yml index faf81bb..2fbf1c2 100644 --- a/roles/str-common/tasks/inspect.yml +++ b/roles/str-common/tasks/inspect.yml @@ -19,4 +19,17 @@ {{ ansible_pkg_mgr == 'yum' }} is_dnf_os: > {{ ansible_pkg_mgr == 'dnf' }} + is_rhel8_based: > + {{ + ( ['ansible_distribution'] | + intersect(['RedHat', 'CentOS']) | bool ) and + ansible_distribution_version|int == 8 + }} +# Fix python ansible interpreter when running on RHEL8. Currently RHEL8 +# uses python2, but it does miss some python2 modules, such as python2-dnf. +# This can be removed once RHEL8 uses by default Python3 +- name: Hardcode Python interpreter for ansible modules on RHEL8 based OS + set_fact: + ansible_python_interpreter: /usr/bin/env python3 + when: is_rhel8_based diff --git a/roles/str-common/tasks/trunner.yml b/roles/str-common/tasks/trunner.yml index 396da13..2ed6c22 100644 --- a/roles/str-common/tasks/trunner.yml +++ b/roles/str-common/tasks/trunner.yml @@ -16,6 +16,23 @@ {{ hostvars[test_runner_inventory_name]['ansible_pkg_mgr'] == 'yum' }} is_dnf_os: > {{ hostvars[test_runner_inventory_name]['ansible_pkg_mgr'] == 'dnf' }} + is_rhel8_based: > + {{ + ( [hostvars[test_runner_inventory_name]['ansible_distribution']] | + intersect(['RedHat', 'CentOS']) | bool ) + and + ( hostvars[test_runner_inventory_name]['ansible_distribution_version'] | + int == 8 ) + }} + + # Fix python ansible interpreter when running on RHEL8. Currently RHEL8 + # uses python2, but it does miss some python2 modules, such as python2-dnf. + # This can be removed once RHEL8 uses by default Python 3. + - name: Hardcode Python interpreter for ansible modules on RHEL8 based OS + delegate_facts: True + set_fact: + ansible_python_interpreter: /usr/bin/env python3 + when: "hostvars[test_runner_inventory_name]['is_rhel8_based'] | bool" - name: Fetch tests from remote repositories git: @@ -43,3 +60,9 @@ {{ test_runner_inventory_name }} uses dnf: {{ hostvars[test_runner_inventory_name]['is_dnf_os'] }} verbosity: 1 + +- debug: + msg: > + {{ test_runner_inventory_name }} is RHEL8 based OS: + {{ hostvars[test_runner_inventory_name]['is_rhel8_based'] }} + verbosity: 1