6c54ce4d3b
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
47 lines
1.3 KiB
YAML
47 lines
1.3 KiB
YAML
---
|
|
|
|
- name: Set facts about infra VMs
|
|
gather_facts: false
|
|
hosts: "{{ infra_vm_limit | default('infra-vms') }}"
|
|
tags:
|
|
- always
|
|
tasks:
|
|
- name: Group virtual machines by hypervisor
|
|
group_by:
|
|
key: infra_vms_{{ infra_vm_hypervisor }}
|
|
# FIXME(mgoddard): Is delegate_to necessary?
|
|
delegate_to: "{{ infra_vm_hypervisor }}"
|
|
changed_when: false
|
|
|
|
- name: Ensure defined infra VMs are destroyed
|
|
hosts: hypervisors
|
|
max_fail_percentage: >-
|
|
{{ infra_vm_deprovision_max_fail_percentage |
|
|
default(kayobe_max_fail_percentage) |
|
|
default(100) }}
|
|
tags:
|
|
- infra-vm-deprovision
|
|
tasks:
|
|
- import_role:
|
|
name: infra-vms
|
|
vars:
|
|
infra_vm_action: destroy
|
|
infra_vm_vms: "{{ groups['infra_vms_' ~ inventory_hostname ] | default([]) }}"
|
|
|
|
- name: Set facts about infra VMs
|
|
gather_facts: false
|
|
hosts: "{{ infra_vm_limit | default('infra-vms') }}"
|
|
max_fail_percentage: >-
|
|
{{ infra_vm_deprovision_max_fail_percentage |
|
|
default(kayobe_max_fail_percentage) |
|
|
default(100) }}
|
|
tags:
|
|
- infra-vm-deprovision
|
|
tasks:
|
|
- name: Remove host key from known hosts
|
|
known_hosts:
|
|
name: "{{ ansible_host }}"
|
|
state: "absent"
|
|
delegate_to: localhost
|
|
throttle: 1
|