Mohammed Naser | 90f91b3 | 2023-01-16 22:59:52 +0000 | [diff] [blame] | 1 | # Copyright (c) 2023 VEXXHOST, Inc. |
Mohammed Naser | b7b97d6 | 2022-03-12 16:30:00 -0500 | [diff] [blame] | 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 | |
guilhermesteinmuller | d946d7a | 2022-04-04 15:04:27 -0300 | [diff] [blame] | 15 | - name: Collect "ceph mon dump" output from a monitor |
| 16 | delegate_to: "{{ groups[ceph_csi_rbd_mons_group][0] }}" |
Mohammed Naser | b7b97d6 | 2022-03-12 16:30:00 -0500 | [diff] [blame] | 17 | run_once: true |
Rico Lin | e713267 | 2024-02-28 00:10:53 +0800 | [diff] [blame] | 18 | ansible.builtin.command: cephadm shell -- ceph mon dump -f json |
guilhermesteinmuller | d946d7a | 2022-04-04 15:04:27 -0300 | [diff] [blame] | 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: |
Mohammed Naser | 545bc43 | 2023-04-16 23:02:23 +0000 | [diff] [blame] | 25 | ceph_csi_rbd_ceph_fsid: "{{ _ceph_mon_dump.stdout | from_json | community.general.json_query('fsid') }}" |
guilhermesteinmuller | d946d7a | 2022-04-04 15:04:27 -0300 | [diff] [blame] | 26 | ceph_monitors: "{{ _ceph_mon_dump.stdout | from_json | community.general.json_query('mons[*].addr') | map('regex_replace', '(.*):(.*)', '\\1') }}" |
Mohammed Naser | b7b97d6 | 2022-03-12 16:30:00 -0500 | [diff] [blame] | 27 | |
Mohammed Naser | 511c3fa | 2022-03-17 17:54:10 -0400 | [diff] [blame] | 28 | - name: Create Ceph pool |
Mohammed Naser | 63b739d | 2022-05-19 21:51:31 -0400 | [diff] [blame] | 29 | delegate_to: "{{ groups[ceph_csi_rbd_mons_group][0] }}" |
Mohammed Naser | 90f91b3 | 2023-01-16 22:59:52 +0000 | [diff] [blame] | 30 | run_once: true |
Mohammed Naser | 545bc43 | 2023-04-16 23:02:23 +0000 | [diff] [blame] | 31 | vexxhost.ceph.pool: |
Mohammed Naser | b7b97d6 | 2022-03-12 16:30:00 -0500 | [diff] [blame] | 32 | name: "{{ ceph_csi_rbd_pool }}" |
Mohammed Naser | 63b739d | 2022-05-19 21:51:31 -0400 | [diff] [blame] | 33 | rule_name: "{{ ceph_csi_rbd_rule_name | default(omit) }}" |
Mohammed Naser | b7b97d6 | 2022-03-12 16:30:00 -0500 | [diff] [blame] | 34 | application: rbd |
Mohammed Naser | 511c3fa | 2022-03-17 17:54:10 -0400 | [diff] [blame] | 35 | pg_autoscale_mode: "on" |
Mohammed Naser | b7b97d6 | 2022-03-12 16:30:00 -0500 | [diff] [blame] | 36 | |
Mohammed Naser | 4b24d9b | 2022-11-02 13:14:52 -0400 | [diff] [blame] | 37 | - name: Create user {{ ceph_csi_rbd_user }} |
Mohammed Naser | 63b739d | 2022-05-19 21:51:31 -0400 | [diff] [blame] | 38 | delegate_to: "{{ groups[ceph_csi_rbd_mons_group][0] }}" |
Mohammed Naser | 90f91b3 | 2023-01-16 22:59:52 +0000 | [diff] [blame] | 39 | run_once: true |
Mohammed Naser | 545bc43 | 2023-04-16 23:02:23 +0000 | [diff] [blame] | 40 | vexxhost.ceph.key: |
Mohammed Naser | b7b97d6 | 2022-03-12 16:30:00 -0500 | [diff] [blame] | 41 | 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 Naser | 4b24d9b | 2022-11-02 13:14:52 -0400 | [diff] [blame] | 47 | - name: Retrieve keyring for {{ ceph_csi_rbd_user }} |
Mohammed Naser | 63b739d | 2022-05-19 21:51:31 -0400 | [diff] [blame] | 48 | delegate_to: "{{ groups[ceph_csi_rbd_mons_group][0] }}" |
Mohammed Naser | 90f91b3 | 2023-01-16 22:59:52 +0000 | [diff] [blame] | 49 | run_once: true |
Mohammed Naser | 545bc43 | 2023-04-16 23:02:23 +0000 | [diff] [blame] | 50 | vexxhost.ceph.key: |
Mohammed Naser | b7b97d6 | 2022-03-12 16:30:00 -0500 | [diff] [blame] | 51 | name: "{{ ceph_csi_rbd_user }}" |
| 52 | state: info |
| 53 | output_format: json |
| 54 | register: _ceph_key |
| 55 | |
Mohammed Naser | 511c3fa | 2022-03-17 17:54:10 -0400 | [diff] [blame] | 56 | - name: Store keyring inside fact |
Mohammed Naser | 90f91b3 | 2023-01-16 22:59:52 +0000 | [diff] [blame] | 57 | run_once: true |
Mohammed Naser | 511c3fa | 2022-03-17 17:54:10 -0400 | [diff] [blame] | 58 | ansible.builtin.set_fact: |
Mohammed Naser | b7b97d6 | 2022-03-12 16:30:00 -0500 | [diff] [blame] | 59 | _ceph_rbd_csi_ceph_keyring: "{{ _ceph_key.stdout | from_json | first }}" |
| 60 | |
Mohammed Naser | 90f91b3 | 2023-01-16 22:59:52 +0000 | [diff] [blame] | 61 | - 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) }}" |