blob: b9237e857149f689e6b9c92cd8d84a602bff40ac [file] [log] [blame]
Mohammed Naserf3f59a72023-01-15 21:02:04 -05001#!/bin/bash
2
3{{/*
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/}}
16
17set -ex
18export HOME=/tmp
19
20cp -vf /etc/ceph/ceph.conf.template /etc/ceph/ceph.conf
21
22KEYRING=/etc/ceph/ceph.client.${CEPH_CINDER_USER}.keyring
23{{- if .Values.conf.ceph.cinder.keyring }}
24cat > ${KEYRING} <<EOF
25[client.{{ .Values.conf.ceph.cinder.user }}]
26 key = {{ .Values.conf.ceph.cinder.keyring }}
27EOF
28{{- else }}
29if ! [ "x${CEPH_CINDER_USER}" == "xadmin" ]; then
30 #
31 # If user is not client.admin, check if it already exists. If not create
32 # the user. If the cephx user does not exist make sure the caps are set
33 # according to best practices
34 #
35 if USERINFO=$(ceph auth get client.${CEPH_CINDER_USER}); then
36 echo "Cephx user client.${CEPH_CINDER_USER} already exist"
37 echo "Update user client.${CEPH_CINDER_USER} caps"
38 ceph auth caps client.${CEPH_CINDER_USER} \
39 mon "profile rbd" \
40 osd "profile rbd"
41 ceph auth get client.${CEPH_CINDER_USER} -o ${KEYRING}
42 else
43 echo "Creating Cephx user client.${CEPH_CINDER_USER}"
44 ceph auth get-or-create client.${CEPH_CINDER_USER} \
45 mon "profile rbd" \
46 osd "profile rbd" \
47 -o ${KEYRING}
48 fi
49 rm -f /etc/ceph/ceph.client.admin.keyring
50fi
51{{- end }}