tripleo-ansible/tripleo_ansible/playbooks/cli-overcloud-node-provide....

98 lines
3.0 KiB
YAML

---
# Copyright 2019 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
- name: Overcloud Node Provide
connection: "{{ (tripleo_target_host is defined) | ternary('ssh', 'local') }}"
hosts: "{{ tripleo_target_host | default('localhost') }}"
remote_user: "{{ tripleo_target_user | default(lookup('env', 'USER')) }}"
gather_facts: "{{ (tripleo_target_host is defined) | ternary(true, false) }}"
any_errors_fatal: true
pre_tasks:
- name: Check for required inputs
fail:
msg: >
Input missing `{{ item }}`
when:
- hostvars[inventory_hostname][item] is undefined
loop:
- node_uuids
tasks:
- name: Set node_uuids_provide fact
set_fact:
node_uuids_provide: "{{ node_uuids }}"
- name: exit if nothing to do
block:
- name: Notice
debug:
msg: No nodes are manageable at this time.
- name: end play
meta: end_play
when:
- node_uuids_provide == []
# Set nodes to available
- name: Make nodes available
os_baremetal_provide_node:
cloud: undercloud
node_uuid: "{{ node_uuids_provide }}"
timeout: 1200
wait_for_bridge_mappings: true
- name: Detect nova service endpoint
command: >-
openstack --os-cloud undercloud catalog show nova
register: nova_catalog_show
- name: Nova cell host discovery
when: "'service nova not found' not in nova_catalog_show.stderr"
block:
# Run cellv2 discovery of hosts
- name: Run cell_v2 host discovery
command: podman exec nova_api /bin/nova-manage cell_v2 discover_hosts --verbose
changed_when: false
become: true
- name: Wait for nova resources
command: >-
openstack --os-cloud undercloud hypervisor show {{ item }}
loop: "{{ node_uuids_provide }}"
changed_when: false
register: hypervisor_check
until: hypervisor_check is success
delay: 30
retries: 30
# Power off nodes the nodes
- name: Power off nodes
command: >-
openstack --os-cloud undercloud baremetal node power off {{ item }}
loop: "{{ node_uuids_provide }}"
async: 2400
poll: 0
register: node_power_off
- name: poll for completion
async_status:
jid: "{{ item.ansible_job_id }}"
loop: "{{ node_power_off.results }}"
loop_control:
label: "{{ item.item }}"
register: wait
until: wait.finished
retries: 120