blob: c4d1b80cd9ad057fb65c951645670ecf09b164ed [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
28 vexxhost.atmosphere.ceph_pool:
Mohammed Naserb7b97d62022-03-12 16:30:00 -050029 name: "{{ ceph_csi_rbd_pool }}"
30 application: rbd
Mohammed Naser511c3fa2022-03-17 17:54:10 -040031 pg_autoscale_mode: "on"
Mohammed Naserb7b97d62022-03-12 16:30:00 -050032
Mohammed Naser511c3fa2022-03-17 17:54:10 -040033- name: Create {{ ceph_csi_rbd_user }} user
34 vexxhost.atmosphere.ceph_key:
Mohammed Naserb7b97d62022-03-12 16:30:00 -050035 name: "{{ ceph_csi_rbd_user }}"
36 caps:
37 mon: profile rbd
38 mgr: profile rbd pool={{ ceph_csi_rbd_pool }}
39 osd: profile rbd pool={{ ceph_csi_rbd_pool }}
40
Mohammed Naser511c3fa2022-03-17 17:54:10 -040041- name: Retrieve {{ ceph_csi_rbd_user }} keyring
42 vexxhost.atmosphere.ceph_key:
Mohammed Naserb7b97d62022-03-12 16:30:00 -050043 name: "{{ ceph_csi_rbd_user }}"
44 state: info
45 output_format: json
46 register: _ceph_key
47
Mohammed Naser511c3fa2022-03-17 17:54:10 -040048- name: Store keyring inside fact
49 ansible.builtin.set_fact:
Mohammed Naserb7b97d62022-03-12 16:30:00 -050050 _ceph_rbd_csi_ceph_keyring: "{{ _ceph_key.stdout | from_json | first }}"
51
Mohammed Naser511c3fa2022-03-17 17:54:10 -040052- name: Deploy Helm chart
53 kubernetes.core.helm:
Mohammed Naserb7b97d62022-03-12 16:30:00 -050054 name: ceph-csi-rbd
55 chart_ref: ceph/ceph-csi-rbd
56 chart_version: 3.5.1
57 release_namespace: kube-system
58 kubeconfig: /etc/kubernetes/admin.conf
59 values:
60 csiConfig:
61 - clusterID: "{{ ceph_mon_fsid }}"
guilhermesteinmullerd946d7a2022-04-04 15:04:27 -030062 monitors: "{{ ceph_monitors }}"
Mohammed Naserb7b97d62022-03-12 16:30:00 -050063 nodeplugin:
64 httpMetrics:
65 containerPort: 8081
66 provisioner:
67 nodeSelector:
68 openstack-control-plane: enabled
69 storageClass:
70 create: true
71 name: general
72 annotations:
73 storageclass.kubernetes.io/is-default-class: "true"
74 clusterID: "{{ ceph_csi_rbd_ceph_fsid }}"
75 pool: "{{ ceph_csi_rbd_pool }}"
76 mountOptions:
77 - discard
78 secret:
79 create: true
80 userID: "{{ ceph_csi_rbd_id }}"
81 userKey: "{{ _ceph_rbd_csi_ceph_keyring.key }}"