blob: 057b75aafaff9f5b3b8d3f72687d8db627fc8643 [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
15- name: Retrieve Helm values for "ceph-csi-rbd"
Mohammed Nasere8159ae2023-01-16 22:16:06 +000016 kubernetes.core.helm_info:
Mohammed Naserb7b97d62022-03-12 16:30:00 -050017 name: ceph-csi-rbd
Mohammed Nasere8159ae2023-01-16 22:16:06 +000018 release_namespace: kube-system
19 register: _ceph_csi_rbd_helm_info
Mohammed Naserb7b97d62022-03-12 16:30:00 -050020
21- name: Create Ceph service
22 kubernetes.core.k8s:
23 state: present
24 definition:
25 apiVersion: v1
26 kind: Service
27 metadata:
28 name: ceph-mon
29 namespace: openstack
30 labels:
31 application: ceph
32 spec:
33 clusterIP: None
34 ports:
35 - name: mon
36 port: 6789
37 targetPort: 6789
38 - name: mon-msgr2
39 port: 3300
40 targetPort: 3300
41 - name: metrics
42 port: 9283
43 targetPort: 9283
44
45- name: Generate Ceph endpoint list
46 ansible.builtin.set_fact:
Mohammed Naser2145fc32023-01-29 23:23:03 +000047 _ceph_provisioners_ceph_monitors: |
Mohammed Naser511c3fa2022-03-17 17:54:10 -040048 {{
Mohammed Naser2145fc32023-01-29 23:23:03 +000049 _ceph_provisioners_ceph_monitors | default([]) +
Mohammed Naserb7b97d62022-03-12 16:30:00 -050050 [{'ip': item}]
51 }}
Mohammed Naser2145fc32023-01-29 23:23:03 +000052 loop: "{{ ceph_provisioners_ceph_monitors }}"
Mohammed Naserb7b97d62022-03-12 16:30:00 -050053
54- name: Create Ceph endpoints
55 kubernetes.core.k8s:
56 state: present
57 definition:
58 apiVersion: v1
59 kind: Endpoints
60 metadata:
61 name: ceph-mon
62 namespace: openstack
63 labels:
64 application: ceph
65 subsets:
Mohammed Naser2145fc32023-01-29 23:23:03 +000066 - addresses: "{{ _ceph_provisioners_ceph_monitors }}"
Mohammed Naserb7b97d62022-03-12 16:30:00 -050067 ports:
68 - name: mon
69 port: 6789
70 protocol: TCP
71 - name: mon-msgr2
72 port: 3300
73 protocol: TCP
74 - name: metrics
75 port: 9283
76 protocol: TCP
77
78- name: Retrieve client.admin keyring
Mohammed Naser2145fc32023-01-29 23:23:03 +000079 delegate_to: "{{ groups[ceph_provisioners_ceph_mon_group][0] }}"
Mohammed Naserb7b97d62022-03-12 16:30:00 -050080 vexxhost.atmosphere.ceph_key:
81 name: client.admin
82 state: info
83 output_format: json
Mohammed Naser2145fc32023-01-29 23:23:03 +000084 register: _ceph_provisioners_ceph_key
Mohammed Naserb7b97d62022-03-12 16:30:00 -050085
86- name: Parse client.admin keyring
87 ansible.builtin.set_fact:
Mohammed Naser2145fc32023-01-29 23:23:03 +000088 _ceph_provisioners_keyring: "{{ _ceph_provisioners_ceph_key.stdout | from_json | first }}"
Mohammed Naserb7b97d62022-03-12 16:30:00 -050089
90- name: Create "pvc-ceph-client-key" secret
91 kubernetes.core.k8s:
92 state: present
93 definition:
94 apiVersion: v1
95 kind: Secret
96 type: kubernetes.io/rbd
97 metadata:
98 name: pvc-ceph-client-key
99 namespace: openstack
100 labels:
101 application: ceph
102 stringData:
Mohammed Naser2145fc32023-01-29 23:23:03 +0000103 key: "{{ _ceph_provisioners_keyring.key }}"
Mohammed Naserb7b97d62022-03-12 16:30:00 -0500104
105- name: Deploy Helm chart
guilhermesteinmuller155f8042023-01-24 19:47:44 +0000106 run_once: true
107 kubernetes.core.helm:
Mohammed Naser2145fc32023-01-29 23:23:03 +0000108 name: "{{ ceph_provisioners_helm_release_name }}"
109 chart_ref: "{{ ceph_provisioners_helm_chart_ref }}"
110 release_namespace: "{{ ceph_provisioners_helm_release_namespace }}"
guilhermesteinmuller155f8042023-01-24 19:47:44 +0000111 create_namespace: true
112 kubeconfig: /etc/kubernetes/admin.conf
Mohammed Naser2145fc32023-01-29 23:23:03 +0000113 values: "{{ _ceph_provisioners_helm_values | combine(ceph_provisioners_helm_values, recursive=True) }}"