blob: e62069bd0559e260dbd92c6090141d6cf63384b1 [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
Mohammed Naser3f961782023-04-20 10:48:21 -040015- name: Collect "ceph mon dump" output from a monitor
16 delegate_to: "{{ groups[ceph_provisioners_ceph_mon_group][0] }}"
17 run_once: true
Rico Line7132672024-02-28 00:10:53 +080018 ansible.builtin.command: cephadm shell -- ceph mon dump -f json
Mohammed Naser3f961782023-04-20 10:48:21 -040019 changed_when: false
20 register: _ceph_mon_dump
21
22- name: Generate fact with list of Ceph monitors
23 run_once: true
24 ansible.builtin.set_fact:
25 _ceph_provisioners_ceph_fsid: "{{ _ceph_mon_dump.stdout | from_json | community.general.json_query('fsid') }}"
26 _ceph_provisioners_ceph_monitors: |
27 {{
28 _ceph_provisioners_ceph_monitors | default([]) +
29 [{'ip': item}]
30 }}
31 loop: "{{ _ceph_mon_dump.stdout | from_json | community.general.json_query('mons[*].addr') | map('regex_replace', '(.*):(.*)', '\\1') }}"
Mohammed Naserb7b97d62022-03-12 16:30:00 -050032
33- name: Create Ceph service
34 kubernetes.core.k8s:
35 state: present
36 definition:
37 apiVersion: v1
38 kind: Service
39 metadata:
40 name: ceph-mon
41 namespace: openstack
42 labels:
43 application: ceph
44 spec:
45 clusterIP: None
46 ports:
47 - name: mon
48 port: 6789
49 targetPort: 6789
50 - name: mon-msgr2
51 port: 3300
52 targetPort: 3300
53 - name: metrics
54 port: 9283
55 targetPort: 9283
56
Mohammed Naserb7b97d62022-03-12 16:30:00 -050057- name: Create Ceph endpoints
58 kubernetes.core.k8s:
59 state: present
60 definition:
61 apiVersion: v1
62 kind: Endpoints
63 metadata:
64 name: ceph-mon
65 namespace: openstack
66 labels:
67 application: ceph
68 subsets:
Mohammed Naser2145fc32023-01-29 23:23:03 +000069 - addresses: "{{ _ceph_provisioners_ceph_monitors }}"
Mohammed Naserb7b97d62022-03-12 16:30:00 -050070 ports:
71 - name: mon
72 port: 6789
73 protocol: TCP
74 - name: mon-msgr2
75 port: 3300
76 protocol: TCP
77 - name: metrics
78 port: 9283
79 protocol: TCP
80
81- name: Retrieve client.admin keyring
Mohammed Naser2145fc32023-01-29 23:23:03 +000082 delegate_to: "{{ groups[ceph_provisioners_ceph_mon_group][0] }}"
Mohammed Naser545bc432023-04-16 23:02:23 +000083 vexxhost.ceph.key:
Mohammed Naserb7b97d62022-03-12 16:30:00 -050084 name: client.admin
85 state: info
86 output_format: json
Mohammed Naser2145fc32023-01-29 23:23:03 +000087 register: _ceph_provisioners_ceph_key
Mohammed Naserb7b97d62022-03-12 16:30:00 -050088
89- name: Parse client.admin keyring
90 ansible.builtin.set_fact:
Mohammed Naser2145fc32023-01-29 23:23:03 +000091 _ceph_provisioners_keyring: "{{ _ceph_provisioners_ceph_key.stdout | from_json | first }}"
Mohammed Naserb7b97d62022-03-12 16:30:00 -050092
93- name: Create "pvc-ceph-client-key" secret
94 kubernetes.core.k8s:
95 state: present
96 definition:
97 apiVersion: v1
98 kind: Secret
99 type: kubernetes.io/rbd
100 metadata:
101 name: pvc-ceph-client-key
102 namespace: openstack
103 labels:
104 application: ceph
105 stringData:
Mohammed Naser2145fc32023-01-29 23:23:03 +0000106 key: "{{ _ceph_provisioners_keyring.key }}"
Mohammed Naserb7b97d62022-03-12 16:30:00 -0500107
108- name: Deploy Helm chart
guilhermesteinmuller155f8042023-01-24 19:47:44 +0000109 run_once: true
110 kubernetes.core.helm:
Mohammed Naser2145fc32023-01-29 23:23:03 +0000111 name: "{{ ceph_provisioners_helm_release_name }}"
112 chart_ref: "{{ ceph_provisioners_helm_chart_ref }}"
113 release_namespace: "{{ ceph_provisioners_helm_release_namespace }}"
guilhermesteinmuller155f8042023-01-24 19:47:44 +0000114 create_namespace: true
115 kubeconfig: /etc/kubernetes/admin.conf
Mohammed Naser2145fc32023-01-29 23:23:03 +0000116 values: "{{ _ceph_provisioners_helm_values | combine(ceph_provisioners_helm_values, recursive=True) }}"