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.
 
 
 
 

216 lines
7.3 KiB

---
# Copyright 2020 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: Set resource and role chain fact
set_fact:
resource_chains: "{{ tripleo_heat_resource_tree.resources | get_filtered_resources('OS::Heat::ResourceChain') }}"
role_chain: "{{ tripleo_heat_resource_tree.resources | get_filtered_resource_chains(tripleo_role_name) }}"
- name: Set service chain fact
set_fact:
service_chain: "{{ resource_chains | get_filtered_service_chain(role_chain.resources) }}"
- name: Set role services fact
set_fact:
role_services: "{{ service_chain.resources | get_filtered_role_resources(tripleo_heat_resource_tree.resources) }}"
- name: Set role service key fact
set_fact:
role_service_key: "{{ tripleo_role_name }}Services"
- name: Set role_services_from_key fact
set_fact:
role_services_from_key: "{{ tripleo_heat_resource_tree['parameters'][role_service_key]['default'] }}"
- name: Set features facts
set_fact:
dpdk: |-
{{ (role_services_from_key|map('regex_search', '.*\:\:ComputeNeutronOvsDpdk')|list|select('string')|list|length)>0 }}
sriov: |-
{{ (role_services_from_key|map('regex_search', '.*\:\:NeutronSriovAgent')|list|select('string')|list|length)>0 }}
hci: |-
{% set novacompute = ((role_services_from_key | map('regex_search', '.*\:\:NovaCompute') | select('string') | list | length) > 0) | bool %}
{% set cephosd = ((role_services_from_key | map('regex_search', '.*\:\:CephOSD') | select('string') | list | length) > 0) | bool %}
{{ (novacompute | bool) and (cephosd | bool) }}
- name: Set feature fact
set_fact:
feature_dict:
DPDK: "{{ dpdk }}"
SRIOV: "{{ sriov }}"
HOST: "{{ dpdk or sriov }}"
HCI: "{{ hci }}"
- name: Set role feature fact
set_fact:
role_features: |-
{% set enabled_services = [] %}
{% for key, value in feature_dict.items() %}
{% if value | bool %}
{% set _ = enabled_services.append(key) %}
{% endif %}
{% endfor %}
{{ enabled_services }}
scheduler_hints: |-
{% set params = tripleo_heat_resource_tree.parameters.get((tripleo_role_name ~ 'SchedulerHints'), {}) %}
{{ params.get('default', {}) }}
flavor_name: |-
{% set param_name = 'Overcloud' ~ tripleo_role_name ~ 'Flavor' | replace('OvercloudControllerFlavor', 'OvercloudControlFlavor') %}
{% set params = tripleo_heat_resource_tree.parameters.get(param_name, {}) %}
{{ params.get('default', '') }}
- name: Node block
when:
- tripleo_all_nodes is undefined
block:
- name: Return available ironic hosts
os_baremetal_node_info:
cloud: undercloud
filters:
provision_state: "available"
is_maintenance: false
register: known_available_nodes
- name: Return available ironic hosts
os_baremetal_node_info:
cloud: undercloud
filters:
provision_state: "active"
is_maintenance: false
register: known_active_nodes
- name: Set all nodes fact
set_fact:
tripleo_all_nodes: "{{ known_available_nodes.baremetal_nodes | union(known_active_nodes.baremetal_nodes) }}"
- name: All node block
when:
- (tripleo_all_nodes | length) > 0
block:
- name: Scheduler hint block
when:
- (scheduler_hints | length) > 0
- role_node_uuid is undefined
block:
- name: Set hint regex fact
set_fact:
hint_regex: >-
{{ scheduler_hints.get('capabilities:node', {}) | replace('%index%', '(\d+)') }}
- name: Union all nodes
set_fact:
matching_nodes_with_hint: "{{
tripleo_all_nodes |
get_node_capabilities |
selectattr('hint', 'regex', hint_regex) |
map(attribute='uuid') |
list
}}"
- name: Set role node uuid fact
set_fact:
role_node_uuid: "{{ matching_nodes_with_hint | first }}"
when:
- (matching_nodes_with_hint | length) > 0
- name: Flavor hint block
when:
- (scheduler_hints | length) < 1
- role_node_uuid is undefined
block:
- name: Get flavor profile
tripleo_get_flavor_profile:
flavor_name: "{{ flavor_name }}"
register: flavor_profile
- name: Union all nodes
set_fact:
matching_nodes_with_profile: "{{
tripleo_all_nodes |
get_node_profile |
selectattr('profile', 'equalto', flavor_profile.profile) |
map(attribute='uuid') |
list
}}"
- name: Set role node uuid fact
set_fact:
role_node_uuid: "{{ matching_nodes_with_profile | first }}"
when:
- (matching_nodes_with_profile | length) > 0
- name: Get baremetal inspection data
tripleo_get_introspected_data:
node_id: "{{ role_node_uuid }}"
register: baremetal_data
when:
- role_node_uuid is defined
- name: Set hardware data fact
set_fact:
hw_data: "{{ baremetal_data.data }}"
when:
- baremetal_data is defined
- baremetal_data['data'] is defined
- name: Derive parameters for OvS Dpdk
when:
- dpdk
include_tasks: derive-ovs-dpdk-parameters.yml
- name: Derive parameters for SRIOV
when:
- sriov
include_tasks: derive-sriov-parameters.yml
- name: Host derive parameters
when:
- dpdk or sriov
include_tasks: derive-host-parameters.yml
- name: Derive parameters for HCI
when:
- hci
block:
- name: extract average guest cpu and memory
set_fact:
average_guest_cpu_utilization_percentage: "{{ item.value.average_guest_cpu_utilization_percentage }}"
average_guest_memory_size_in_mb: "{{ item.value.average_guest_memory_size_in_mb }}"
loop: "{{ lookup('dict', hci_profile_config) }}"
when: item.key == hci_profile
- name: Default derive parameters for HCI
set_fact:
derived_parameters: {}
when:
- derived_parameters is not defined
- name: Derive parameters for HCI (collocated ceph-osd/nova-compute nodes)
tripleo_derive_hci_parameters:
tripleo_environment_parameters: "{{ tripleo_environment_parameters }}"
tripleo_role_name: "{{ tripleo_role_name }}"
introspection_data: "{{ baremetal_data }}"
average_guest_cpu_utilization_percentage: "{{ average_guest_cpu_utilization_percentage }}"
average_guest_memory_size_in_mb: "{{ average_guest_memory_size_in_mb }}"
derived_parameters: "{{ derived_parameters }}"
register: derived_parameters_result
- name: Show HCI derived paramters results
debug:
msg: "{{ derived_parameters_result }}"
when:
- derived_parameters_result is defined
- derived_parameters_result|length >0