blob: b8839ee389a15ab61b3472a26da3ad2fe647dc62 [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
57 kubernetes.core.helm:
Mohammed Naserb7b97d62022-03-12 16:30:00 -050058 name: ceph-csi-rbd
59 chart_ref: ceph/ceph-csi-rbd
60 chart_version: 3.5.1
61 release_namespace: kube-system
62 kubeconfig: /etc/kubernetes/admin.conf
63 values:
64 csiConfig:
Mohammed Naser63b739d2022-05-19 21:51:31 -040065 - clusterID: "{{ ceph_csi_rbd_ceph_fsid }}"
guilhermesteinmullerd946d7a2022-04-04 15:04:27 -030066 monitors: "{{ ceph_monitors }}"
Mohammed Naserb7b97d62022-03-12 16:30:00 -050067 nodeplugin:
68 httpMetrics:
69 containerPort: 8081
70 provisioner:
71 nodeSelector:
72 openstack-control-plane: enabled
73 storageClass:
74 create: true
75 name: general
76 annotations:
77 storageclass.kubernetes.io/is-default-class: "true"
78 clusterID: "{{ ceph_csi_rbd_ceph_fsid }}"
79 pool: "{{ ceph_csi_rbd_pool }}"
80 mountOptions:
81 - discard
82 secret:
83 create: true
84 userID: "{{ ceph_csi_rbd_id }}"
85 userKey: "{{ _ceph_rbd_csi_ceph_keyring.key }}"