Make local kolla-ansible Python executable configurable
The default is still Python 2. This is a necessary prerequisite for using the master branch of kolla-ansible, which requires Python 3. Change-Id: Ida5b60b723c8208bb7305c3d669eafdab6dbbe01 Story: 2004959 Task: 38767
This commit is contained in:
parent
030ede06e8
commit
6b47717c43
@ -15,6 +15,14 @@ kolla_ansible_source_version:
|
|||||||
# Virtualenv directory where Kolla-ansible will be installed.
|
# Virtualenv directory where Kolla-ansible will be installed.
|
||||||
kolla_ansible_venv: "{{ ansible_env['PWD'] }}/kolla-venv"
|
kolla_ansible_venv: "{{ ansible_env['PWD'] }}/kolla-venv"
|
||||||
|
|
||||||
|
# Python interpreter to use to create Kolla Ansible virtualenv.
|
||||||
|
# FIXME(mgoddard): Use ansible_python when Kayobe supports Python 3.
|
||||||
|
kolla_ansible_venv_python: "python{{ kolla_ansible_venv_python_major_version }}"
|
||||||
|
|
||||||
|
# Major version of Python interpreter used in Kolla Ansible virtualenv.
|
||||||
|
# FIXME(mgoddard): Use ansible_python when Kayobe supports Python 3.
|
||||||
|
kolla_ansible_venv_python_major_version: 2
|
||||||
|
|
||||||
# Virtualenv directory where Kolla-ansible's ansible modules will execute
|
# Virtualenv directory where Kolla-ansible's ansible modules will execute
|
||||||
# remotely on the target nodes. If None, no virtualenv will be used.
|
# remotely on the target nodes. If None, no virtualenv will be used.
|
||||||
kolla_ansible_target_venv:
|
kolla_ansible_target_venv:
|
||||||
|
@ -13,7 +13,8 @@
|
|||||||
|
|
||||||
- name: Ensure required packages are installed
|
- name: Ensure required packages are installed
|
||||||
package:
|
package:
|
||||||
name: "{{ kolla_ansible_package_dependencies }}"
|
# NOTE(mgoddard): select non-empty packages.
|
||||||
|
name: "{{ kolla_ansible_package_dependencies | select | list }}"
|
||||||
state: present
|
state: present
|
||||||
become: True
|
become: True
|
||||||
|
|
||||||
@ -42,11 +43,29 @@
|
|||||||
become: True
|
become: True
|
||||||
when: kolla_ansible_venv is not none
|
when: kolla_ansible_venv is not none
|
||||||
|
|
||||||
|
# TODO(mgoddard): Remove this block when the previous release does not support
|
||||||
|
# Python 2.
|
||||||
|
- block:
|
||||||
|
- name: Check if virtualenv is python 2
|
||||||
|
stat:
|
||||||
|
path: "{{ kolla_ansible_venv }}/bin/python2"
|
||||||
|
register: stat_result
|
||||||
|
|
||||||
|
- name: Ensure python2 virtualenv is absent
|
||||||
|
file:
|
||||||
|
path: "{{ kolla_ansible_venv }}"
|
||||||
|
state: absent
|
||||||
|
when: stat_result.stat.exists
|
||||||
|
when:
|
||||||
|
- kolla_ansible_venv is not none
|
||||||
|
- kolla_ansible_venv_python_major_version | int == 3
|
||||||
|
|
||||||
- name: Ensure the latest version of pip is installed
|
- name: Ensure the latest version of pip is installed
|
||||||
pip:
|
pip:
|
||||||
name: "{{ item.name }}"
|
name: "{{ item.name }}"
|
||||||
state: latest
|
state: latest
|
||||||
virtualenv: "{{ kolla_ansible_venv }}"
|
virtualenv: "{{ kolla_ansible_venv }}"
|
||||||
|
virtualenv_python: "{{ kolla_ansible_venv_python }}"
|
||||||
with_items:
|
with_items:
|
||||||
- { name: pip }
|
- { name: pip }
|
||||||
|
|
||||||
@ -65,7 +84,9 @@
|
|||||||
# This is a workaround for the lack of a python package for libselinux-python
|
# This is a workaround for the lack of a python package for libselinux-python
|
||||||
# on PyPI. Without using --system-site-packages to create the virtualenv, it
|
# on PyPI. Without using --system-site-packages to create the virtualenv, it
|
||||||
# seems difficult to ensure the selinux python module is available. It is a
|
# seems difficult to ensure the selinux python module is available. It is a
|
||||||
# dependency for Ansible when selinux is enabled.
|
# dependency for Ansible when selinux is enabled. On CentOS 8, we can install
|
||||||
|
# the selinux package from PyPI, however when using Python 3 on CentOS 7 this
|
||||||
|
# does not work.
|
||||||
- name: Ensure selinux Python package is linked into the virtualenv
|
- name: Ensure selinux Python package is linked into the virtualenv
|
||||||
file:
|
file:
|
||||||
src: "/usr/lib64/python2.7/site-packages/selinux"
|
src: "/usr/lib64/python2.7/site-packages/selinux"
|
||||||
@ -75,3 +96,4 @@
|
|||||||
- ansible_os_family == 'RedHat'
|
- ansible_os_family == 'RedHat'
|
||||||
- ansible_selinux != False
|
- ansible_selinux != False
|
||||||
- ansible_selinux.status != 'disabled'
|
- ansible_selinux.status != 'disabled'
|
||||||
|
- kolla_ansible_venv_python_major_version | int == 2
|
||||||
|
@ -4,6 +4,15 @@
|
|||||||
# Components define groups of services, e.g. nova or ironic.
|
# Components define groups of services, e.g. nova or ironic.
|
||||||
# Services define single containers, e.g. nova-compute or ironic-api.
|
# Services define single containers, e.g. nova-compute or ironic-api.
|
||||||
|
|
||||||
|
{% if ansible_os_family == 'RedHat' and ansible_distribution_major_version | int == 7 and kolla_ansible_venv_python_major_version | int == 3 %}
|
||||||
|
# TODO(mgoddard): Remove when CentOS 7 is no longer supported.
|
||||||
|
# Force the use of python2 for localhost. This is necessary for delegate_to:
|
||||||
|
# localhost, which will otherwise use the playbook python interpreter
|
||||||
|
# (python3). On CentOS 7, that fails due to a lack of python3 bindings for
|
||||||
|
# SELinux. https://bugs.centos.org/view.php?id=16389
|
||||||
|
localhost ansible_python_interpreter=/usr/bin/python2
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% for group in kolla_overcloud_top_level_groups %}
|
{% for group in kolla_overcloud_top_level_groups %}
|
||||||
# Top level {{ group }} group.
|
# Top level {{ group }} group.
|
||||||
[{{ group }}]
|
[{{ group }}]
|
||||||
|
@ -5,6 +5,6 @@ kolla_ansible_package_dependencies:
|
|||||||
- libffi-dev
|
- libffi-dev
|
||||||
- libssl-dev
|
- libssl-dev
|
||||||
- patch
|
- patch
|
||||||
- python-dev
|
- "python{% if kolla_ansible_venv_python_major_version | int == 3 %}3{% endif %}-dev"
|
||||||
- python-pip
|
- "python{% if kolla_ansible_venv_python_major_version | int == 3 %}3{% endif %}-pip"
|
||||||
- python-virtualenv
|
- "python{% if kolla_ansible_venv_python_major_version | int == 3 %}3-venv{% else %}-virtualenv{% endif %}"
|
||||||
|
@ -5,6 +5,6 @@ kolla_ansible_package_dependencies:
|
|||||||
- libffi-devel
|
- libffi-devel
|
||||||
- openssl-devel
|
- openssl-devel
|
||||||
- patch
|
- patch
|
||||||
- python-devel
|
- "python{% if kolla_ansible_venv_python_major_version | int == 3 %}3{% endif %}-devel"
|
||||||
- python-pip
|
- "python{% if kolla_ansible_venv_python_major_version | int == 3 %}3{% endif %}-pip"
|
||||||
- python-virtualenv
|
- "{% if kolla_ansible_venv_python_major_version | int == 2 %}python-virtualenv{% endif %}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user