blob: 7d59b848e5ca9c1e6fe0f0b0f0cbb8afa0ac9c62 [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 Naser511c3fa2022-03-17 17:54:10 -040035- name: Create {{ ceph_csi_rbd_user }} 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 Naser511c3fa2022-03-17 17:54:10 -040044- name: Retrieve {{ ceph_csi_rbd_user }} keyring
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
81 provisioner:
82 nodeSelector:
83 openstack-control-plane: enabled
84 storageClass:
85 create: true
86 name: general
87 annotations:
88 storageclass.kubernetes.io/is-default-class: "true"
89 clusterID: "{{ ceph_csi_rbd_ceph_fsid }}"
90 pool: "{{ ceph_csi_rbd_pool }}"
91 mountOptions:
92 - discard
93 secret:
94 create: true
95 userID: "{{ ceph_csi_rbd_id }}"
96 userKey: "{{ _ceph_rbd_csi_ceph_keyring.key }}"