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
69 lines
2.8 KiB
YAML
69 lines
2.8 KiB
YAML
---
|
|
# This playbook will ensure that all baremetal compute nodes are named after
|
|
# their inventory host names. It matches the ipmi address in the inventory to
|
|
# the one gathered from inspection
|
|
|
|
- name: Rename baremetal compute nodes
|
|
hosts: controllers[0]
|
|
gather_facts: False
|
|
vars:
|
|
venv: "{{ virtualenv_path }}/openstack-cli"
|
|
pre_tasks:
|
|
- name: Set up openstack cli virtualenv
|
|
pip:
|
|
virtualenv: "{{ venv }}"
|
|
name:
|
|
- python-openstackclient
|
|
- python-ironicclient
|
|
state: latest
|
|
extra_args: "{% if pip_upper_constraints_file %}-c {{ pip_upper_constraints_file }}{% endif %}"
|
|
|
|
- name: Rename baremetal compute nodes
|
|
hosts: baremetal-compute
|
|
gather_facts: False
|
|
max_fail_percentage: >-
|
|
{{ baremetal_compute_rename_max_fail_percentage |
|
|
default(baremetal_compute_max_fail_percentage) |
|
|
default(kayobe_max_fail_percentage) |
|
|
default(100) }}
|
|
vars:
|
|
venv: "{{ virtualenv_path }}/openstack-cli"
|
|
controller_host: "{{ groups['controllers'][0] }}"
|
|
tasks:
|
|
- name: Fail if ipmi host variable not set
|
|
vars:
|
|
ipmi_address: "{{ hostvars[inventory_hostname].ipmi_address }}"
|
|
fail:
|
|
msg: >
|
|
The host variable, ipmi_address is not defined for {{ inventory_hostname }}. This variable is required
|
|
to run this playbook.
|
|
when: ipmi_address is not defined or not ipmi_address
|
|
- name: Get list of nodes
|
|
command: >
|
|
{{ venv }}/bin/openstack baremetal node list -f json --fields uuid name driver_info
|
|
register: nodes
|
|
delegate_to: "{{ controller_host }}"
|
|
environment: "{{ openstack_auth_env }}"
|
|
run_once: true
|
|
changed_when: false
|
|
vars:
|
|
# NOTE: Without this, the controller's ansible_host variable will not
|
|
# be respected when using delegate_to.
|
|
ansible_host: "{{ hostvars[controller_host].ansible_host | default(controller_host) }}"
|
|
|
|
- name: Rename baremetal compute nodes
|
|
command: >
|
|
{{ venv }}/bin/openstack baremetal node set --name "{{ inventory_hostname }}" "{{ node['UUID'] }}"
|
|
delegate_to: "{{ controller_host }}"
|
|
environment: "{{ openstack_auth_env }}"
|
|
vars:
|
|
# NOTE: Without this, the controller's ansible_host variable will not
|
|
# be respected when using delegate_to.
|
|
ansible_host: "{{ hostvars[controller_host].ansible_host | default(controller_host) }}"
|
|
ipmi_address: "{{ hostvars[inventory_hostname].ipmi_address }}"
|
|
matching_nodes: "{{ (nodes.stdout | from_json) | selectattr('Driver Info.ipmi_address', 'defined') | selectattr('Driver Info.ipmi_address', 'equalto', ipmi_address) | list }}"
|
|
node: "{{ matching_nodes | first }}"
|
|
when:
|
|
- matching_nodes | length > 0
|
|
- node['Name'] != inventory_hostname
|