blob: fdb34aef1cdf441a561c728af88013d026b2595f [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
guilhermesteinmullerd946d7a2022-04-04 15:04:27 -030015- name: Collect "ceph mon dump" output from a monitor
16 delegate_to: "{{ groups[ceph_csi_rbd_mons_group][0] }}"
Mohammed Naserb7b97d62022-03-12 16:30:00 -050017 run_once: true
guilhermesteinmullerd946d7a2022-04-04 15:04:27 -030018 ansible.builtin.command: ceph mon dump -f json
19 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_monitors: "{{ _ceph_mon_dump.stdout | from_json | community.general.json_query('mons[*].addr') | map('regex_replace', '(.*):(.*)', '\\1') }}"
Mohammed Naserb7b97d62022-03-12 16:30:00 -050026
Mohammed Naser511c3fa2022-03-17 17:54:10 -040027- name: Create Ceph pool
Mohammed Naser63b739d2022-05-19 21:51:31 -040028 delegate_to: "{{ groups[ceph_csi_rbd_mons_group][0] }}"
Mohammed Naser511c3fa2022-03-17 17:54:10 -040029 vexxhost.atmosphere.ceph_pool:
Mohammed Naserb7b97d62022-03-12 16:30:00 -050030 name: "{{ ceph_csi_rbd_pool }}"
Mohammed Naser63b739d2022-05-19 21:51:31 -040031 rule_name: "{{ ceph_csi_rbd_rule_name | default(omit) }}"
Mohammed Naserb7b97d62022-03-12 16:30:00 -050032 application: rbd
Mohammed Naser511c3fa2022-03-17 17:54:10 -040033 pg_autoscale_mode: "on"
Mohammed Naserb7b97d62022-03-12 16:30:00 -050034
Mohammed Naser4b24d9b2022-11-02 13:14:52 -040035- name: Create user {{ ceph_csi_rbd_user }}
Mohammed Naser63b739d2022-05-19 21:51:31 -040036 delegate_to: "{{ groups[ceph_csi_rbd_mons_group][0] }}"
Mohammed Naser511c3fa2022-03-17 17:54:10 -040037 vexxhost.atmosphere.ceph_key:
Mohammed Naserb7b97d62022-03-12 16:30:00 -050038 name: "{{ ceph_csi_rbd_user }}"
39 caps:
40 mon: profile rbd
41 mgr: profile rbd pool={{ ceph_csi_rbd_pool }}
42 osd: profile rbd pool={{ ceph_csi_rbd_pool }}
43
Mohammed Naser4b24d9b2022-11-02 13:14:52 -040044- name: Retrieve keyring for {{ ceph_csi_rbd_user }}
Mohammed Naser63b739d2022-05-19 21:51:31 -040045 delegate_to: "{{ groups[ceph_csi_rbd_mons_group][0] }}"
Mohammed Naser511c3fa2022-03-17 17:54:10 -040046 vexxhost.atmosphere.ceph_key:
Mohammed Naserb7b97d62022-03-12 16:30:00 -050047 name: "{{ ceph_csi_rbd_user }}"
48 state: info
49 output_format: json
50 register: _ceph_key
51
Mohammed Naser511c3fa2022-03-17 17:54:10 -040052- name: Store keyring inside fact
53 ansible.builtin.set_fact:
Mohammed Naserb7b97d62022-03-12 16:30:00 -050054 _ceph_rbd_csi_ceph_keyring: "{{ _ceph_key.stdout | from_json | first }}"
55
Mohammed Naser511c3fa2022-03-17 17:54:10 -040056- name: Deploy Helm chart
Mohammed Naserc8e1a452022-08-11 16:16:13 -040057 kubernetes.core.k8s:
58 state: present
59 definition:
Mohammed Naserc8e1a452022-08-11 16:16:13 -040060 - apiVersion: helm.toolkit.fluxcd.io/v2beta1
61 kind: HelmRelease
62 metadata:
63 name: ceph-csi-rbd
64 namespace: kube-system
65 spec:
66 interval: 60s
67 chart:
68 spec:
69 chart: ceph-csi-rbd
70 version: 3.5.1
71 sourceRef:
72 kind: HelmRepository
73 name: ceph
74 values:
75 csiConfig:
76 - clusterID: "{{ ceph_csi_rbd_ceph_fsid }}"
77 monitors: "{{ ceph_monitors }}"
78 nodeplugin:
79 httpMetrics:
80 containerPort: 8081
Mohammed Naser71ebfe82022-12-28 05:28:16 +000081 registrar:
82 image:
83 repository: "{{ lookup('vexxhost.atmosphere.image_ref', 'csi_node_driver_registrar', output='name') }}"
84 plugin:
85 image:
86 repository: "{{ lookup('vexxhost.atmosphere.image_ref', 'csi_rbd_plugin', output='name') }}"
Mohammed Naserc8e1a452022-08-11 16:16:13 -040087 provisioner:
88 nodeSelector:
89 openstack-control-plane: enabled
Mohammed Naser71ebfe82022-12-28 05:28:16 +000090 provisioner:
91 image:
92 repository: "{{ lookup('vexxhost.atmosphere.image_ref', 'csi_rbd_provisioner', output='name') }}"
93 attacher:
94 image:
95 repository: "{{ lookup('vexxhost.atmosphere.image_ref', 'csi_rbd_attacher', output='name') }}"
96 resizer:
97 image:
98 repository: "{{ lookup('vexxhost.atmosphere.image_ref', 'csi_rbd_resizer', output='name') }}"
99 snapshotter:
100 image:
101 repository: "{{ lookup('vexxhost.atmosphere.image_ref', 'csi_rbd_snapshotter', output='name') }}"
Mohammed Naserc8e1a452022-08-11 16:16:13 -0400102 storageClass:
103 create: true
104 name: general
105 annotations:
106 storageclass.kubernetes.io/is-default-class: "true"
107 clusterID: "{{ ceph_csi_rbd_ceph_fsid }}"
108 pool: "{{ ceph_csi_rbd_pool }}"
109 mountOptions:
110 - discard
111 secret:
112 create: true
113 userID: "{{ ceph_csi_rbd_id }}"
114 userKey: "{{ _ceph_rbd_csi_ceph_keyring.key }}"