|
16 | 16 | ansible.builtin.assert: |
17 | 17 | that: n_result.resources | length == 1 |
18 | 18 |
|
19 | | -# Secrets (RabbitMQ) ---------------------------------------------------------- |
20 | | - |
21 | | -- name: Create RabbitMQ Secret |
22 | | - when: rabbitmq_state|string == 'present' |
23 | | - block: |
24 | | - |
25 | | - - name: Check RabbitMQ secrets |
26 | | - kubernetes.core.k8s_info: |
27 | | - kind: Secret |
28 | | - api_version: v1 |
29 | | - namespace: "{{ infra_namespace }}" |
30 | | - name: im-rabbitmq |
31 | | - register: rmq_s_result |
32 | | - |
33 | | - - name: Set RabbitMQ secret facts |
34 | | - ansible.builtin.set_fact: |
35 | | - rabbitmq_user_fact: "{{ rabbitmq_user }}" |
36 | | - rabbitmq_user_password_fact: "{{ rabbitmq_user_password }}" |
37 | | - rabbitmq_erlang_cookie_fact: "{{ rabbitmq_erlang_cookie }}" |
38 | | - when: rmq_s_result.resources | length == 0 |
39 | | - |
40 | | - - name: Set RabbitMQ secret facts (pre-deployed secrets) |
41 | | - ansible.builtin.set_fact: |
42 | | - rabbitmq_user_fact: "{{ rmq_s_result.resources[0].data.user | b64decode }}" |
43 | | - rabbitmq_user_password_fact: "{{ rmq_s_result.resources[0].data.password | b64decode }}" |
44 | | - rabbitmq_erlang_cookie_fact: "{{ rmq_s_result.resources[0].data.erlang_cookie | b64decode }}" |
45 | | - when: rmq_s_result.resources | length == 1 |
46 | | - |
47 | | - - name: Write RabbitMQ secrets |
48 | | - kubernetes.core.k8s: |
49 | | - definition: "{{ lookup('template', 'secret-rabbitmq.yaml.j2') }}" |
50 | | - wait: yes |
51 | | - when: rmq_s_result.resources | length == 0 |
52 | | - |
53 | 19 | # RabbitMQ -------------------------------------------------------------------- |
54 | 20 |
|
55 | 21 | - name: Deploy RabbitMQ |
|
60 | 26 | that: |
61 | 27 | - kc_cert_issuer in cert_issuer_set |
62 | 28 |
|
63 | | - - name: Get {{ rabbitmq_vol_storageclass }} StorageClass |
64 | | - kubernetes.core.k8s_info: |
65 | | - kind: StorageClass |
66 | | - name: "{{ rabbitmq_vol_storageclass }}" |
67 | | - register: sc_result |
68 | | - when: rabbitmq_vol_storageclass != " " |
69 | | - |
70 | | - - name: Assert {{ pg_vol_storageclass }} StorageClass |
71 | | - ansible.builtin.assert: |
72 | | - that: sc_result.resources | length == 1 |
73 | | - fail_msg: The {{ rabbitmq_vol_storageclass }} StorageClass must be available on the cluster |
74 | | - when: rabbitmq_vol_storageclass != " " |
75 | | - |
76 | | - - name: Create RabbitMQ volume claims |
77 | | - kubernetes.core.k8s: |
78 | | - definition: "{{ lookup('template', item) }}" |
79 | | - wait: yes |
80 | | - wait_timeout: "{{ wait_timeout }}" |
81 | | - loop: |
82 | | - - pvc-rabbitmq-data.yaml.j2 |
83 | | - - pvc-rabbitmq-log.yaml.j2 |
84 | | - |
85 | | - # Best practice ... wait for the PVC to bind. |
86 | | - # e.g. wait until resources[0].status.phase == Bound (initially Pending) |
87 | | - |
88 | | - - name: Wait for RabbitMQ volume claim to bind |
89 | | - kubernetes.core.k8s_info: |
90 | | - kind: PersistentVolumeClaim |
91 | | - name: rabbitmq-data |
92 | | - namespace: "{{ infra_namespace }}" |
93 | | - register: rabbitmq_pvc_result |
94 | | - until: >- |
95 | | - rabbitmq_pvc_result.resources | length > 0 |
96 | | - and rabbitmq_pvc_result.resources[0].status is defined |
97 | | - and rabbitmq_pvc_result.resources[0].status.phase is defined |
98 | | - and rabbitmq_pvc_result.resources[0].status.phase == 'Bound' |
99 | | - delay: 5 |
100 | | - retries: "{{ (bind_timeout | int / 5) | int }}" |
101 | | - when: wait_for_bind | bool |
102 | | - |
103 | 29 | - name: RabbitMQ |
104 | 30 | kubernetes.core.k8s: |
105 | 31 | definition: "{{ lookup('template', item) }}" |
106 | 32 | wait: yes |
107 | 33 | wait_timeout: "{{ wait_timeout }}" |
108 | 34 | loop: |
109 | | - - configmap-rabbitmq-conf.yaml.j2 |
110 | | - - configmap-rabbitmq-plugins.yaml.j2 |
111 | | - - service-rabbitmq.yaml.j2 |
112 | | - - statefulset-rabbitmq.yaml.j2 |
| 35 | + - rabbitmqcluster.yaml.j2 |
113 | 36 |
|
114 | 37 | - name: Wait for RabbitMQ to become Ready ({{ wait_timeout }} seconds) |
115 | 38 | kubernetes.core.k8s_info: |
116 | 39 | kind: Pod |
117 | | - name: rabbitmq-0 |
| 40 | + name: rabbit-server-0 |
118 | 41 | namespace: "{{ infra_namespace }}" |
119 | 42 | register: rabbitmq_result |
120 | 43 | until: >- |
121 | | - rabbitmq_result.resources | length == 1 |
| 44 | + rabbitmq_result.resources | length > 0 |
122 | 45 | and rabbitmq_result.resources[0].status is defined |
123 | 46 | and rabbitmq_result.resources[0].status.containerStatuses is defined |
124 | | - and rabbitmq_result.resources[0].status.containerStatuses | length == 1 |
| 47 | + and rabbitmq_result.resources[0].status.containerStatuses | length > 0 |
125 | 48 | and rabbitmq_result.resources[0].status.containerStatuses[0].ready |
126 | 49 | delay: 30 |
127 | 50 | retries: "{{ (wait_timeout | int / 30) | int }}" |
|
0 commit comments