kayobe/ansible/roles/kolla/tasks/install.yml
Mark Goddard f639ad0b35 Use ansible_facts to reference facts
By default, Ansible injects a variable for every fact, prefixed with
ansible_. This can result in a large number of variables for each host,
which at scale can incur a performance penalty. Ansible provides a
configuration option [0] that can be set to False to prevent this
injection of facts. In this case, facts should be referenced via
ansible_facts.<fact>.

This change updates all references to Ansible facts within Kayobe
from using individual fact variables to using the items in the
ansible_facts dictionary. This allows users to disable fact variable
injection in their Ansible configuration, which may provide some
performance improvement.

This change disables fact variable injection in the ansible
configuration used in CI, to catch any attempts to use the injected
variables.

[0] https://docs.ansible.com/ansible/latest/reference_appendices/config.html#inject-facts-as-vars

Story: 2007993
Task: 42464
Depends-On: https://review.opendev.org/c/openstack/kolla-ansible/+/791276

Change-Id: I14db53ed6e57d37bbd28dd5819e432e3fe6628b2
2021-08-21 09:57:29 +02:00

80 lines
2.5 KiB
YAML

---
- name: Include OS family-specific variables
include_vars: "{{ ansible_facts.os_family }}.yml"
- name: Ensure EPEL repo is installed
package:
name: epel-release
state: present
become: True
when:
- ansible_facts.os_family == 'RedHat'
- kolla_install_epel | bool
- name: Ensure required packages are installed
package:
name: "{{ kolla_package_dependencies }}"
state: present
cache_valid_time: "{{ apt_cache_valid_time if ansible_facts.os_family == 'Debian' else omit }}"
update_cache: "{{ True if ansible_facts.os_family == 'Debian' else omit }}"
become: True
- name: Ensure source code checkout path exists
file:
path: "{{ kolla_source_path | dirname }}"
state: directory
owner: "{{ ansible_facts.user_uid }}"
group: "{{ ansible_facts.user_gid }}"
become: True
when: kolla_ctl_install_type == 'source'
- name: Ensure Kolla source code checkout exists
git:
repo: "{{ kolla_source_url }}"
dest: "{{ kolla_source_path }}"
version: "{{ kolla_source_version }}"
when: kolla_ctl_install_type == 'source'
- name: Ensure virtualenv parent directory exists
file:
path: "{{ kolla_venv | dirname }}"
state: directory
owner: "{{ ansible_facts.user_uid }}"
group: "{{ ansible_facts.user_gid }}"
become: True
when: kolla_venv is not none
- name: Ensure the latest version of pip is installed
pip:
name: "{{ item.name }}"
state: latest
virtualenv: "{{ kolla_venv }}"
virtualenv_python: "python3.{{ ansible_facts.python.version.minor }}"
with_items:
- { name: pip }
- name: Ensure Python package docker-py is absent
# In version 2.0.0, docker renamed the docker-py python package to docker.
# Kolla requires the docker package rather than the docker-py package.
pip:
name: docker-py
state: absent
virtualenv: "{{ kolla_venv }}"
- name: Ensure required Python packages are installed
pip:
name: "{{ item.name }}"
version: "{{ item.version | default(omit) }}"
state: "{{ item.state | default('present') }}"
virtualenv: "{{ kolla_venv }}"
extra_args: "{% if kolla_upper_constraints_file %}-c {{ kolla_upper_constraints_file }}{% endif %}"
with_items:
# Intall Kolla from source.
- name: "{{ kolla_source_path }}"
install: "{{ kolla_ctl_install_type == 'source' }}"
# Intall Kolla from PyPI.
- name: "kolla"
version: "{{ kolla_openstack_release }}"
install: "{{ kolla_ctl_install_type == 'binary' }}"
when: item.install | default(True) | bool