Mohammed Naser | b7b97d6 | 2022-03-12 16:30:00 -0500 | [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 | |
Mohammed Naser | c8e1a45 | 2022-08-11 16:16:13 -0400 | [diff] [blame] | 15 | - name: Retrieve list of all the needed endpoints |
| 16 | ansible.builtin.set_fact: |
| 17 | openstack_helm_endpoints_list: |- |
Mohammed Naser | 553e675 | 2023-01-24 13:50:51 +0000 | [diff] [blame] | 18 | {{ lookup('ansible.builtin.file', '../../../charts/' ~ openstack_helm_endpoints_chart ~ '/values.yaml', split_lines=False) | from_yaml | community.general.json_query('keys(endpoints)') | difference(_openstack_helm_endpoints_ignore) }} |
Mohammed Naser | b7b97d6 | 2022-03-12 16:30:00 -0500 | [diff] [blame] | 19 | when: |
Oleksandr Kozachenko | b009349 | 2023-09-06 21:43:47 +0200 | [diff] [blame] | 20 | - openstack_helm_endpoints_chart is defined |
Mohammed Naser | b7b97d6 | 2022-03-12 16:30:00 -0500 | [diff] [blame] | 21 | |
Mohammed Naser | fef6942 | 2023-01-18 02:38:06 +0000 | [diff] [blame] | 22 | # NOTE(mnaser): Since we manage one-RabbitMQ per service, we create the RabbitMQ |
| 23 | # cluster here and then append the necessary values to be used |
| 24 | # inside the `oslo_messaging` section. |
| 25 | - name: Configure "oslo.messaging" |
| 26 | when: |
| 27 | - '"oslo_messaging" in openstack_helm_endpoints_list' |
| 28 | block: |
| 29 | - name: Create RabbitMQ cluster |
| 30 | ansible.builtin.include_role: |
| 31 | name: rabbitmq |
| 32 | vars: |
| 33 | rabbitmq_cluster_name: "{{ openstack_helm_endpoints_chart }}" |
| 34 | |
| 35 | - name: Grab RabbitMQ cluster secret |
| 36 | kubernetes.core.k8s_info: |
| 37 | api_version: v1 |
| 38 | kind: Secret |
| 39 | name: "rabbitmq-{{ openstack_helm_endpoints_chart }}-default-user" |
| 40 | namespace: openstack |
| 41 | register: _openstack_helm_endpoints_rabbitmq_cluster_secret |
| 42 | |
| 43 | - name: Cache fact with RabbitMQ cluster credentials |
| 44 | ansible.builtin.set_fact: |
| 45 | _openstack_helm_endpoints_rabbitmq_cluster_username: |- |
| 46 | {{ _openstack_helm_endpoints_rabbitmq_cluster_secret.resources[0]['data']['username'] | b64decode }} |
| 47 | _openstack_helm_endpoints_rabbitmq_cluster_password: |- |
| 48 | {{ _openstack_helm_endpoints_rabbitmq_cluster_secret.resources[0]['data']['password'] | b64decode }} |
| 49 | |
| 50 | # NOTE(mnaser): Since we deploy the database using the operator and we let it |
| 51 | # generate the root password, we look it up if the fact has not |
| 52 | # been cached from a previous run. |
| 53 | - name: Configure "oslo.db" |
| 54 | when: |
| 55 | - '"oslo_db" in openstack_helm_endpoints_list' |
| 56 | - openstack_helm_endpoints_mariadb_admin_password is not defined |
| 57 | block: |
| 58 | - name: Grab Percona XtraDB cluster secret |
| 59 | kubernetes.core.k8s_info: |
| 60 | api_version: v1 |
| 61 | kind: Secret |
| 62 | name: percona-xtradb |
| 63 | namespace: openstack |
| 64 | register: _openstack_helm_endpoints_oslo_db_secret |
| 65 | |
| 66 | - name: Cache fact with Percona XtraDB password |
| 67 | ansible.builtin.set_fact: |
| 68 | openstack_helm_endpoints_mariadb_admin_password: "{{ _openstack_helm_endpoints_oslo_db_secret.resources[0]['data']['root'] | b64decode }}" |
| 69 | |
Mohammed Naser | b7b97d6 | 2022-03-12 16:30:00 -0500 | [diff] [blame] | 70 | - name: Reset value for OpenStack_Helm endpoints |
| 71 | ansible.builtin.set_fact: |
| 72 | openstack_helm_endpoints: "{{ openstack_helm_endpoints_config }}" |
| 73 | |
| 74 | - name: Generate OpenStack-Helm endpoints |
| 75 | ansible.builtin.set_fact: |
| 76 | openstack_helm_endpoints: | |
| 77 | {{ openstack_helm_endpoints | combine(lookup('vars', '_openstack_helm_endpoints_' + service), recursive=True) }} |
| 78 | loop: "{{ openstack_helm_endpoints_list }}" |
| 79 | loop_control: |
| 80 | loop_var: service |
| 81 | |
| 82 | # NOTE(mnaser): Since we use `openstack_helm_endpoints_list` to ensure that we |
| 83 | # have a common entry for endpoints and stay DRY, we need to |
| 84 | # reset the fact so it works for follow-up requests. |
| 85 | - name: Clean-up facts |
| 86 | ansible.builtin.set_fact: |
| 87 | openstack_helm_endpoints_list: |