blob: 5cdcbd4679ddafda6d532e750503d4dc81276504 [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:
60 - apiVersion: source.toolkit.fluxcd.io/v1beta2
61 kind: HelmRepository
62 metadata:
63 name: ceph
64 namespace: kube-system
65 spec:
66 interval: 60s
67 url: https://ceph.github.io/csi-charts
68
69 - apiVersion: helm.toolkit.fluxcd.io/v2beta1
70 kind: HelmRelease
71 metadata:
72 name: ceph-csi-rbd
73 namespace: kube-system
74 spec:
75 interval: 60s
76 chart:
77 spec:
78 chart: ceph-csi-rbd
79 version: 3.5.1
80 sourceRef:
81 kind: HelmRepository
82 name: ceph
83 values:
84 csiConfig:
85 - clusterID: "{{ ceph_csi_rbd_ceph_fsid }}"
86 monitors: "{{ ceph_monitors }}"
87 nodeplugin:
88 httpMetrics:
89 containerPort: 8081
90 provisioner:
91 nodeSelector:
92 openstack-control-plane: enabled
93 storageClass:
94 create: true
95 name: general
96 annotations:
97 storageclass.kubernetes.io/is-default-class: "true"
98 clusterID: "{{ ceph_csi_rbd_ceph_fsid }}"
99 pool: "{{ ceph_csi_rbd_pool }}"
100 mountOptions:
101 - discard
102 secret:
103 create: true
104 userID: "{{ ceph_csi_rbd_id }}"
105 userKey: "{{ _ceph_rbd_csi_ceph_keyring.key }}"