kayobe/ansible/kolla-ansible.yml

176 lines
8.5 KiB
YAML

---
- name: Ensure Kolla Ansible is configured
hosts: config-mgmt
vars:
# We need to reference configuration for the controller and seed nodes.
# We pick the first host from each group for this. It is possible that at
# this point these groups have no hosts in, and we should handle that case
# gracefully.
# NOTE: Per-host configuration is not currently supported.
controller_host: "{{ groups['controllers'][0] }}"
seed_host: "{{ groups['seed'][0] }}"
pre_tasks:
# Configuration of extra user-provided Kolla globals.
- block:
- name: Check whether a Kolla extra globals configuration file exists
stat:
path: "{{ kayobe_config_path ~ '/kolla/globals.yml' }}"
register: globals_stat
- name: Read the Kolla extra globals configuration file
set_fact:
kolla_extra_globals: "{{ lookup('template', kayobe_config_path ~ '/kolla/globals.yml') | from_yaml }}"
when: globals_stat.stat.exists
tags:
- config
# Configuration and validation of controller networking.
- block:
- name: Set facts containing the VIP addresses and FQDNs
set_fact:
kolla_internal_vip_address: "{{ internal_net_name | net_vip_address }}"
kolla_internal_fqdn: "{{ internal_net_name | net_fqdn or internal_net_name | net_vip_address }}"
kolla_external_vip_address: "{{ external_net_name | net_vip_address }}"
kolla_external_fqdn: "{{ external_net_name | net_fqdn or external_net_name | net_vip_address }}"
when: "{{ kolla_enable_haproxy | bool }}"
- name: Set facts containing the VIP addresses and FQDNs
set_fact:
kolla_internal_vip_address: "{{ internal_net_name | net_ip(controller_host) }}"
kolla_internal_fqdn: "{{ internal_net_name | net_ip(controller_host) }}"
kolla_external_vip_address: "{{ external_net_name | net_ip(controller_host) }}"
kolla_external_fqdn: "{{ external_net_name | net_ip(controller_host) }}"
when:
- "{{ not kolla_enable_haproxy | bool }}"
- name: Set facts containing the controller network interfaces
set_fact:
kolla_network_interface: "{{ internal_net_name | net_interface(controller_host) | replace('-', '_') }}"
kolla_external_vip_interface: "{{ external_net_name | net_interface(controller_host) | replace('-', '_') }}"
kolla_api_interface: "{{ internal_net_name | net_interface(controller_host) | replace('-', '_') }}"
kolla_storage_interface: "{{ storage_net_name | net_interface(controller_host) | replace('-', '_') }}"
kolla_cluster_interface: "{{ storage_mgmt_net_name | net_interface(controller_host) | replace('-', '_') }}"
kolla_provision_interface: "{{ provision_wl_net_name | net_interface(controller_host) | replace('-', '_') }}"
kolla_inspector_dnsmasq_interface: "{{ provision_wl_net_name | net_interface(controller_host) | replace('-', '_') }}"
# Initialise the following lists.
kolla_neutron_bridge_names: []
kolla_neutron_external_interfaces: []
kolla_neutron_bridge_interfaces: []
# When these networks are VLANs, we need to use the underlying tagged
# bridge interface rather than the untagged interface. We therefore
# strip the .<vlan> suffix of the interface name. We use a union here
# as a single tagged interface may be shared between these networks.
- name: Set a fact containing the bridges to be patched to the Neutron OVS bridges
set_fact:
kolla_neutron_bridge_interfaces: >
{{ kolla_neutron_bridge_interfaces |
union([item | net_interface(controller_host) | replace('.' ~ item | net_vlan(controller_host) | default('!nomatch!'), '')]) |
list }}
with_items:
- "{{ provision_wl_net_name }}"
- "{{ external_net_name }}"
when: "{{ item in hostvars[controller_host].network_interfaces }}"
- name: Set facts containing the Neutron bridge and interface names
set_fact:
kolla_neutron_bridge_names: >
{{ kolla_neutron_bridge_names +
[item ~ network_bridge_suffix_ovs] }}
kolla_neutron_external_interfaces: >
{{ kolla_neutron_bridge_names +
[network_patch_prefix ~ item ~ network_patch_suffix_ovs] }}
with_items: "{{ kolla_neutron_bridge_interfaces }}"
- name: Validate controller Kolla Ansible network configuration
fail:
msg: >
The Kolla Ansible variable {{ item.var_name }}
({{ item.description }}) is invalid. Value:
"{{ hostvars[inventory_hostname][item.var_name] | default('<undefined>') }}".
when:
- "{{ item.required | bool }}"
- "{{ hostvars[inventory_hostname][item.var_name] is not defined or not hostvars[inventory_hostname][item.var_name] }}"
with_items:
- var_name: "kolla_internal_vip_address"
description: "Internal API VIP address"
required: True
- var_name: "kolla_internal_fqdn"
description: "Internal API Fully Qualified Domain Name (FQDN)"
required: True
- var_name: "kolla_external_vip_address"
description: "external API VIP address"
required: True
- var_name: "kolla_external_fqdn"
description: "External API Fully Qualified Domain Name (FQDN)"
required: True
- var_name: "kolla_api_interface"
description: "API network interface name"
required: True
- var_name: "kolla_external_vip_interface"
description: "External network interface name"
required: True
- var_name: "kolla_provision_interface"
description: "Bare metal provisioning network interface name"
required: "{{ kolla_enable_ironic }}"
- var_name: "kolla_inspector_dnsmasq_interface"
description: "Bare metal introspection network interface name"
required: "{{ kolla_enable_ironic }}"
- var_name: "kolla_neutron_bridge_names"
description: "List of Neutron bridge names"
required: True
- var_name: "kolla_neutron_external_interfaces"
description: "List of Neutron interface names"
required: True
- name: Validate controller Kolla Ansible Neutron bridge and interface configuration
fail:
msg: >
The Kolla Ansible variable {{ item.0.var_name }}
({{ item.0.description }}) is invalid. Value:
"{{ item.1 | default('<undefined>') }}".
when:
- "{{ item.0.required | bool }}"
- "{{ item.1 is not defined or not item.1 }}"
with_subelements:
- - var_name: "kolla_neutron_bridge_names"
value: "{{ kolla_neutron_bridge_names }}"
description: "List of Neutron bridge names"
required: True
- var_name: "kolla_neutron_external_interfaces"
value: "{{ kolla_neutron_external_interfaces }}"
description: "List of Neutron interface names"
required: True
- value
when: "{{ controller_host is defined }}"
tags:
- config
- config-validation
# Configuration and validation of seed networking.
- block:
- name: Set facts containing the seed network interfaces
set_fact:
kolla_bifrost_network_interface: "{{ provision_oc_net_name | net_interface(seed_host) | replace('-', '_') }}"
- name: Validate seed Kolla Ansible network configuration
fail:
msg: >
The Kolla Ansible variable {{ item.var_name }}
({{ item.description }}) is invalid. Value:
"{{ hostvars[inventory_hostname][item.var_name] | default('<undefined>') }}".
when:
- "{{ item.required | bool }}"
- "{{ hostvars[inventory_hostname][item.var_name] is not defined or not hostvars[inventory_hostname][item.var_name] }}"
with_items:
- var_name: "kolla_bifrost_network_interface"
description: "Bifrost network interface name"
required: True
when: "{{ seed_host is defined }}"
tags:
- config
- config-validation
roles:
- role: kolla-ansible