5c825bd395
Uses the familiar ansible --limit syntax of a colon-separated host list.
81 lines
2.8 KiB
YAML
81 lines
2.8 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"
|
|
# Set this to a colon-separated list of compute node hostnames to provide.
|
|
# If unset, all compute nodes will be provided.
|
|
compute_node_limit:
|
|
compute_node_limit_list: "{{ compute_node_limit.split(':') }}"
|
|
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: Initialise a fact containing the ironic nodes
|
|
set_fact:
|
|
ironic_nodes: []
|
|
|
|
- name: Update a fact containing the ironic nodes
|
|
set_fact:
|
|
ironic_nodes: "{{ ironic_nodes + [item] }}"
|
|
with_items: "{{ ironic_node_list.stdout | from_json }}"
|
|
when: >
|
|
{{ not compute_node_limit or
|
|
item['Name'] in compute_node_limit_list }}
|
|
|
|
- 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: Initialise a fact containing the ironic nodes
|
|
set_fact:
|
|
ironic_nodes: []
|
|
|
|
- name: Limit ironic nodes to the specified list
|
|
set_fact:
|
|
ironic_nodes: "{{ ironic_nodes + [item] }}"
|
|
with_items: "{{ ironic_node_list.stdout | from_json }}"
|
|
when: >
|
|
{{ not compute_node_limit or
|
|
item['Name'] in compute_node_limit_list }}
|
|
|
|
- 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' }}"
|