diff --git a/roles/tobiko-ensure-python3/defaults/main.yaml b/roles/tobiko-ensure-python3/defaults/main.yaml index 7790dc432..b6d3671d2 100644 --- a/roles/tobiko-ensure-python3/defaults/main.yaml +++ b/roles/tobiko-ensure-python3/defaults/main.yaml @@ -19,3 +19,13 @@ python_info: {} enable_yum_repos: [] compile_python3: no + +python_vars_prefixes: + - py3 + +python_vars_names: + - "{{ ansible_distribution }}-{{ ansible_distribution_version }}" + - "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}" + - "{{ ansible_os_family }}-{{ ansible_distribution_major_version }}" + - "{{ ansible_distribution }}" + - "{{ ansible_os_family }}" diff --git a/roles/tobiko-ensure-python3/tasks/install.yaml b/roles/tobiko-ensure-python3/tasks/install.yaml index 1a7d38919..93d79b6a1 100644 --- a/roles/tobiko-ensure-python3/tasks/install.yaml +++ b/roles/tobiko-ensure-python3/tasks/install.yaml @@ -3,7 +3,7 @@ - name: "enable yum repos" become: yes shell: - yum-config-manager --enable '{{ item }}' |grep baseurl + yum-config-manager --enable '{{ item }}' | grep baseurl loop: '{{ enable_yum_repos }}' diff --git a/roles/tobiko-ensure-python3/tasks/platform.yaml b/roles/tobiko-ensure-python3/tasks/platform.yaml index ace45db4f..2a9fb908f 100644 --- a/roles/tobiko-ensure-python3/tasks/platform.yaml +++ b/roles/tobiko-ensure-python3/tasks/platform.yaml @@ -1,23 +1,44 @@ --- -- name: "show ansible distro variables" - debug: - msg: - ansible_architecture: '{{ ansible_architecture }}' - ansible_distribution: '{{ ansible_distribution }}' - ansible_distribution_major_version: '{{ ansible_distribution_major_version }}' - ansible_os_family: '{{ ansible_os_family }}' +- when: osp_version is not defined + block: + - name: "get RHOSP version" + register: get_rhosp_version + shell: + awk '{print $6}' /etc/rhosp-release + + - name: show RHOSP version + debug: var=get_rhosp_version.stdout_lines + + - name: set rhosp_version and python_vars_prefixes facts + set_fact: + rhosp_version: '{{ get_rhosp_version.stdout_lines | first }}' + python_vars_prefixes: "{{ ['rhosp'] + python_vars_prefixes }}" + + rescue: + - debug: + msg='this is not an RHOSP host' + + +- name: + set_fact: + python_vars_files: > + {{ python_vars_prefixes | + product(python_vars_names) | + map('join', '-') | + product(['yaml']) | + map('join', '.') | + list }} + + +- name: "show platform vars files" + debug: var=python_vars_files - name: "include platform variables" include_vars: "{{ item }}" ignore_errors: yes - with_first_found: - - "py3-{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yaml" - - "py3-{{ ansible_os_family }}-{{ ansible_distribution_major_version }}.yaml" - - "py3-{{ ansible_distribution }}.{{ ansible_architecture }}.yaml" - - "py3-{{ ansible_distribution }}.yaml" - - "py3-{{ ansible_os_family }}.yaml" + with_first_found: '{{ python_vars_files }}' register: include_platform_vars diff --git a/roles/tobiko-ensure-python3/vars/py3-RedHat-7.yaml b/roles/tobiko-ensure-python3/vars/py3-RedHat-7.yaml index a34da9843..a130e5a22 100644 --- a/roles/tobiko-ensure-python3/vars/py3-RedHat-7.yaml +++ b/roles/tobiko-ensure-python3/vars/py3-RedHat-7.yaml @@ -1,7 +1,7 @@ --- enable_yum_repos: - - rhelosp-rhel-*-server-opt + - rhel-7-server-optional-rpms python_packages: python3: diff --git a/roles/tobiko-ensure-python3/vars/rhosp-RedHat-7.yaml b/roles/tobiko-ensure-python3/vars/rhosp-RedHat-7.yaml new file mode 100644 index 000000000..a34da9843 --- /dev/null +++ b/roles/tobiko-ensure-python3/vars/rhosp-RedHat-7.yaml @@ -0,0 +1,12 @@ +--- + +enable_yum_repos: + - rhelosp-rhel-*-server-opt + +python_packages: + python3: + - python3 + - python3-devel + python3.6: + - python36 + - python36-devel