blob: 518409d30b3b7aca00cafe1445f12af27da906e0 [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
guilhermesteinmuller700eb2f2023-01-24 19:08:31 +000015- name: Uninstall the legacy HelmRelease
16 run_once: true
17 block:
18 - name: Suspend the existing HelmRelease
19 kubernetes.core.k8s:
20 state: patched
21 api_version: helm.toolkit.fluxcd.io/v2beta1
22 kind: HelmRelease
Mohammed Naser2145fc32023-01-29 23:23:03 +000023 name: "{{ nova_helm_release_name }}"
24 namespace: "{{ nova_helm_release_namespace }}"
guilhermesteinmuller700eb2f2023-01-24 19:08:31 +000025 definition:
26 spec:
27 suspend: true
28
29 - name: Remove the existing HelmRelease
30 kubernetes.core.k8s:
31 state: absent
32 api_version: helm.toolkit.fluxcd.io/v2beta1
33 kind: HelmRelease
Mohammed Naser2145fc32023-01-29 23:23:03 +000034 name: "{{ nova_helm_release_name }}"
35 namespace: "{{ nova_helm_release_namespace }}"
Mohammed Naserb7b97d62022-03-12 16:30:00 -050036
Mohammed Naser01338322022-03-22 14:51:31 -040037- name: Generate public key for SSH private key
38 become: false
39 delegate_to: localhost
40 block:
41 - name: Generate temporary file for SSH public key
42 changed_when: false
43 ansible.builtin.tempfile:
44 state: file
45 prefix: nova_ssh_key_
46 register: _nova_ssh_key_tempfile
47 # NOTE(mnaser): It's important to add a trailing newline at the end of this
48 # string or else `ssh-keygen` will not be happy.`
49 - name: Write contents of current private SSH key
50 changed_when: false
51 ansible.builtin.copy:
52 dest: "{{ _nova_ssh_key_tempfile.path }}"
Mohammed Naser2145fc32023-01-29 23:23:03 +000053 content: "{{ nova_ssh_key }}\n"
Mohammed Naserc8e1a452022-08-11 16:16:13 -040054 mode: "0600"
Mohammed Naser01338322022-03-22 14:51:31 -040055 - name: Generate public key for SSH private key
56 changed_when: false
57 community.crypto.openssh_keypair:
58 path: "{{ _nova_ssh_key_tempfile.path }}"
59 regenerate: never
60 register: _nova_ssh_publickey
61 always:
62 - name: Delete temporary file for public SSH key
63 changed_when: false
64 ansible.builtin.file:
65 path: "{{ _nova_ssh_key_tempfile.path }}"
66 state: absent
67
Mohammed Naserb7b97d62022-03-12 16:30:00 -050068- name: Deploy Helm chart
guilhermesteinmuller700eb2f2023-01-24 19:08:31 +000069 run_once: true
70 kubernetes.core.helm:
Mohammed Naser2145fc32023-01-29 23:23:03 +000071 name: "{{ nova_helm_release_name }}"
72 chart_ref: "{{ nova_helm_chart_ref }}"
73 release_namespace: "{{ nova_helm_release_namespace }}"
guilhermesteinmuller700eb2f2023-01-24 19:08:31 +000074 create_namespace: true
75 kubeconfig: /etc/kubernetes/admin.conf
Mohammed Naser2145fc32023-01-29 23:23:03 +000076 values: "{{ _nova_helm_values | combine(nova_helm_values, recursive=True) }}"
Mohammed Naserb7b97d62022-03-12 16:30:00 -050077
78- name: Create Ingress
79 ansible.builtin.include_role:
80 name: openstack_helm_ingress
81 vars:
82 openstack_helm_ingress_endpoint: compute
83 openstack_helm_ingress_service_name: nova-api
84 openstack_helm_ingress_service_port: 8774
Mohammed Naser2145fc32023-01-29 23:23:03 +000085 openstack_helm_ingress_annotations: "{{ nova_ingress_annotations }}"
Mohammed Naserb7b97d62022-03-12 16:30:00 -050086
87- name: Create Ingress
88 ansible.builtin.include_role:
89 name: openstack_helm_ingress
90 vars:
91 openstack_helm_ingress_endpoint: compute_novnc_proxy
92 openstack_helm_ingress_service_name: nova-novncproxy
93 openstack_helm_ingress_service_port: 6080
Mohammed Naser2145fc32023-01-29 23:23:03 +000094 openstack_helm_ingress_annotations: "{{ nova_ingress_annotations }}"
Mohammed Naserb7b97d62022-03-12 16:30:00 -050095
Mohammed Naserb7b97d62022-03-12 16:30:00 -050096- name: Create flavors
Mohammed Naser2145fc32023-01-29 23:23:03 +000097 when: nova_flavors | length > 0
Mohammed Naserc8e1a452022-08-11 16:16:13 -040098 block:
99 - name: Wait until compute api service ready
100 kubernetes.core.k8s_info:
101 api_version: apps/v1
102 kind: Deployment
103 name: nova-api-osapi
104 namespace: openstack
105 wait_sleep: 10
106 wait_timeout: 600
107 wait: true
108 wait_condition:
109 type: Available
110 status: true
111
112 - name: Create flavors
113 openstack.cloud.compute_flavor:
114 cloud: atmosphere
115 # Flavor settings
116 flavorid: "{{ item.flavorid | default(omit) }}"
117 name: "{{ item.name }}"
118 vcpus: "{{ item.vcpus }}"
119 ram: "{{ item.ram }}"
120 disk: "{{ item.disk | default(omit) }}"
121 ephemeral: "{{ item.ephemeral | default(omit) }}"
122 swap: "{{ item.swap | default(omit) }}"
123 is_public: "{{ item.is_public | default(omit) }}"
124 rxtx_factor: "{{ item.rxtx_factor | default(omit) }}"
125 extra_specs: "{{ item.extra_specs | default(omit) }}"
Mohammed Naser2145fc32023-01-29 23:23:03 +0000126 loop: "{{ nova_flavors }}"
Mohammed Naser6f85b3a2022-09-21 14:57:56 -0400127 # NOTE(mnaser): This often fails with a 503 since we're sending a request
128 # way too fast after the service is ready, retry for now
129 # but the Helm chart should be fixed.
130 #
131 # See: https://github.com/vexxhost/atmosphere/issues/72
132 retries: 60
133 delay: 5
134 register: _result
135 until: _result is not failed