kayobe/ansible/kolla-target-venv.yml
Mark Goddard 6c54ce4d3b Introduce max fail percentage to playbooks
This allows us to continue execution until a certain proportion of hosts
fail. This can be useful at scale, where failures are common, and
restarting a deployment is time-consuming.

The default max failure percentage is 100, keeping the default
behaviour. A global max failure percentage may be set via
kayobe_max_fail_percentage, and individual playbooks may define a max
failure percentage via <playbook>_max_fail_percentage.

Related Kolla Ansible patch:
https://review.opendev.org/c/openstack/kolla-ansible/+/805598

Change-Id: Ib81c72b63be5765cca664c38141ffc769640cf07
2024-06-03 16:24:29 +00:00

81 lines
2.9 KiB
YAML

---
# Create a virtualenv for ansible modules to use on the remote target systems
# when running kolla-ansible.
- name: Ensure a virtualenv exists for kolla-ansible
hosts: seed:overcloud
gather_facts: False
max_fail_percentage: >-
{{ kolla_target_venv_max_fail_percentage |
default(host_configure_max_fail_percentage) |
default(kayobe_max_fail_percentage) |
default(100) }}
vars:
# kolla_overcloud_inventory_top_level_group_map looks like:
# kolla_overcloud_inventory_top_level_group_map:
# control:
# groups:
# - controllers
hosts_in_kolla_inventory: >-
{{ kolla_overcloud_inventory_top_level_group_map.values() |
map(attribute='groups') | flatten | unique | union(['seed']) | join(':') }}
tags:
- kolla-ansible
- kolla-target-venv
tasks:
- block:
- name: Gather facts
setup:
filter: "{{ kayobe_ansible_setup_filter }}"
gather_subset: "{{ kayobe_ansible_setup_gather_subset }}"
when: not ansible_facts
- name: Ensure the Python venv package is installed on Debian family systems
package:
name: python3-venv
state: present
cache_valid_time: "{{ apt_cache_valid_time }}"
update_cache: "True"
become: True
when: ansible_facts.os_family == 'Debian'
- name: Ensure kolla-ansible virtualenv has the latest version of pip installed
pip:
name: pip
state: latest
virtualenv: "{{ kolla_ansible_target_venv }}"
# Site packages are required for using the dnf python module, which
# is not available via PyPI.
virtualenv_site_packages: True
virtualenv_command: "python3.{{ ansible_facts.python.version.minor }} -m venv"
become: True
- name: Ensure kolla-ansible virtualenv has docker SDK for python installed
pip:
name: docker
state: latest
virtualenv: "{{ kolla_ansible_target_venv }}"
extra_args: "{% if kolla_upper_constraints_file %}-c {{ kolla_upper_constraints_file }}{% endif %}"
become: True
- name: Ensure kolla-ansible virtualenv has SELinux bindings installed
pip:
name: selinux
state: latest
virtualenv: "{{ kolla_ansible_target_venv }}"
become: True
when:
- ansible_facts.os_family == 'RedHat'
- name: Ensure kolla-ansible virtualenv has correct ownership
file:
path: "{{ kolla_ansible_target_venv }}"
recurse: True
state: directory
owner: "{{ kolla_ansible_user }}"
group: "{{ kolla_ansible_group }}"
become: True
when:
- kolla_ansible_target_venv is not none
- inventory_hostname in query('inventory_hostnames', hosts_in_kolla_inventory)