| # Copyright (c) 2022 VEXXHOST, Inc. |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| # not use this file except in compliance with the License. You may obtain |
| # a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| # License for the specific language governing permissions and limitations |
| # under the License. |
| |
| - name: Collect "ceph mon dump" output from a monitor |
| delegate_to: "{{ groups[ceph_csi_rbd_mons_group][0] }}" |
| run_once: true |
| ansible.builtin.command: ceph mon dump -f json |
| changed_when: false |
| register: _ceph_mon_dump |
| |
| - name: Generate fact with list of Ceph monitors |
| run_once: true |
| ansible.builtin.set_fact: |
| ceph_monitors: "{{ _ceph_mon_dump.stdout | from_json | community.general.json_query('mons[*].addr') | map('regex_replace', '(.*):(.*)', '\\1') }}" |
| |
| - name: Create Ceph pool |
| delegate_to: "{{ groups[ceph_csi_rbd_mons_group][0] }}" |
| vexxhost.atmosphere.ceph_pool: |
| name: "{{ ceph_csi_rbd_pool }}" |
| rule_name: "{{ ceph_csi_rbd_rule_name | default(omit) }}" |
| application: rbd |
| pg_autoscale_mode: "on" |
| |
| - name: Create {{ ceph_csi_rbd_user }} user |
| delegate_to: "{{ groups[ceph_csi_rbd_mons_group][0] }}" |
| vexxhost.atmosphere.ceph_key: |
| name: "{{ ceph_csi_rbd_user }}" |
| caps: |
| mon: profile rbd |
| mgr: profile rbd pool={{ ceph_csi_rbd_pool }} |
| osd: profile rbd pool={{ ceph_csi_rbd_pool }} |
| |
| - name: Retrieve {{ ceph_csi_rbd_user }} keyring |
| delegate_to: "{{ groups[ceph_csi_rbd_mons_group][0] }}" |
| vexxhost.atmosphere.ceph_key: |
| name: "{{ ceph_csi_rbd_user }}" |
| state: info |
| output_format: json |
| register: _ceph_key |
| |
| - name: Store keyring inside fact |
| ansible.builtin.set_fact: |
| _ceph_rbd_csi_ceph_keyring: "{{ _ceph_key.stdout | from_json | first }}" |
| |
| - name: Deploy Helm chart |
| kubernetes.core.k8s: |
| state: present |
| definition: |
| - apiVersion: source.toolkit.fluxcd.io/v1beta2 |
| kind: HelmRepository |
| metadata: |
| name: ceph |
| namespace: kube-system |
| spec: |
| interval: 60s |
| url: https://ceph.github.io/csi-charts |
| |
| - apiVersion: helm.toolkit.fluxcd.io/v2beta1 |
| kind: HelmRelease |
| metadata: |
| name: ceph-csi-rbd |
| namespace: kube-system |
| spec: |
| interval: 60s |
| chart: |
| spec: |
| chart: ceph-csi-rbd |
| version: 3.5.1 |
| sourceRef: |
| kind: HelmRepository |
| name: ceph |
| values: |
| csiConfig: |
| - clusterID: "{{ ceph_csi_rbd_ceph_fsid }}" |
| monitors: "{{ ceph_monitors }}" |
| nodeplugin: |
| httpMetrics: |
| containerPort: 8081 |
| provisioner: |
| nodeSelector: |
| openstack-control-plane: enabled |
| storageClass: |
| create: true |
| name: general |
| annotations: |
| storageclass.kubernetes.io/is-default-class: "true" |
| clusterID: "{{ ceph_csi_rbd_ceph_fsid }}" |
| pool: "{{ ceph_csi_rbd_pool }}" |
| mountOptions: |
| - discard |
| secret: |
| create: true |
| userID: "{{ ceph_csi_rbd_id }}" |
| userKey: "{{ _ceph_rbd_csi_ceph_keyring.key }}" |