TripleO Ansible project repository. Contains playbooks for use with TripleO OpenStack deployments.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
tripleo-ansible/tripleo_ansible/playbooks/cli-baremetal-introspect.yaml

123 lines
4.4 KiB

---
# 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: Baremetal Introspection for multiple Ironic Nodes
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
vars:
run_validations: false
concurrency: 20
max_retries: 1
node_timeout: 1200
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_intro fact
set_fact:
node_uuids_intro: "{{ node_uuids }}"
- name: exit if nothing to do
block:
- name: Notice
fail:
msg: No nodes are manageable at this time.
when:
- node_uuids_intro == []
# NOTE(cloudnull): This limits the concurrency so that we're not adding
# more threads than needed.
- name: Set concurrency fact
set_fact:
runtime_concurrency: "{{
((concurrency | int) > (node_uuids_intro | length)) |
ternary((node_uuids_intro | length), (concurrency | int))
}}"
# Pre-introspection validation
- name: Validations block
when:
- run_validations | bool
block:
- name: Check if validation enabled
set_fact:
validations_enabled: "{{ lookup('hiera', 'tripleo_validations_enabled') }}"
run_once: true
become: true
# Pre-introspection validation
# NOTE(cloudnull): The stackrc file is sourced because validations are not
# 100% compatible with clouds.yaml at this time.
- name: Run Validations
shell: |-
source "{{ ansible_home }}/stackrc"
openstack --os-cloud undercloud tripleo validator run --group "pre-introspection"
when:
- validations_enabled | bool
- name: Fail if validations are disabled
fail:
msg: >-
Run validations were enabled but via hiera information disabled.
Check the configuration and try again.
when:
- not (validations_enabled | bool)
# Introspect nodes
- name: Start baremetal introspection
os_tripleo_baremetal_node_introspection:
auth_type: password
cloud: undercloud
node_uuids: "{{ node_uuids_intro }}"
concurrency: "{{ runtime_concurrency }}"
max_retries: "{{ max_retries }}"
node_timeout: "{{ node_timeout }}"
register: baremetal_introspection_result
failed_when: false
- name: Nodes that passed introspection
debug:
msg: >-
{% if baremetal_introspection_result.passed_nodes != [] %}
{{ baremetal_introspection_result.passed_nodes | join(' ') }}{% else %}
No nodes completed introspection successfully!{% endif %}
when: baremetal_introspection_result.passed_nodes is defined
- name: Nodes that failed introspection
debug:
msg: >-
{% if baremetal_introspection_result.failed_nodes != [] %}
{{ baremetal_introspection_result.failed_nodes | join(' ') }}{% else %}
All nodes completed introspection successfully!{% endif %}
failed_when: baremetal_introspection_result.failed_nodes != []
when: baremetal_introspection_result.failed_nodes is defined
- name: Node introspection failed and no results are provided
fail:
msg: >-
Nodes failed introspection and no info was provided
when:
- baremetal_introspection_result.failed_nodes is not defined
- baremetal_introspection_result.passed_nodes is not defined