blob: 3a03a265a35e90a79201d33b80a0562480399420 [file] [log] [blame]
Mohammed Naser90f91b32023-01-16 22:59:52 +00001# Copyright (c) 2023 VEXXHOST, Inc.
Mohammed Naserb7b97d62022-03-12 16:30:00 -05002#
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
Rico Line7132672024-02-28 00:10:53 +080018 ansible.builtin.command: cephadm shell -- ceph mon dump -f json
guilhermesteinmullerd946d7a2022-04-04 15:04:27 -030019 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:
Mohammed Naser545bc432023-04-16 23:02:23 +000025 ceph_csi_rbd_ceph_fsid: "{{ _ceph_mon_dump.stdout | from_json | community.general.json_query('fsid') }}"
guilhermesteinmullerd946d7a2022-04-04 15:04:27 -030026 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 -050027
Mohammed Naser511c3fa2022-03-17 17:54:10 -040028- name: Create Ceph pool
Mohammed Naser63b739d2022-05-19 21:51:31 -040029 delegate_to: "{{ groups[ceph_csi_rbd_mons_group][0] }}"
Mohammed Naser90f91b32023-01-16 22:59:52 +000030 run_once: true
Mohammed Naser545bc432023-04-16 23:02:23 +000031 vexxhost.ceph.pool:
Mohammed Naserb7b97d62022-03-12 16:30:00 -050032 name: "{{ ceph_csi_rbd_pool }}"
Mohammed Naser63b739d2022-05-19 21:51:31 -040033 rule_name: "{{ ceph_csi_rbd_rule_name | default(omit) }}"
Mohammed Naserb7b97d62022-03-12 16:30:00 -050034 application: rbd
Mohammed Naser511c3fa2022-03-17 17:54:10 -040035 pg_autoscale_mode: "on"
Mohammed Naserb7b97d62022-03-12 16:30:00 -050036
Mohammed Naser4b24d9b2022-11-02 13:14:52 -040037- name: Create user {{ ceph_csi_rbd_user }}
Mohammed Naser63b739d2022-05-19 21:51:31 -040038 delegate_to: "{{ groups[ceph_csi_rbd_mons_group][0] }}"
Mohammed Naser90f91b32023-01-16 22:59:52 +000039 run_once: true
Mohammed Naser545bc432023-04-16 23:02:23 +000040 vexxhost.ceph.key:
Mohammed Naserb7b97d62022-03-12 16:30:00 -050041 name: "{{ ceph_csi_rbd_user }}"
42 caps:
43 mon: profile rbd
44 mgr: profile rbd pool={{ ceph_csi_rbd_pool }}
45 osd: profile rbd pool={{ ceph_csi_rbd_pool }}
46
Mohammed Naser4b24d9b2022-11-02 13:14:52 -040047- name: Retrieve keyring for {{ ceph_csi_rbd_user }}
Mohammed Naser63b739d2022-05-19 21:51:31 -040048 delegate_to: "{{ groups[ceph_csi_rbd_mons_group][0] }}"
Mohammed Naser90f91b32023-01-16 22:59:52 +000049 run_once: true
Mohammed Naser545bc432023-04-16 23:02:23 +000050 vexxhost.ceph.key:
Mohammed Naserb7b97d62022-03-12 16:30:00 -050051 name: "{{ ceph_csi_rbd_user }}"
52 state: info
53 output_format: json
54 register: _ceph_key
55
Mohammed Naser511c3fa2022-03-17 17:54:10 -040056- name: Store keyring inside fact
Mohammed Naser90f91b32023-01-16 22:59:52 +000057 run_once: true
Mohammed Naser511c3fa2022-03-17 17:54:10 -040058 ansible.builtin.set_fact:
Mohammed Naserb7b97d62022-03-12 16:30:00 -050059 _ceph_rbd_csi_ceph_keyring: "{{ _ceph_key.stdout | from_json | first }}"
60
Mohammed Naser90f91b32023-01-16 22:59:52 +000061- name: Deploy Helm chart
62 run_once: true
63 kubernetes.core.helm:
64 name: "{{ ceph_csi_rbd_helm_release_name }}"
65 chart_ref: "{{ ceph_csi_rbd_helm_chart_ref }}"
66 release_namespace: "{{ ceph_csi_rbd_helm_release_namespace }}"
67 create_namespace: true
68 kubeconfig: /etc/kubernetes/admin.conf
69 values: "{{ _ceph_csi_rbd_helm_values | combine(ceph_csi_rbd_helm_values, recursive=True) }}"