Oleksandr Kozachenko | b009349 | 2023-09-06 21:43:47 +0200 | [diff] [blame] | 1 | # 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 | |
Rico Lin | 46bb4f1 | 2023-10-18 00:28:48 +0800 | [diff] [blame] | 23 | - name: Install MySQL python package |
Oleksandr Kozachenko | b009349 | 2023-09-06 21:43:47 +0200 | [diff] [blame] | 24 | ansible.builtin.pip: |
| 25 | name: PyMySQL |
| 26 | |
Rico Lin | 46bb4f1 | 2023-10-18 00:28:48 +0800 | [diff] [blame] | 27 | - name: Check MySQL ready |
| 28 | community.mysql.mysql_info: |
| 29 | login_host: "{{ _pxc_service.resources[0].spec.clusterIP }}" |
| 30 | login_user: root |
| 31 | login_password: "{{ openstack_helm_endpoints.oslo_db.auth.admin.password }}" |
| 32 | filter: |
| 33 | - version |
| 34 | register: mysql_ready |
| 35 | until: mysql_ready is not failed |
| 36 | retries: 10 |
| 37 | delay: 5 |
| 38 | |
Oleksandr Kozachenko | b009349 | 2023-09-06 21:43:47 +0200 | [diff] [blame] | 39 | - name: Create Keycloak database |
| 40 | run_once: true |
| 41 | community.mysql.mysql_db: |
| 42 | login_host: "{{ _pxc_service.resources[0].spec.clusterIP }}" |
| 43 | login_user: root |
| 44 | login_password: "{{ openstack_helm_endpoints.oslo_db.auth.admin.password }}" |
| 45 | name: "{{ keycloak_database_name }}" |
| 46 | |
| 47 | - name: Create a Keycloak user |
| 48 | run_once: true |
| 49 | community.mysql.mysql_user: |
| 50 | login_host: "{{ _pxc_service.resources[0].spec.clusterIP }}" |
| 51 | login_user: root |
| 52 | login_password: "{{ openstack_helm_endpoints.oslo_db.auth.admin.password }}" |
| 53 | name: "{{ keycloak_database_username }}" |
| 54 | password: "{{ keycloak_database_password }}" |
| 55 | host: "%" |
| 56 | priv: "{{ keycloak_database_name }}.*:ALL" |
| 57 | |
| 58 | - name: Disable pxc strict mode |
| 59 | community.mysql.mysql_query: |
| 60 | login_host: "{{ _pxc_service.resources[0].spec.clusterIP }}" |
| 61 | login_user: root |
| 62 | login_password: "{{ openstack_helm_endpoints.oslo_db.auth.admin.password }}" |
| 63 | query: "set global pxc_strict_mode='PERMISSIVE'" |
| 64 | |
| 65 | - name: Deploy Helm chart |
| 66 | run_once: true |
| 67 | kubernetes.core.helm: |
| 68 | name: "{{ keycloak_helm_release_name }}" |
| 69 | chart_ref: "{{ keycloak_helm_chart_ref }}" |
| 70 | release_namespace: "{{ keycloak_helm_release_namespace }}" |
| 71 | create_namespace: true |
| 72 | kubeconfig: /etc/kubernetes/admin.conf |
| 73 | wait: true |
Oleksandr K | a518383 | 2024-01-02 22:17:48 +0100 | [diff] [blame] | 74 | timeout: 10m |
Oleksandr Kozachenko | b009349 | 2023-09-06 21:43:47 +0200 | [diff] [blame] | 75 | values: "{{ _keycloak_helm_values | combine(keycloak_helm_values, recursive=True) }}" |
| 76 | |
| 77 | - name: Create Keycloak Ingress |
| 78 | ansible.builtin.include_role: |
| 79 | name: ingress |
| 80 | vars: |
| 81 | ingress_name: keycloak |
| 82 | ingress_namespace: "{{ keycloak_helm_release_namespace }}" |
| 83 | ingress_class_name: "{{ keycloak_ingress_class_name }}" |
| 84 | ingress_host: "{{ keycloak_host }}" |
| 85 | ingress_service_name: "{{ keycloak_helm_release_name }}" |
| 86 | ingress_service_port: 80 |
Michiel Piscaer | 4ea5220 | 2023-09-11 17:29:29 +0200 | [diff] [blame] | 87 | ingress_secret_name: "{{ keycloak_host_tls_secret_name }}" |
Oleksandr Kozachenko | b009349 | 2023-09-06 21:43:47 +0200 | [diff] [blame] | 88 | ingress_annotations: |
| 89 | cert-manager.io/cluster-issuer: atmosphere |
| 90 | |
Rico Lin | 46bb4f1 | 2023-10-18 00:28:48 +0800 | [diff] [blame] | 91 | - name: Enable pxc strict mode |
Oleksandr Kozachenko | b009349 | 2023-09-06 21:43:47 +0200 | [diff] [blame] | 92 | community.mysql.mysql_query: |
| 93 | login_host: "{{ _pxc_service.resources[0].spec.clusterIP }}" |
| 94 | login_user: root |
| 95 | login_password: "{{ openstack_helm_endpoints.oslo_db.auth.admin.password }}" |
| 96 | query: "set global pxc_strict_mode='ENFORCING'" |