blob: b8839ee389a15ab61b3472a26da3ad2fe647dc62 [file] [log] [blame]
# 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.helm:
name: ceph-csi-rbd
chart_ref: ceph/ceph-csi-rbd
chart_version: 3.5.1
release_namespace: kube-system
kubeconfig: /etc/kubernetes/admin.conf
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 }}"