blob: 44beec912e724b266e8a3022359bf6fd1bea28a7 [file] [log] [blame]
Mohammed Naserb7b97d62022-03-12 16:30:00 -05001# Copyright (c) 2022 VEXXHOST, Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
guilhermesteinmuller6f6bf702023-01-24 19:00:19 +000015- name: Uninstall the legacy HelmRelease
16 run_once: true
17 block:
18 - name: Suspend the existing HelmRelease
Mohammed Naserf0314a82023-04-11 18:53:30 +000019 failed_when: false
guilhermesteinmuller6f6bf702023-01-24 19:00:19 +000020 kubernetes.core.k8s:
21 state: patched
22 api_version: helm.toolkit.fluxcd.io/v2beta1
23 kind: HelmRelease
Mohammed Naser2145fc32023-01-29 23:23:03 +000024 name: "{{ neutron_helm_release_name }}"
25 namespace: "{{ neutron_helm_release_namespace }}"
guilhermesteinmuller6f6bf702023-01-24 19:00:19 +000026 definition:
27 spec:
28 suspend: true
29
30 - name: Remove the existing HelmRelease
Mohammed Naserf0314a82023-04-11 18:53:30 +000031 failed_when: false
guilhermesteinmuller6f6bf702023-01-24 19:00:19 +000032 kubernetes.core.k8s:
33 state: absent
34 api_version: helm.toolkit.fluxcd.io/v2beta1
35 kind: HelmRelease
Mohammed Naser2145fc32023-01-29 23:23:03 +000036 name: "{{ neutron_helm_release_name }}"
37 namespace: "{{ neutron_helm_release_namespace }}"
Mohammed Naserb7b97d62022-03-12 16:30:00 -050038
Mohammed Naser434f02e2024-06-18 18:54:35 -040039- name: Set external_dns_driver
40 ansible.builtin.set_fact:
41 _neutron_external_dns_driver: "designate"
42 when: neutron_designate_integration_enabled | bool
43
Mohammed Naser54ee9922023-07-22 18:40:25 +000044- name: Generate Helm values
45 ansible.builtin.set_fact:
46 _neutron_helm_values: "{{ __neutron_helm_values }}"
47
Mohammed Naser1d75a922023-07-23 19:24:49 +000048- name: Append Helm values
49 when: atmosphere_network_backend == 'ovn'
50 ansible.builtin.set_fact:
51 _neutron_helm_values: "{{ _neutron_helm_values | combine(__neutron_ovn_helm_values, recursive=True) }}"
Mohammed Naser54ee9922023-07-22 18:40:25 +000052
Mohammed Nasere40c3e82024-07-04 02:52:34 -040053- name: Append Helm values (neutron_policy_server)
54 when: neutron_policy_server_integration_enabled | bool
55 ansible.builtin.set_fact:
56 _neutron_helm_values: "{{ _neutron_helm_values | combine(__neutron_policy_server_helm_values, recursive=True) }}"
57
Mohammed Naserb7b97d62022-03-12 16:30:00 -050058- name: Deploy Helm chart
guilhermesteinmuller6f6bf702023-01-24 19:00:19 +000059 run_once: true
60 kubernetes.core.helm:
Mohammed Naser2145fc32023-01-29 23:23:03 +000061 name: "{{ neutron_helm_release_name }}"
62 chart_ref: "{{ neutron_helm_chart_ref }}"
63 release_namespace: "{{ neutron_helm_release_namespace }}"
guilhermesteinmuller6f6bf702023-01-24 19:00:19 +000064 create_namespace: true
65 kubeconfig: /etc/kubernetes/admin.conf
Mohammed Naser2145fc32023-01-29 23:23:03 +000066 values: "{{ _neutron_helm_values | combine(neutron_helm_values, recursive=True) }}"
Mohammed Naserb7b97d62022-03-12 16:30:00 -050067
68- name: Create Ingress
69 ansible.builtin.include_role:
70 name: openstack_helm_ingress
71 vars:
72 openstack_helm_ingress_endpoint: network
73 openstack_helm_ingress_service_name: neutron-server
74 openstack_helm_ingress_service_port: 9696
Mohammed Naser2145fc32023-01-29 23:23:03 +000075 openstack_helm_ingress_annotations: "{{ neutron_ingress_annotations }}"
Mohammed Naserb7b97d62022-03-12 16:30:00 -050076
Mohammed Naserb7b97d62022-03-12 16:30:00 -050077- name: Create networks
Mohammed Naser2145fc32023-01-29 23:23:03 +000078 when: neutron_networks | length > 0
Mohammed Naserc8e1a452022-08-11 16:16:13 -040079 block:
80 - name: Wait until network service ready
81 kubernetes.core.k8s_info:
82 api_version: apps/v1
83 kind: Deployment
84 name: neutron-server
85 namespace: openstack
86 wait_sleep: 10
87 wait_timeout: 600
88 wait: true
89 wait_condition:
90 type: Available
91 status: true
Mohammed Naserb7b97d62022-03-12 16:30:00 -050092
Mohammed Naserc8e1a452022-08-11 16:16:13 -040093 - name: Create networks
94 openstack.cloud.network:
95 cloud: atmosphere
96 # Network settings
97 name: "{{ item.name }}"
98 external: "{{ item.external | default(omit) }}"
99 shared: "{{ item.shared | default(omit) }}"
100 mtu_size: "{{ item.mtu_size | default(omit) }}"
101 port_security_enabled: "{{ item.port_security_enabled | default(omit) }}"
102 provider_network_type: "{{ item.provider_network_type | default(omit) }}"
103 provider_physical_network: "{{ item.provider_physical_network | default(omit) }}"
104 provider_segmentation_id: "{{ item.provider_segmentation_id | default(omit) }}"
Mohammed Naser2145fc32023-01-29 23:23:03 +0000105 loop: "{{ neutron_networks }}"
Mohammed Naser52c3a702023-02-02 02:03:34 +0000106 # NOTE(mnaser): This often fails since the SSL certificates are not
107 # ready yet. We need to wait for them to be ready.
108 retries: 60
109 delay: 5
110 register: _result
111 until: _result is not failed
Mohammed Naserc8e1a452022-08-11 16:16:13 -0400112
113 - name: Create subnets
114 openstack.cloud.subnet:
115 cloud: atmosphere
116 # Subnet settings
117 network_name: "{{ item.0.name }}"
118 name: "{{ item.1.name }}"
119 ip_version: "{{ item.1.ip_version | default(omit) }}"
120 cidr: "{{ item.1.cidr | default(omit) }}"
121 gateway_ip: "{{ item.1.gateway_ip | default(omit) }}"
122 no_gateway_ip: "{{ item.1.no_gateway_ip | default(omit) }}"
123 allocation_pool_start: "{{ item.1.allocation_pool_start | default(omit) }}"
124 allocation_pool_end: "{{ item.1.allocation_pool_end | default(omit) }}"
125 dns_nameservers: "{{ item.1.dns_nameservers | default(omit) }}"
126 enable_dhcp: "{{ item.1.enable_dhcp | default(omit) }}"
127 host_routes: "{{ item.1.host_routes | default(omit) }}"
128 ipv6_address_mode: "{{ item.1.ipv6_address_mode | default(omit) }}"
129 ipv6_ra_mode: "{{ item.1.ipv6_ra_mode | default(omit) }}"
130 with_subelements:
Mohammed Naser2145fc32023-01-29 23:23:03 +0000131 - "{{ neutron_networks }}"
Mohammed Naserc8e1a452022-08-11 16:16:13 -0400132 - subnets
Mohammed Naser52c3a702023-02-02 02:03:34 +0000133 # NOTE(mnaser): This often fails since the SSL certificates are not
134 # ready yet. We need to wait for them to be ready.
135 retries: 60
136 delay: 5
137 register: _result
138 until: _result is not failed