2017-03-15 16:45:02 +00:00
|
|
|
---
|
2017-11-13 19:15:48 +00:00
|
|
|
- name: Check whether Ironic is enabled
|
|
|
|
hosts: controllers
|
2021-03-04 14:54:13 +00:00
|
|
|
gather_facts: False
|
2017-12-19 14:42:18 +00:00
|
|
|
tags:
|
|
|
|
- provision-net
|
2018-05-26 12:32:51 +01:00
|
|
|
- cleaning-net
|
2017-11-13 19:15:48 +00:00
|
|
|
tasks:
|
|
|
|
- name: Create controllers group with ironic enabled
|
|
|
|
group_by:
|
2018-03-05 17:05:54 +00:00
|
|
|
key: "controllers_for_provision_net_{{ kolla_enable_ironic | bool }}"
|
2021-03-04 14:54:13 +00:00
|
|
|
changed_when: false
|
2017-11-13 19:15:48 +00:00
|
|
|
|
2018-05-26 12:32:51 +01:00
|
|
|
- name: Ensure provisioning and cleaning networks and subnets are registered in neutron
|
2017-03-15 16:45:02 +00:00
|
|
|
# Only required to run on a single host.
|
2018-03-05 17:05:54 +00:00
|
|
|
hosts: controllers_for_provision_net_True[0]
|
2018-05-26 12:32:51 +01:00
|
|
|
vars:
|
2020-02-13 16:21:37 +00:00
|
|
|
venv: "{{ virtualenv_path }}/openstacksdk"
|
2018-05-26 12:32:51 +01:00
|
|
|
provision_net:
|
|
|
|
name: "{{ kolla_ironic_provisioning_network }}"
|
|
|
|
provider_network_type: "{% if provision_wl_net_name | net_vlan %}vlan{% else %}flat{% endif %}"
|
|
|
|
provider_physical_network: "{{ provision_wl_net_name | net_physical_network | default('physnet1', True) }}"
|
|
|
|
provider_segmentation_id: "{{ provision_wl_net_name | net_vlan }}"
|
2019-08-16 12:08:25 +01:00
|
|
|
# Flat networks need to be shared to allow instances to use them.
|
|
|
|
shared: "{{ (provision_wl_net_name | net_vlan) is none }}"
|
2018-05-26 12:32:51 +01:00
|
|
|
subnets:
|
|
|
|
- name: "{{ kolla_ironic_provisioning_network }}"
|
|
|
|
cidr: "{{ provision_wl_net_name | net_cidr }}"
|
|
|
|
gateway_ip: "{{ provision_wl_net_name | net_neutron_gateway or provision_wl_net_name | net_gateway }}"
|
|
|
|
allocation_pool_start: "{{ provision_wl_net_name | net_neutron_allocation_pool_start }}"
|
|
|
|
allocation_pool_end: "{{ provision_wl_net_name | net_neutron_allocation_pool_end }}"
|
|
|
|
cleaning_net:
|
|
|
|
name: "{{ kolla_ironic_cleaning_network }}"
|
|
|
|
provider_network_type: "{% if cleaning_net_name | net_vlan %}vlan{% else %}flat{% endif %}"
|
|
|
|
provider_physical_network: "{{ cleaning_net_name | net_physical_network | default('physnet1', True) }}"
|
|
|
|
provider_segmentation_id: "{{ cleaning_net_name | net_vlan }}"
|
2019-08-16 12:08:25 +01:00
|
|
|
# Flat networks need to be shared to allow instances to use them.
|
|
|
|
shared: "{{ (cleaning_net_name | net_vlan) is none }}"
|
2018-05-26 12:32:51 +01:00
|
|
|
subnets:
|
|
|
|
- name: "{{ kolla_ironic_cleaning_network }}"
|
|
|
|
cidr: "{{ cleaning_net_name | net_cidr }}"
|
|
|
|
gateway_ip: "{{ cleaning_net_name | net_neutron_gateway or cleaning_net_name | net_gateway }}"
|
|
|
|
allocation_pool_start: "{{ cleaning_net_name | net_neutron_allocation_pool_start }}"
|
|
|
|
allocation_pool_end: "{{ cleaning_net_name | net_neutron_allocation_pool_end }}"
|
2019-08-16 12:08:25 +01:00
|
|
|
network_registrations: "{{ [provision_net] + ([] if cleaning_net_name == provision_wl_net_name else [cleaning_net]) }}"
|
2017-12-19 14:42:18 +00:00
|
|
|
tags:
|
|
|
|
- provision-net
|
2018-05-26 12:32:51 +01:00
|
|
|
- cleaning-net
|
2017-04-05 11:05:45 +01:00
|
|
|
pre_tasks:
|
|
|
|
- name: Validate OpenStack password authentication parameters
|
|
|
|
fail:
|
|
|
|
msg: >
|
|
|
|
Required OpenStack authentication parameter {{ item }} is
|
|
|
|
{% if item in openstack_auth %}empty{% else %}not present{% endif %}
|
|
|
|
in openstack_auth. Have you sourced the environment file?
|
|
|
|
when:
|
2017-10-19 11:36:35 +01:00
|
|
|
- openstack_auth_type == 'password'
|
|
|
|
- item not in openstack_auth or not openstack_auth[item]
|
2017-04-05 11:05:45 +01:00
|
|
|
with_items: "{{ openstack_auth_password_required_params }}"
|
|
|
|
tags:
|
|
|
|
- config-validation
|
|
|
|
|
2017-03-15 16:45:02 +00:00
|
|
|
roles:
|
2017-06-28 17:22:47 +01:00
|
|
|
- role: stackhpc.os-networks
|
2020-04-17 20:02:10 +01:00
|
|
|
os_openstacksdk_install_epel: "{{ dnf_install_epel }}"
|
2020-02-13 16:21:37 +00:00
|
|
|
os_openstacksdk_state: latest
|
|
|
|
os_openstacksdk_upper_constraints_file: "{{ pip_upper_constraints_file }}"
|
2019-08-16 12:08:25 +01:00
|
|
|
os_networks_venv: "{{ venv }}"
|
2017-05-18 10:13:38 +01:00
|
|
|
os_networks_auth_type: "{{ openstack_auth_type }}"
|
|
|
|
os_networks_auth: "{{ openstack_auth }}"
|
2019-01-22 16:59:24 +00:00
|
|
|
os_networks_cacert: "{{ openstack_cacert | default(omit, true) }}"
|
2019-11-05 22:25:56 +00:00
|
|
|
os_networks_interface: "{{ openstack_interface | default(omit, true) }}"
|
2017-03-15 16:45:02 +00:00
|
|
|
# Network configuration.
|
2019-08-16 12:08:25 +01:00
|
|
|
os_networks: "{{ network_registrations }}"
|
|
|
|
tasks:
|
|
|
|
# NOTE(mgoddard): Originally, provisioning and cleaning networks were
|
|
|
|
# always shared. However now, VLAN networks are not shared. The os_network
|
|
|
|
# module does not appear to update networks after they have been created,
|
|
|
|
# so during this transition we manually update them here if necessary.
|
|
|
|
# TODO(mgoddard): Remove this code after a suitable transition period.
|
|
|
|
|
|
|
|
- name: Ensure python-openstackclient is installed
|
|
|
|
pip:
|
|
|
|
name: python-openstackclient
|
|
|
|
state: latest
|
|
|
|
extra_args: "{% if pip_upper_constraints_file %}-c {{ pip_upper_constraints_file }}{% endif %}"
|
|
|
|
virtualenv: "{{ venv }}"
|
|
|
|
when: network_registrations | rejectattr('shared') | list | length > 0
|
|
|
|
|
|
|
|
- block:
|
|
|
|
- name: Gather facts about provisioning network
|
2021-05-10 10:53:48 +01:00
|
|
|
os_networks_info:
|
2019-08-16 12:08:25 +01:00
|
|
|
auth: "{{ openstack_auth }}"
|
|
|
|
auth_type: "{{ openstack_auth_type }}"
|
|
|
|
cacert: "{{ openstack_cacert | default(omit, true) }}"
|
2019-11-05 22:25:56 +00:00
|
|
|
interface: "{{ openstack_interface | default(omit, true) }}"
|
2019-08-16 12:08:25 +01:00
|
|
|
name: "{{ provision_net.name }}"
|
|
|
|
register: provisioning_network_facts
|
|
|
|
|
|
|
|
- name: Set provisioning network to unshared
|
|
|
|
command: "{{ venv }}/bin/openstack network set {{ provision_net.name }} --no-share"
|
|
|
|
changed_when: true
|
2021-05-10 10:53:48 +01:00
|
|
|
when: provisioning_network_facts.openstack_networks[0].shared
|
2019-08-16 12:08:25 +01:00
|
|
|
environment: "{{ openstack_auth_env }}"
|
2020-02-17 09:22:25 +00:00
|
|
|
vars:
|
|
|
|
ansible_python_interpreter: "{{ venv }}/bin/python"
|
2019-08-16 12:08:25 +01:00
|
|
|
when: not provision_net.shared | bool
|
|
|
|
|
|
|
|
- block:
|
|
|
|
- name: Gather facts about cleaning network
|
2021-05-10 10:53:48 +01:00
|
|
|
os_networks_info:
|
2019-08-16 12:08:25 +01:00
|
|
|
auth: "{{ openstack_auth }}"
|
|
|
|
auth_type: "{{ openstack_auth_type }}"
|
|
|
|
cacert: "{{ openstack_cacert | default(omit, true) }}"
|
2019-11-05 22:25:56 +00:00
|
|
|
interface: "{{ openstack_interface | default(omit, true) }}"
|
2019-08-16 12:08:25 +01:00
|
|
|
name: "{{ cleaning_net.name }}"
|
|
|
|
register: cleaning_network_facts
|
|
|
|
|
|
|
|
- name: Set cleaning network to unshared
|
|
|
|
command: "{{ venv }}/bin/openstack network set {{ cleaning_net.name }} --no-share"
|
|
|
|
changed_when: true
|
2021-05-10 10:53:48 +01:00
|
|
|
when: cleaning_network_facts.openstack_networks[0].shared
|
2019-08-16 12:08:25 +01:00
|
|
|
environment: "{{ openstack_auth_env }}"
|
2020-02-17 09:22:25 +00:00
|
|
|
vars:
|
|
|
|
ansible_python_interpreter: "{{ venv }}/bin/python"
|
2019-08-16 12:08:25 +01:00
|
|
|
when:
|
|
|
|
- cleaning_net_name != provision_wl_net_name
|
|
|
|
- not cleaning_net.shared | bool
|