61 lines
2.1 KiB
YAML
61 lines
2.1 KiB
YAML
---
|
|
# This playbook will ensure that all compute nodes in the overcloud ironic
|
|
# inventory are available. Supported initial states include 'enroll' and
|
|
# 'manageable'.
|
|
|
|
- name: Ensure compute nodes are available in ironic
|
|
hosts: controllers[0]
|
|
vars:
|
|
venv: "{{ ansible_env.PWD }}/shade-venv"
|
|
roles:
|
|
- role: stackhpc.os-openstackclient
|
|
os_openstackclient_venv: "{{ venv }}"
|
|
tasks:
|
|
- name: Get a list of ironic nodes
|
|
shell: >
|
|
source {{ venv }}/bin/activate &&
|
|
openstack baremetal node list --fields name provision_state -f json
|
|
register: ironic_node_list
|
|
changed_when: False
|
|
environment: "{{ openstack_auth_env }}"
|
|
|
|
- name: Set a fact containing the ironic nodes
|
|
set_fact:
|
|
ironic_nodes: "{{ ironic_node_list.stdout | from_json }}"
|
|
|
|
- name: Ensure ironic nodes are managed
|
|
shell: >
|
|
source {{ venv }}/bin/activate &&
|
|
openstack baremetal node manage {{ item['Name'] }}
|
|
with_items: "{{ ironic_nodes }}"
|
|
when: "{{ item['Provisioning State'] == 'enroll' }}"
|
|
environment: "{{ openstack_auth_env }}"
|
|
|
|
- name: Ensure ironic nodes are available
|
|
shell: >
|
|
source {{ venv }}/bin/activate &&
|
|
openstack baremetal node provide {{ item['Name'] }}
|
|
with_items: "{{ ironic_nodes }}"
|
|
when: "{{ item['Provisioning State'] in ['enroll', 'manageable'] }}"
|
|
environment: "{{ openstack_auth_env }}"
|
|
|
|
- name: Get a list of ironic nodes
|
|
shell: >
|
|
source {{ venv }}/bin/activate &&
|
|
openstack baremetal node list -f json -c Name -c 'Provisioning State'
|
|
register: ironic_node_list
|
|
changed_when: False
|
|
environment: "{{ openstack_auth_env }}"
|
|
|
|
- name: Set a fact containing the ironic nodes
|
|
set_fact:
|
|
ironic_nodes: "{{ ironic_node_list.stdout | from_json }}"
|
|
|
|
- name: Fail if any ironic nodes are not available
|
|
fail:
|
|
msg: >
|
|
Failed to make compute node {{ item['Name'] }} available in ironic.
|
|
Provisioning state is {{ item['Provisioning State'] }}.
|
|
with_items: "{{ ironic_nodes }}"
|
|
when: "{{ item['Provisioning State'] != 'available' }}"
|