kayobe/ansible/kolla-openstack.yml

187 lines
8.6 KiB
YAML

---
- name: Ensure locally built Ironic Python Agent images are copied
hosts: controllers[0]
vars:
# These are the filenames generated by overcloud-ipa-build.yml.
ipa_image_name: "ipa"
ipa_images:
- "{{ ipa_image_name }}.vmlinuz"
- "{{ ipa_image_name }}.initramfs"
tasks:
- block:
- block:
- name: Check for the presence of locally built Ironic Python Agent (IPA) images
stat:
path: "{{ image_cache_path }}/{{ ipa_image_name }}/{{ item }}"
get_md5: False
get_checksum: False
mime: False
with_items: "{{ ipa_images }}"
register: ipa_image_stat
- name: Validate the presence of locally built Ironic Python Agent (IPA) images
fail:
msg: >
Expected locally built Ironic Python Agent (IPA) image
{{ item.item }} was not present in
{{ image_cache_path }}/{{ ipa_image_name }}.
with_items: "{{ ipa_image_stat.results }}"
when: not item.stat.exists
tags:
- config-validation
- name: Check whether the image cache directory exists
local_action:
module: stat
path: "{{ hostvars.localhost.image_cache_path }}"
get_md5: False
get_checksum: False
mime: False
register: image_cache_stat
- name: Ensure the image cache directory exists
local_action:
module: file
path: "{{ hostvars.localhost.image_cache_path }}"
state: directory
owner: "{{ lookup('env', 'USER') }}"
group: "{{ lookup('env', 'USER') }}"
become: True
when: not image_cache_stat.stat.exists
- name: Ensure Ironic Python Agent images are copied onto the local machine
fetch:
src: "{{ image_cache_path }}/{{ ipa_image_name }}/{{ item.src }}"
dest: "{{ hostvars.localhost.image_cache_path }}/{{ ipa_image_name }}/{{ item.dest }}"
flat: True
with_items:
- src: "{{ ipa_images[0] }}"
dest: "{{ ipa_images_kernel_name }}"
- src: "{{ ipa_images[1] }}"
dest: "{{ ipa_images_ramdisk_name }}"
when: ipa_build_images | bool
tags:
- config
- name: Ensure Kolla OpenStack components are configured
hosts: config-mgmt
vars:
switch_type_to_device_type:
dellos9: netmiko_dell_force10
junos: netmiko_juniper
ipa_image_name: "ipa"
pre_tasks:
- block:
- name: Check whether Kolla extra configuration files exist
stat:
path: "{{ kayobe_config_path }}/kolla/config/{{ item.file }}"
get_checksum: False
get_md5: False
mime: False
register: stat_result
with_items:
- { name: glance, file: glance.conf }
- { name: inspector, file: ironic-inspector.conf }
- { name: ironic, file: ironic.conf }
- { name: ironic_dnsmasq, file: ironic/ironic-dnsmasq.conf }
- { name: magnum, file: magnum.conf }
- { name: murano, file: murano.conf }
- { name: neutron, file: neutron.conf }
- { name: neutron_ml2, file: neutron/ml2_conf.ini }
- { name: nova, file: nova.conf }
- { name: sahara, file: sahara.conf }
- name: Initialise a fact containing extra configuration
set_fact:
kolla_extra_config: {}
- name: Update a fact containing extra configuration
set_fact:
kolla_extra_config: "{{ kolla_extra_config | combine({item.item.name: lookup('template', '{{ item.stat.path }}')}) }}"
with_items: "{{ stat_result.results }}"
when: item.stat.exists
- name: Validate switch configuration for Neutron ML2 genericswitch driver
fail:
msg: >
Switch configuration for {{ item }} is invalid. The following
variables must be set for the host: switch_type, ansible_host,
ansible_user, ansible_ssh_pass. Further, switch_type must be one of
{{ switch_type_to_device_type.keys() | join(', ') }}.
with_items: "{{ kolla_neutron_ml2_generic_switch_hosts }}"
when: >
item not in hostvars or
'switch_type' not in hostvars[item] or
hostvars[item].switch_type not in switch_type_to_device_type or
'ansible_host' not in hostvars[item] or
'ansible_user' not in hostvars[item] or
'ansible_ssh_pass' not in hostvars[item]
tags:
- config-validation
- name: Update a fact containing switches for use by Neutron ML2 genericswitch driver
set_fact:
kolla_neutron_ml2_generic_switches: >
{{
kolla_neutron_ml2_generic_switches +
[{
'name': item,
'device_type': switch_type_to_device_type[hostvars[item].switch_type],
'ip': hostvars[item].ansible_host,
'username': hostvars[item].ansible_user,
'password': hostvars[item].ansible_ssh_pass,
'ngs_trunk_ports': (
hostvars[item].switch_interface_config |
switch_interface_config_select_description(kolla_neutron_ml2_generic_switch_trunk_port_hosts) |
switch_interface_config_select_trunk()).keys() | join(',')
} | combine(hostvars[item].kolla_neutron_ml2_generic_switch_extra) ]
}}
with_items: "{{ kolla_neutron_ml2_generic_switch_hosts }}"
- name: Set facts containing IPA kernel and ramdisk URLs
set_fact:
kolla_inspector_ipa_kernel_upstream_url: "{{ inspector_ipa_kernel_upstream_url }}"
kolla_inspector_ipa_ramdisk_upstream_url: "{{ inspector_ipa_ramdisk_upstream_url }}"
when: not ipa_build_images | bool
- name: Set facts containing IPA kernel and ramdisk paths
set_fact:
kolla_inspector_ipa_kernel_path: "{{ image_cache_path }}/{{ ipa_image_name }}/{{ ipa_images_kernel_name }}"
kolla_inspector_ipa_ramdisk_path: "{{ image_cache_path }}/{{ ipa_image_name }}/{{ ipa_images_ramdisk_name }}"
when: ipa_build_images | bool
tags:
- config
roles:
- role: kolla-openstack
# Ironic inspector configuration.
kolla_inspector_manage_firewall: "{{ inspector_manage_firewall }}"
kolla_inspector_processing_hooks: "{{ inspector_processing_hooks }}"
kolla_inspector_add_ports: "{{ inspector_add_ports }}"
kolla_inspector_keep_ports: "{{ inspector_keep_ports }}"
kolla_inspector_enable_discovery: "{{ inspector_enable_discovery }}"
kolla_inspector_discovery_enroll_node_driver: "{{ inspector_discovery_enroll_node_driver }}"
kolla_inspector_extra_kernel_options: "{{ inspector_extra_kernel_options }}"
# Ironic inspector swift store configuration. Currently only supports the
# 'fake' inspection store.
kolla_inspector_enable_swift: "{{ inspector_store_enabled }}"
kolla_inspector_swift_auth:
auth_type: token_endpoint
url: "http://{% raw %}{{ api_interface_address }}{% endraw %}:{{ inspector_store_port }}"
token: fake-token
# Ironic inspector's dnsmasq configuration.
kolla_inspector_dhcp_pool_start: "{{ inspection_net_name | net_inspection_allocation_pool_start }}"
kolla_inspector_dhcp_pool_end: "{{ inspection_net_name | net_inspection_allocation_pool_end }}"
kolla_inspector_default_gateway: "{{ inspection_net_name | net_inspection_gateway or inspection_net_name | net_gateway }}"
# Extra free-form user-provided configuration.
kolla_extra_glance: "{{ kolla_extra_config.glance | default }}"
kolla_extra_inspector: "{{ kolla_extra_config.inspector | default }}"
kolla_extra_ironic: "{{ kolla_extra_config.ironic | default }}"
kolla_extra_ironic_dnsmasq: "{{ kolla_extra_config.ironic_dnsmasq | default }}"
kolla_extra_magnum: "{{ kolla_extra_config.magnum | default }}"
kolla_extra_murano: "{{ kolla_extra_config.murano | default }}"
kolla_extra_neutron: "{{ kolla_extra_config.neutron | default }}"
kolla_extra_neutron_ml2: "{{ kolla_extra_config.neutron_ml2 | default }}"
kolla_extra_nova: "{{ kolla_extra_config.nova | default }}"
kolla_extra_sahara: "{{ kolla_extra_config.sahara | default }}"
kolla_extra_config_path: "{{ kayobe_config_path }}/kolla/config"