blob: b9c3bfdab2c9e1d1d0bcd425dffe33801bd1e21c [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
guilhermesteinmullerbc82a042023-01-24 18:20:05 +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: "{{ glance_helm_release_name }}"
24 namespace: "{{ glance_helm_release_namespace }}"
guilhermesteinmullerbc82a042023-01-24 18:20:05 +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: "{{ glance_helm_release_name }}"
35 namespace: "{{ glance_helm_release_namespace }}"
Mohammed Naserb7b97d62022-03-12 16:30:00 -050036
37- name: Deploy Helm chart
guilhermesteinmullerbc82a042023-01-24 18:20:05 +000038 run_once: true
39 kubernetes.core.helm:
Mohammed Naser2145fc32023-01-29 23:23:03 +000040 name: "{{ glance_helm_release_name }}"
41 chart_ref: "{{ glance_helm_chart_ref }}"
42 release_namespace: "{{ glance_helm_release_namespace }}"
guilhermesteinmullerbc82a042023-01-24 18:20:05 +000043 create_namespace: true
44 kubeconfig: /etc/kubernetes/admin.conf
Mohammed Naser2145fc32023-01-29 23:23:03 +000045 values: "{{ _glance_helm_values | combine(glance_helm_values, recursive=True) }}"
Mohammed Naserb7b97d62022-03-12 16:30:00 -050046
47- name: Create Ingress
48 ansible.builtin.include_role:
49 name: openstack_helm_ingress
50 vars:
51 openstack_helm_ingress_endpoint: image
52 openstack_helm_ingress_service_name: glance-api
53 openstack_helm_ingress_service_port: 9292
Mohammed Naser2145fc32023-01-29 23:23:03 +000054 openstack_helm_ingress_annotations: "{{ _glance_ingress_annotations | combine(glance_ingress_annotations) }}"
okozachenkoa6c49ce2022-04-15 01:20:31 +100055
56- name: Create images
Mohammed Naser2145fc32023-01-29 23:23:03 +000057 when: glance_images | length > 0
okozachenkoa6c49ce2022-04-15 01:20:31 +100058 block:
59 - name: Wait until image service ready
60 kubernetes.core.k8s_info:
61 api_version: apps/v1
62 kind: Deployment
63 name: glance-api
64 namespace: openstack
65 wait_sleep: 10
66 wait_timeout: 600
67 wait: true
68 wait_condition:
69 type: Available
70 status: true
71
okozachenkoa6c49ce2022-04-15 01:20:31 +100072 - name: Download images
73 ansible.builtin.get_url:
Mohammed Naserc8e1a452022-08-11 16:16:13 -040074 url: "{{ item.source_url | regex_replace('\\/$', '') }}/{{ item.image_file }}"
okozachenkoa6c49ce2022-04-15 01:20:31 +100075 dest: "/tmp/{{ item.image_file }}"
Mohammed Naserc8e1a452022-08-11 16:16:13 -040076 mode: "0600"
Mohammed Naser2145fc32023-01-29 23:23:03 +000077 loop: "{{ glance_images }}"
okozachenkoa6c49ce2022-04-15 01:20:31 +100078
79 - name: Upload images
80 openstack.cloud.image:
okozachenko0c48e9c2022-05-19 01:57:57 +100081 cloud: atmosphere
okozachenkoa6c49ce2022-04-15 01:20:31 +100082 name: "{{ item.name }}"
83 state: present
84 filename: "/tmp/{{ item.image_file }}"
85 min_disk: "{{ item.min_disk | default(omit) }}"
86 min_ram: "{{ item.min_ram | default(omit) }}"
87 container_format: "{{ item.container_format | default(omit) }}"
88 disk_format: "{{ item.disk_format | default(omit) }}"
89 properties: "{{ item.properties | default(omit) }}"
90 kernel: "{{ item.kernel | default(omit) }}"
91 ramdisk: "{{ item.ramdisk | default(omit) }}"
92 is_public: "{{ item.is_public | default(omit) }}"
Mohammed Naser2145fc32023-01-29 23:23:03 +000093 loop: "{{ glance_images }}"