114 lines
3.8 KiB
YAML
114 lines
3.8 KiB
YAML
---
|
|
- name: Include OS family-specific variables
|
|
include_vars: "{{ ansible_os_family }}.yml"
|
|
|
|
- name: Ensure EPEL repo is installed
|
|
package:
|
|
name: epel-release
|
|
state: present
|
|
become: True
|
|
when:
|
|
- ansible_os_family == 'RedHat'
|
|
- kolla_ansible_install_epel | bool
|
|
|
|
- name: Ensure required packages are installed
|
|
package:
|
|
# NOTE(mgoddard): select non-empty packages.
|
|
name: "{{ kolla_ansible_package_dependencies | select | list }}"
|
|
state: present
|
|
become: True
|
|
|
|
- name: Ensure source code checkout parent directory exists
|
|
file:
|
|
path: "{{ kolla_ansible_source_path | dirname }}"
|
|
state: directory
|
|
owner: "{{ ansible_user_uid }}"
|
|
group: "{{ ansible_user_gid }}"
|
|
become: True
|
|
when: kolla_ansible_ctl_install_type == 'source'
|
|
|
|
- name: Ensure Kolla Ansible source code checkout exists
|
|
git:
|
|
repo: "{{ kolla_ansible_source_url }}"
|
|
dest: "{{ kolla_ansible_source_path }}"
|
|
version: "{{ kolla_ansible_source_version }}"
|
|
when: kolla_ansible_ctl_install_type == 'source'
|
|
|
|
- name: Ensure virtualenv parent directory exists
|
|
file:
|
|
path: "{{ kolla_ansible_venv | dirname }}"
|
|
state: directory
|
|
owner: "{{ ansible_user_uid }}"
|
|
group: "{{ ansible_user_gid }}"
|
|
become: True
|
|
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
|
|
pip:
|
|
name: "{{ item.name }}"
|
|
state: latest
|
|
virtualenv: "{{ kolla_ansible_venv }}"
|
|
virtualenv_python: "{{ kolla_ansible_venv_python }}"
|
|
with_items:
|
|
- { name: pip }
|
|
|
|
- name: Ensure required Python packages are installed
|
|
vars:
|
|
kolla_ansible_packages:
|
|
# Install Kolla Ansible from source or PyPI.
|
|
- >-
|
|
{% if kolla_ansible_ctl_install_type == 'source' %}
|
|
{{ kolla_ansible_source_path }}
|
|
{% else %}
|
|
kolla-ansible=={{ kolla_openstack_release }}
|
|
{% endif %}
|
|
# Limit the version of ansible used by kolla-ansible to avoid new
|
|
# releases from breaking tested code. Changes to this limit should be
|
|
# tested.
|
|
- ansible>=2.8,<2.10,!=2.8.9,!=2.9.8
|
|
- >-
|
|
{%- if ansible_os_family == 'RedHat' and ansible_distribution_major_version | int >= 8 %}
|
|
selinux
|
|
{% endif -%}
|
|
pip:
|
|
name: "{{ (kolla_ansible_packages + kolla_ansible_venv_extra_requirements) | select | list }}"
|
|
state: latest
|
|
extra_args: "{% if kolla_upper_constraints_file %}-c {{ kolla_upper_constraints_file }}{% endif %}"
|
|
virtualenv: "{{ kolla_ansible_venv }}"
|
|
virtualenv_python: "{{ kolla_ansible_venv_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
|
|
# seems difficult to ensure the selinux python module is available. It is a
|
|
# 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
|
|
file:
|
|
src: "/usr/lib64/python2.7/site-packages/selinux"
|
|
dest: "{{ kolla_ansible_venv }}/lib/python2.7/site-packages/selinux"
|
|
state: link
|
|
when:
|
|
- ansible_os_family == 'RedHat'
|
|
- ansible_distribution_major_version | int == 7
|
|
- ansible_selinux != False
|
|
- ansible_selinux.status != 'disabled'
|
|
- kolla_ansible_venv_python_major_version | int == 2
|