blob: 3782c3c896dd36411fed843eee9fd4792a97080b [file] [log] [blame]
Oleksandr Kozachenkob0093492023-09-06 21:43:47 +02001# 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
15- name: Get the Kuberentes service for Percona XtraDB Cluster
16 run_once: true
17 kubernetes.core.k8s_info:
18 kind: Service
19 name: "{{ openstack_helm_endpoints.oslo_db.hosts.default }}"
20 namespace: openstack
21 register: _pxc_service
22
23- name: Install Kubernetes python package
24 ansible.builtin.pip:
25 name: PyMySQL
26
27- name: Create Keycloak database
28 run_once: true
29 community.mysql.mysql_db:
30 login_host: "{{ _pxc_service.resources[0].spec.clusterIP }}"
31 login_user: root
32 login_password: "{{ openstack_helm_endpoints.oslo_db.auth.admin.password }}"
33 name: "{{ keycloak_database_name }}"
34
35- name: Create a Keycloak user
36 run_once: true
37 community.mysql.mysql_user:
38 login_host: "{{ _pxc_service.resources[0].spec.clusterIP }}"
39 login_user: root
40 login_password: "{{ openstack_helm_endpoints.oslo_db.auth.admin.password }}"
41 name: "{{ keycloak_database_username }}"
42 password: "{{ keycloak_database_password }}"
43 host: "%"
44 priv: "{{ keycloak_database_name }}.*:ALL"
45
46- name: Disable pxc strict mode
47 community.mysql.mysql_query:
48 login_host: "{{ _pxc_service.resources[0].spec.clusterIP }}"
49 login_user: root
50 login_password: "{{ openstack_helm_endpoints.oslo_db.auth.admin.password }}"
51 query: "set global pxc_strict_mode='PERMISSIVE'"
52
53- name: Deploy Helm chart
54 run_once: true
55 kubernetes.core.helm:
56 name: "{{ keycloak_helm_release_name }}"
57 chart_ref: "{{ keycloak_helm_chart_ref }}"
58 release_namespace: "{{ keycloak_helm_release_namespace }}"
59 create_namespace: true
60 kubeconfig: /etc/kubernetes/admin.conf
61 wait: true
62 values: "{{ _keycloak_helm_values | combine(keycloak_helm_values, recursive=True) }}"
63
64- name: Create Keycloak Ingress
65 ansible.builtin.include_role:
66 name: ingress
67 vars:
68 ingress_name: keycloak
69 ingress_namespace: "{{ keycloak_helm_release_namespace }}"
70 ingress_class_name: "{{ keycloak_ingress_class_name }}"
71 ingress_host: "{{ keycloak_host }}"
72 ingress_service_name: "{{ keycloak_helm_release_name }}"
73 ingress_service_port: 80
Michiel Piscaer4ea52202023-09-11 17:29:29 +020074 ingress_secret_name: "{{ keycloak_host_tls_secret_name }}"
Oleksandr Kozachenkob0093492023-09-06 21:43:47 +020075 ingress_annotations:
76 cert-manager.io/cluster-issuer: atmosphere
77
78- name: Disable pxc strict mode
79 community.mysql.mysql_query:
80 login_host: "{{ _pxc_service.resources[0].spec.clusterIP }}"
81 login_user: root
82 login_password: "{{ openstack_helm_endpoints.oslo_db.auth.admin.password }}"
83 query: "set global pxc_strict_mode='ENFORCING'"