Deploy with cephadm
Add the option to deploy the Ceph cluster with the cephadm tool. Co-Authored-By: Francesco Pantano <fpantano@redhat.com> Change-Id: Id2a704b136b9e47b7b88ef586282cb5d0f754cf1
This commit is contained in:
parent
b0418e177f
commit
cb0308877f
|
@ -0,0 +1,534 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# lib/cephadm
|
||||||
|
# Functions to control the configuration
|
||||||
|
# and operation of the **Ceph** storage service
|
||||||
|
# when deployed using the cephadm tool
|
||||||
|
|
||||||
|
# ``stack.sh`` calls the entry points in this order:
|
||||||
|
#
|
||||||
|
# - pre_install_ceph
|
||||||
|
# - install_ceph
|
||||||
|
# - configure_ceph
|
||||||
|
# - init_ceph
|
||||||
|
# - cleanup_ceph # unstack || clean
|
||||||
|
|
||||||
|
# Save trace setting
|
||||||
|
XTRACE=$(set +o | grep xtrace)
|
||||||
|
set +o xtrace
|
||||||
|
|
||||||
|
# GENERIC CEPHADM INTERNAL OPTIONS, DO NOT EDIT
|
||||||
|
CEPH_PUB_KEY="/etc/ceph/ceph.pub"
|
||||||
|
CONFIG="/etc/ceph/ceph.conf"
|
||||||
|
BOOTSTRAP_CONFIG="$HOME/bootstrap_ceph.conf"
|
||||||
|
KEYRING="/etc/ceph/ceph.client.admin.keyring"
|
||||||
|
REQUIREMENTS=("jq" "lvm" "python3")
|
||||||
|
TARGET_BIN=/usr/bin
|
||||||
|
|
||||||
|
# DEFAULT OPTIONS
|
||||||
|
ATTEMPTS=30
|
||||||
|
CONTAINER_IMAGE=${CONTAINER_IMAGE:-'quay.io/ceph/ceph:v16.2.7'}
|
||||||
|
DEVICES=()
|
||||||
|
FSID="4b5c8c0a-ff60-454b-a1b4-9747aa737d19"
|
||||||
|
KEY_EXPORT_DIR="/etc/ceph"
|
||||||
|
KEYS=("client.openstack") # at least the client.openstack default key should be created
|
||||||
|
MIN_OSDS=1
|
||||||
|
SERVICES=()
|
||||||
|
SLEEP=5
|
||||||
|
CEPHADM_DEV_OSD=${CEPHADM_DEV_OSD:-"True"}
|
||||||
|
CEPH_LOOPBACK_DISK_SIZE=${CEPH_LOOPBACK_DISK_SIZE:-8G}
|
||||||
|
|
||||||
|
# POOLS
|
||||||
|
# E.G. POOLS[test]='rbd'
|
||||||
|
declare -A POOLS
|
||||||
|
|
||||||
|
# NFS OPTIONS
|
||||||
|
FSNAME=${FSNAME:-'cephfs'}
|
||||||
|
NFS_PORT=12345
|
||||||
|
NFS_CLIENT=0
|
||||||
|
NFS_CLIENT_LOG="/var/log/ceph-$NFS_CLIENT_NAME.log"
|
||||||
|
NFS_CLIENT_NAME="client.manila"
|
||||||
|
|
||||||
|
# RGW OPTIONS
|
||||||
|
RGW_PORT=8080
|
||||||
|
|
||||||
|
# CLIENT CONFIG
|
||||||
|
CEPH_CLIENT_CONFIG=$HOME/ceph_client.conf
|
||||||
|
CEPH_CONF_DIR=${CEPH_CONF_DIR:-/etc/ceph}
|
||||||
|
# The resulting client config pointed by the other clients
|
||||||
|
CEPH_CONF_FILE=${CEPH_CONF_FILE:-$CEPH_CONF_DIR/ceph_client.conf}
|
||||||
|
|
||||||
|
EXPORT=$HOME/ceph_export.yml
|
||||||
|
RBD_CLIENT_LOG=/var/log/ceph/qemu-guest-$pid.log
|
||||||
|
|
||||||
|
# MANILA DEFAULT(s)
|
||||||
|
MANILA_CEPH_USER=${MANILA_CEPH_USER:-manila}
|
||||||
|
|
||||||
|
[ -z "$SUDO" ] && SUDO=sudo
|
||||||
|
|
||||||
|
## Admin
|
||||||
|
|
||||||
|
# Admin: enable debug mode
|
||||||
|
function set_debug {
|
||||||
|
if [ "$DEBUG" -eq 1 ]; then
|
||||||
|
echo "[CEPHADM] Enabling Debug mode"
|
||||||
|
$SUDO "$CEPHADM" shell --fsid $FSID --config $CONFIG \
|
||||||
|
--keyring $KEYRING -- ceph config set mgr mgr/cephadm/log_to_cluster_level debug
|
||||||
|
echo "[CEPHADM] See debug logs running: ceph -W cephadm --watch-debug"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Admin: check ceph cluster status
|
||||||
|
function check_cluster_status {
|
||||||
|
$SUDO "$CEPHADM" shell --fsid $FSID --config $CONFIG \
|
||||||
|
--keyring $KEYRING -- ceph -s -f json-pretty
|
||||||
|
}
|
||||||
|
|
||||||
|
# Admin: export ceph cluster config spec
|
||||||
|
function export_spec {
|
||||||
|
$SUDO "$CEPHADM" shell --fsid $FSID --config $CONFIG \
|
||||||
|
--keyring $KEYRING -- ceph orch ls --export > "$EXPORT"
|
||||||
|
echo "Ceph cluster config exported: $EXPORT"
|
||||||
|
}
|
||||||
|
|
||||||
|
## Pre-install
|
||||||
|
|
||||||
|
# Pre-install ceph: check depdendencies are available
|
||||||
|
function prereq {
|
||||||
|
for cmd in "${REQUIREMENTS[@]}"; do
|
||||||
|
if ! command -v "$cmd" &> /dev/null; then
|
||||||
|
echo "Command $cmd not found"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Pre-install ceph: install required dependencies
|
||||||
|
function install_deps {
|
||||||
|
install_package jq
|
||||||
|
# install_package podman
|
||||||
|
}
|
||||||
|
|
||||||
|
# Pre-install ceph: show cluster status
|
||||||
|
function preview {
|
||||||
|
echo "---------"
|
||||||
|
echo "SERVICES"
|
||||||
|
for daemon in "${SERVICES[@]}"; do
|
||||||
|
echo "* $daemon"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "---------"
|
||||||
|
echo "POOLS"
|
||||||
|
for key in "${!POOLS[@]}"; do
|
||||||
|
echo "* $key:${POOLS[$key]}";
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "---------"
|
||||||
|
echo "KEYS"
|
||||||
|
for kname in "${KEYS[@]}"; do
|
||||||
|
echo "* $kname";
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "---------"
|
||||||
|
echo "DEVICES"
|
||||||
|
for dev in "${DEVICES[@]}"; do
|
||||||
|
echo "* $dev"
|
||||||
|
done
|
||||||
|
[ -z "$DEVICES" ] && echo "Using ALL available devices"
|
||||||
|
|
||||||
|
echo "---------"
|
||||||
|
echo IP Address: "$HOST_IP"
|
||||||
|
echo "---------"
|
||||||
|
echo "Container Image: $CONTAINER_IMAGE"
|
||||||
|
echo "---------"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Pre-install ceph: get cephadm binary
|
||||||
|
function get_cephadm {
|
||||||
|
curl -O https://raw.githubusercontent.com/ceph/ceph/pacific/src/cephadm/cephadm
|
||||||
|
$SUDO mv cephadm $TARGET_BIN
|
||||||
|
$SUDO chmod +x $TARGET_BIN/cephadm
|
||||||
|
echo "[GET CEPHADM] cephadm is now available"
|
||||||
|
|
||||||
|
if [ -z "$CEPHADM" ]; then
|
||||||
|
CEPHADM=${TARGET_BIN}/cephadm
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Pre-install ceph: bootstrap config
|
||||||
|
function bootstrap_config {
|
||||||
|
cat <<EOF > "$BOOTSTRAP_CONFIG"
|
||||||
|
[global]
|
||||||
|
log to file = true
|
||||||
|
osd crush chooseleaf type = 0
|
||||||
|
osd_pool_default_pg_num = 8
|
||||||
|
osd_pool_default_pgp_num = 8
|
||||||
|
osd_pool_default_size = 1
|
||||||
|
[mon]
|
||||||
|
mon_warn_on_insecure_global_id_reclaim_allowed = False
|
||||||
|
mon_warn_on_pool_no_redundancy = False
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
# Install ceph: run cephadm bootstrap
|
||||||
|
function start_ceph {
|
||||||
|
cluster=$(sudo cephadm ls | jq '.[]' | jq 'select(.name | test("^mon*")).fsid')
|
||||||
|
if [ -z "$cluster" ]; then
|
||||||
|
$SUDO $CEPHADM --image "$CONTAINER_IMAGE" \
|
||||||
|
bootstrap \
|
||||||
|
--fsid $FSID \
|
||||||
|
--config "$BOOTSTRAP_CONFIG" \
|
||||||
|
--output-config $CONFIG \
|
||||||
|
--output-keyring $KEYRING \
|
||||||
|
--output-pub-ssh-key $CEPH_PUB_KEY \
|
||||||
|
--allow-overwrite \
|
||||||
|
--allow-fqdn-hostname \
|
||||||
|
--skip-monitoring-stack \
|
||||||
|
--skip-dashboard \
|
||||||
|
--single-host-defaults \
|
||||||
|
--skip-firewalld \
|
||||||
|
--mon-ip "$HOST_IP"
|
||||||
|
|
||||||
|
test -e $CONFIG
|
||||||
|
test -e $KEYRING
|
||||||
|
|
||||||
|
if [ "$CEPHADM_DEV_OSD" == 'True' ]; then
|
||||||
|
create_osd_dev
|
||||||
|
fi
|
||||||
|
# Wait cephadm backend to be operational
|
||||||
|
# and add osds via drivegroups
|
||||||
|
sleep "$SLEEP"
|
||||||
|
add_osds
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Install ceph: create a loopback device to be used as osd
|
||||||
|
function create_osd_dev {
|
||||||
|
sudo dd if=/dev/zero of=/var/lib/ceph-osd.img bs=1 count=0 seek="$CEPH_LOOPBACK_DISK_SIZE"
|
||||||
|
osd_dev=$(sudo losetup -f --show /var/lib/ceph-osd.img)
|
||||||
|
sudo pvcreate $osd_dev
|
||||||
|
sudo vgcreate ceph_vg $osd_dev
|
||||||
|
sudo lvcreate -n ceph_lv_data -l +100%FREE ceph_vg
|
||||||
|
DEVICES+=("/dev/ceph_vg/ceph_lv_data")
|
||||||
|
}
|
||||||
|
|
||||||
|
# cleanup ceph: delete the osd file and release the loopback device
|
||||||
|
function delete_osd_dev {
|
||||||
|
if [ $(sudo lvs --noheadings -o lv_path -S lv_name=ceph_lv_data) ]; then
|
||||||
|
sudo lvremove --force /dev/ceph_vg/ceph_lv_data
|
||||||
|
sudo vgremove --force ceph_vg
|
||||||
|
osd_dev=$(sudo losetup -j /var/lib/ceph-osd.img -l -n -O NAME)
|
||||||
|
sudo pvremove --force $osd_dev
|
||||||
|
sudo losetup -d $osd_dev
|
||||||
|
sudo rm -f /var/lib/ceph-osd.img
|
||||||
|
sudo partprobe
|
||||||
|
DEVICES=()
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Install ceph: add osds
|
||||||
|
function add_osds {
|
||||||
|
# let's add some osds
|
||||||
|
if [ -z "$DEVICES" ]; then
|
||||||
|
echo "Using ALL available devices"
|
||||||
|
$SUDO $CEPHADM shell ceph orch apply osd --all-available-devices
|
||||||
|
else
|
||||||
|
for item in "${DEVICES[@]}"; do
|
||||||
|
echo "Creating osd $item on node $HOSTNAME"
|
||||||
|
$SUDO "$CEPHADM" shell --fsid $FSID --config $CONFIG \
|
||||||
|
--keyring $KEYRING -- ceph orch daemon add osd "$HOSTNAME:$item"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
while [ "$ATTEMPTS" -ne 0 ]; do
|
||||||
|
num_osds=$($SUDO $CEPHADM shell --fsid $FSID --config $CONFIG \
|
||||||
|
--keyring $KEYRING -- ceph -s -f json | jq '.osdmap | .num_up_osds')
|
||||||
|
if [ "$num_osds" -ge "$MIN_OSDS" ]; then
|
||||||
|
break;
|
||||||
|
fi
|
||||||
|
ATTEMPTS=$(("$ATTEMPTS" - 1))
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
echo "[CEPHADM] OSD(s) deployed: $num_osds"
|
||||||
|
|
||||||
|
# [ "$num_osds" -lt "$MIN_OSDS" ] && exit 255
|
||||||
|
}
|
||||||
|
|
||||||
|
# Install ceph: create and enable pools
|
||||||
|
function add_pools {
|
||||||
|
# Pools are tied to their application, therefore the function
|
||||||
|
# iterates over the associative array that defines this relationship
|
||||||
|
# e.g. { 'volumes': 'rbd', 'manila_data': 'cephfs' }
|
||||||
|
|
||||||
|
[ "${#POOLS[@]}" -eq 0 ] && return;
|
||||||
|
|
||||||
|
for pool in "${!POOLS[@]}"; do
|
||||||
|
$SUDO "$CEPHADM" shell --fsid $FSID --config $CONFIG \
|
||||||
|
--keyring $KEYRING -- ceph osd pool create "$pool" "$DEFAULT_PG_NUM" \
|
||||||
|
"$DEFAULT_PGP_NUM" replicated --autoscale-mode on
|
||||||
|
|
||||||
|
# set the application to the pool (which also means rbd init the pool)
|
||||||
|
$SUDO "$CEPHADM" shell --fsid $FSID --config $CONFIG \
|
||||||
|
--keyring $KEYRING -- ceph osd pool application enable "$pool" "${POOLS[$pool]}"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Utility: build caps according to the generated pools
|
||||||
|
function build_caps {
|
||||||
|
local CAPS=""
|
||||||
|
for pool in "${!POOLS[@]}"; do
|
||||||
|
caps="allow rwx pool="$pool
|
||||||
|
CAPS+=$caps,
|
||||||
|
done
|
||||||
|
echo "${CAPS::-1}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Install ceph: create a keyring
|
||||||
|
function _create_key {
|
||||||
|
local name=$1
|
||||||
|
local caps
|
||||||
|
local osd_caps
|
||||||
|
|
||||||
|
if [ "${#POOLS[@]}" -eq 0 ]; then
|
||||||
|
osd_caps="allow *"
|
||||||
|
else
|
||||||
|
caps=$(build_caps)
|
||||||
|
osd_caps="allow class-read object_prefix rbd_children, $caps"
|
||||||
|
fi
|
||||||
|
|
||||||
|
$SUDO "$CEPHADM" shell -v "$KEY_EXPORT_DIR:$KEY_EXPORT_DIR" --fsid $FSID --config $CONFIG \
|
||||||
|
--keyring $KEYRING -- ceph auth get-or-create "$name" mgr "allow rw" mon "allow r" osd "$osd_caps" \
|
||||||
|
-o "$KEY_EXPORT_DIR/$name.keyring"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Install ceph: create one or more keyrings
|
||||||
|
function create_keys {
|
||||||
|
for key_name in "${KEYS[@]}"; do
|
||||||
|
echo "Creating key $key_name"
|
||||||
|
_create_key "$key_name"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Install ceph: add MDS
|
||||||
|
function cephfs_config {
|
||||||
|
# Two pools are generated by this action
|
||||||
|
# - $FSNAME.FSNAME.data
|
||||||
|
# - $FSNAME.FSNAME.meta
|
||||||
|
$SUDO "$CEPHADM" shell --fsid $FSID --config $CONFIG \
|
||||||
|
--keyring $KEYRING -- ceph fs volume create "$FSNAME"
|
||||||
|
if [[ ${CEPHFS_MULTIPLE_FILESYSTEMS} == 'True' ]]; then
|
||||||
|
$SUDO "$CEPHADM" shell --fsid $FSID --config $CONFIG \
|
||||||
|
--keyring $KEYRING -- ceph fs flag set enable_multiple true \
|
||||||
|
--yes-i-really-mean-it
|
||||||
|
# Enable snapshots in CephFS.
|
||||||
|
$SUDO "$CEPHADM" shell --fsid $FSID --config $CONFIG \
|
||||||
|
--keyring $KEYRING -- ceph fs set $FSNAME allow_new_snaps true \
|
||||||
|
--yes-i-really-mean-it
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Install ceph: add NFS
|
||||||
|
function ceph_nfs_config {
|
||||||
|
# (fpantano) TODO: Build an ingress daemon on top of this
|
||||||
|
echo "[CEPHADM] Deploy nfs.$FSNAME backend"
|
||||||
|
$SUDO "$CEPHADM" shell --fsid $FSID --config $CONFIG \
|
||||||
|
--keyring $KEYRING -- ceph orch apply nfs \
|
||||||
|
"$FSNAME" --placement="$HOSTNAME" --port $NFS_PORT
|
||||||
|
}
|
||||||
|
|
||||||
|
# RGW pre config
|
||||||
|
function configure_ceph_embedded_rgw {
|
||||||
|
|
||||||
|
# keystone endpoint for radosgw
|
||||||
|
_create_swift_endpoint
|
||||||
|
|
||||||
|
# Create radosgw service user with admin privileges
|
||||||
|
create_service_user "radosgw" "admin"
|
||||||
|
|
||||||
|
if [ "$CEPH_RGW_KEYSTONE_SSL" = "True" ]; then
|
||||||
|
# radosgw needs to access keystone's revocation list
|
||||||
|
sudo mkdir -p ${dest}/nss
|
||||||
|
sudo openssl x509 -in /etc/keystone/ssl/certs/ca.pem -pubkey | \
|
||||||
|
sudo certutil -d ${dest}/nss -A -n ca -t "TCu,Cu,Tuw"
|
||||||
|
|
||||||
|
sudo openssl x509 -in /etc/keystone/ssl/certs/signing_cert.pem -pubkey | \
|
||||||
|
sudo certutil -A -d ${dest}/nss -n signing_cert -t "P,P,P"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# General Ceph utility to set config keys within the mgr
|
||||||
|
function set_config_key {
|
||||||
|
local section=$1
|
||||||
|
local key=$2
|
||||||
|
local value=$3
|
||||||
|
$SUDO "$CEPHADM" shell --fsid $FSID --config $CONFIG \
|
||||||
|
ceph config set ${section} ${key} ${value}
|
||||||
|
}
|
||||||
|
|
||||||
|
# RGW config keys: no iniset anymore, everything is pushed as mgr key/value
|
||||||
|
function configure_rgw_ceph_section {
|
||||||
|
|
||||||
|
# RGW KEYSTONE KEYS
|
||||||
|
declare -A RGW_CONFIG_KEYS
|
||||||
|
|
||||||
|
RGW_CONFIG_KEYS=(['rgw_keystone_api_version']=3
|
||||||
|
['rgw_keystone_url']="$KEYSTONE_SERVICE_URI"
|
||||||
|
['rgw_keystone_accepted_roles']="member, _member_, Member, admin"
|
||||||
|
['rgw_keystone_accepted_admin_roles']="ResellerAdmin"
|
||||||
|
['rgw_keystone_admin_domain']="$SERVICE_DOMAIN_NAME"
|
||||||
|
['rgw_keystone_admin_project']="$SERVICE_PROJECT_NAME"
|
||||||
|
['rgw_keystone_admin_user']="radosgw"
|
||||||
|
['rgw_s3_auth_use_keystone']="true"
|
||||||
|
['rgw_keystone_admin_password']="$SERVICE_PASSWORD"
|
||||||
|
['rgw_keystone_verify_ssl']="false"
|
||||||
|
)
|
||||||
|
|
||||||
|
for k in ${!RGW_CONFIG_KEYS[@]}; do
|
||||||
|
set_config_key "global" ${k} ${RGW_CONFIG_KEYS[$k]}
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Install ceph: add RGW
|
||||||
|
function start_ceph_embedded_rgw {
|
||||||
|
$SUDO "$CEPHADM" shell --fsid $FSID --config $CONFIG \
|
||||||
|
--keyring $KEYRING -- ceph orch apply rgw default default default \
|
||||||
|
"--placement=$HOSTNAME count:1" --port "$RGW_PORT"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Configure cephfs and ceph_nfs
|
||||||
|
function configure_ceph_manila {
|
||||||
|
# Deploy mds and configure cephfs
|
||||||
|
cephfs_config
|
||||||
|
# Deploy and configure ganesha
|
||||||
|
[ $MANILA_CEPH_DRIVER == 'cephfsnfs' ] && ceph_nfs_config
|
||||||
|
# Add manila keys to the list
|
||||||
|
KEYS+=('client.manila')
|
||||||
|
}
|
||||||
|
|
||||||
|
# Install ceph: services deployment
|
||||||
|
function enable_services {
|
||||||
|
for item in "${SERVICES[@]}"; do
|
||||||
|
case "$item" in
|
||||||
|
cephfs|CEPHFS)
|
||||||
|
echo "[CEPHADM] Config cephfs volume on node $HOSTNAME"
|
||||||
|
cephfs_config
|
||||||
|
;;
|
||||||
|
nfs|NFS)
|
||||||
|
echo "[CEPHADM] Deploying NFS on node $HOSTNAME"
|
||||||
|
ceph_nfs_config
|
||||||
|
NFS_CLIENT=1
|
||||||
|
;;
|
||||||
|
rgw|RGW)
|
||||||
|
echo "[CEPHADM] Deploying RGW on node $HOSTNAME"
|
||||||
|
rgw
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Install ceph: client config
|
||||||
|
function client_config {
|
||||||
|
echo "Dump the minimal ceph.conf"
|
||||||
|
cp $CONFIG "$CEPH_CLIENT_CONFIG"
|
||||||
|
|
||||||
|
cat >> "$CEPH_CLIENT_CONFIG" <<-EOF
|
||||||
|
[client.libvirt]
|
||||||
|
admin socket = /var/run/ceph/$cluster-$type.$id.$pid.$cctid.asok
|
||||||
|
log file = $RBD_CLIENT_LOG
|
||||||
|
EOF
|
||||||
|
|
||||||
|
if [ "$NFS_CLIENT" -eq 1 ]; then
|
||||||
|
cat >> "$CEPH_CLIENT_CONFIG" <<-EOF
|
||||||
|
[$NFS_CLIENT_NAME]
|
||||||
|
client mount uid = 0
|
||||||
|
client mount gid = 0
|
||||||
|
log file = $NFS_CLIENT_LOG
|
||||||
|
admin socket = /var/run/ceph/\$cluster-\$type.\$id.\$pid.\$cctid.asok
|
||||||
|
keyring = $KEY_EXPORT_DIR/$NFS_CLIENT_NAME.keyring
|
||||||
|
EOF
|
||||||
|
echo "Client config exported: $CEPH_CLIENT_CONFIG"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Copy client config in /etc/ceph: this will be used
|
||||||
|
# later in the process, by the OpenStack services
|
||||||
|
$SUDO cp $CEPH_CLIENT_CONFIG $CEPH_CONF_DIR 2>/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
## Remove ceph
|
||||||
|
|
||||||
|
# Remove ceph: remove cluster and zap osds
|
||||||
|
function stop_ceph {
|
||||||
|
if ! [ -x "$CEPHADM" ]; then
|
||||||
|
get_cephadm
|
||||||
|
CEPHADM=${TARGET_BIN}/cephadm
|
||||||
|
fi
|
||||||
|
cluster=$(sudo cephadm ls | jq '.[]' | jq 'select(.name | test("^mon*")).fsid')
|
||||||
|
if [ -n "$cluster" ]; then
|
||||||
|
sudo cephadm rm-cluster --zap-osds --fsid "$FSID" --force
|
||||||
|
echo "[CEPHADM] Cluster deleted"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
## devstack-plugin-ceph functions
|
||||||
|
|
||||||
|
function pre_install_ceph {
|
||||||
|
# Check dependencies for the service.
|
||||||
|
install_deps
|
||||||
|
prereq
|
||||||
|
}
|
||||||
|
|
||||||
|
function install_ceph {
|
||||||
|
# Install the service.
|
||||||
|
bootstrap_config
|
||||||
|
get_cephadm
|
||||||
|
start_ceph
|
||||||
|
}
|
||||||
|
|
||||||
|
function configure_ceph {
|
||||||
|
[ "$ENABLE_CEPH_MANILA" == "True" ] && { SERVICES+=('cephfs'); KEYS+=('client.manila'); }
|
||||||
|
[ "$MANILA_CEPH_DRIVER" == "cephfsnfs" ] && SERVICES+=('nfs')
|
||||||
|
enable_services
|
||||||
|
add_pools
|
||||||
|
create_keys
|
||||||
|
client_config
|
||||||
|
}
|
||||||
|
|
||||||
|
# Hack: remove this function at some point
|
||||||
|
function configure_ceph_manila {
|
||||||
|
# noop
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
function cleanup_ceph {
|
||||||
|
# Cleanup the service.
|
||||||
|
stop_ceph
|
||||||
|
delete_osd_dev
|
||||||
|
}
|
||||||
|
|
||||||
|
# is_ceph_enabled_for_service() - checks whether the OpenStack service
|
||||||
|
# specified as an argument is enabled with Ceph as its storage backend.
|
||||||
|
function is_ceph_enabled_for_service {
|
||||||
|
local config config_name enabled service
|
||||||
|
enabled=1
|
||||||
|
service=$1
|
||||||
|
# Construct the global variable ENABLE_CEPH_.* corresponding to a
|
||||||
|
# $service.
|
||||||
|
config_name=ENABLE_CEPH_$(echo $service | \
|
||||||
|
tr '[:lower:]' '[:upper:]' | tr '-' '_')
|
||||||
|
config=$(eval echo "\$$config_name")
|
||||||
|
|
||||||
|
if (is_service_enabled $service) && [[ $config == 'True' ]]; then
|
||||||
|
enabled=0
|
||||||
|
fi
|
||||||
|
return $enabled
|
||||||
|
}
|
||||||
|
|
||||||
|
# Restore xtrace
|
||||||
|
$XTRACE
|
||||||
|
|
||||||
|
# Tell emacs to use shell-script-mode
|
||||||
|
## Local variables:
|
||||||
|
## mode: shell-script
|
||||||
|
## End:
|
|
@ -18,3 +18,5 @@ if [[ $ENABLE_CEPH_CINDER == "True" ]]; then
|
||||||
CINDER_ENABLED_BACKENDS=${CINDER_ENABLED_BACKENDS:-ceph}
|
CINDER_ENABLED_BACKENDS=${CINDER_ENABLED_BACKENDS:-ceph}
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
CEPHADM_DEPLOY=$(trueorfalse False CEPHADM_DEPLOY)
|
||||||
|
|
|
@ -2,13 +2,22 @@
|
||||||
|
|
||||||
if [[ "$1" == "source" ]]; then
|
if [[ "$1" == "source" ]]; then
|
||||||
# Initial source
|
# Initial source
|
||||||
|
if [[ "$CEPHADM_DEPLOY" = "True" ]]; then
|
||||||
|
source $TOP_DIR/lib/cephadm
|
||||||
|
else
|
||||||
source $TOP_DIR/lib/ceph
|
source $TOP_DIR/lib/ceph
|
||||||
|
fi
|
||||||
elif [[ "$1" == "stack" && "$2" == "pre-install" ]]; then
|
elif [[ "$1" == "stack" && "$2" == "pre-install" ]]; then
|
||||||
if [[ "$ENABLE_CEPH_RGW" = "True" ]] && (is_service_enabled swift); then
|
if [[ "$ENABLE_CEPH_RGW" = "True" ]] && (is_service_enabled swift); then
|
||||||
die $LINENO \
|
die $LINENO \
|
||||||
"You cannot activate both Swift and Ceph Rados Gateway, \
|
"You cannot activate both Swift and Ceph Rados Gateway, \
|
||||||
please disable Swift or set ENABLE_CEPH_RGW=False"
|
please disable Swift or set ENABLE_CEPH_RGW=False"
|
||||||
fi
|
fi
|
||||||
|
if [[ "$CEPHADM_DEPLOY" = "True" ]]; then
|
||||||
|
# Set up system services
|
||||||
|
echo_summary "[cephadm] Configuring system services ceph"
|
||||||
|
pre_install_ceph
|
||||||
|
else
|
||||||
echo_summary "Installing Ceph"
|
echo_summary "Installing Ceph"
|
||||||
check_os_support_ceph
|
check_os_support_ceph
|
||||||
if [ "$REMOTE_CEPH" = "False" ]; then
|
if [ "$REMOTE_CEPH" = "False" ]; then
|
||||||
|
@ -29,7 +38,13 @@ elif [[ "$1" == "stack" && "$2" == "pre-install" ]]; then
|
||||||
else
|
else
|
||||||
install_ceph_remote
|
install_ceph_remote
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
elif [[ "$1" == "stack" && "$2" == "install" ]]; then
|
elif [[ "$1" == "stack" && "$2" == "install" ]]; then
|
||||||
|
if [[ "$CEPHADM_DEPLOY" = "True" ]]; then
|
||||||
|
# Perform installation of service source
|
||||||
|
echo_summary "[cephadm] Installing ceph"
|
||||||
|
install_ceph
|
||||||
|
else
|
||||||
# FIXME(melwitt): This is a hack to get around a namespacing issue with
|
# FIXME(melwitt): This is a hack to get around a namespacing issue with
|
||||||
# Paste and PasteDeploy. For stable/queens, we use the Pike UCA packages
|
# Paste and PasteDeploy. For stable/queens, we use the Pike UCA packages
|
||||||
# and the Ceph packages in the Pike UCA are pulling in python-paste and
|
# and the Ceph packages in the Pike UCA are pulling in python-paste and
|
||||||
|
@ -41,7 +56,13 @@ elif [[ "$1" == "stack" && "$2" == "install" ]]; then
|
||||||
if [[ "$TARGET_BRANCH" == stable/queens || "$TARGET_BRANCH" == master ]]; then
|
if [[ "$TARGET_BRANCH" == stable/queens || "$TARGET_BRANCH" == master ]]; then
|
||||||
pip_install -U --force PasteDeploy
|
pip_install -U --force PasteDeploy
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
|
elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
|
||||||
|
if [[ "$CEPHADM_DEPLOY" = "True" ]]; then
|
||||||
|
# Configure after the other layer 1 and 2 services have been configured
|
||||||
|
echo_summary "[cephadm] Configuring additional Ceph services"
|
||||||
|
configure_ceph
|
||||||
|
else
|
||||||
if is_ceph_enabled_for_service glance; then
|
if is_ceph_enabled_for_service glance; then
|
||||||
echo_summary "Configuring Glance for Ceph"
|
echo_summary "Configuring Glance for Ceph"
|
||||||
configure_ceph_glance
|
configure_ceph_glance
|
||||||
|
@ -92,6 +113,7 @@ elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
elif [[ "$1" == "stack" && "$2" == "test-config" ]]; then
|
elif [[ "$1" == "stack" && "$2" == "test-config" ]]; then
|
||||||
if is_service_enabled tempest; then
|
if is_service_enabled tempest; then
|
||||||
iniset $TEMPEST_CONFIG compute-feature-enabled swap_volume False
|
iniset $TEMPEST_CONFIG compute-feature-enabled swap_volume False
|
||||||
|
@ -123,6 +145,9 @@ fi
|
||||||
|
|
||||||
|
|
||||||
if [[ "$1" == "unstack" ]]; then
|
if [[ "$1" == "unstack" ]]; then
|
||||||
|
if [[ "$CEPHADM_DEPLOY" = "True" ]]; then
|
||||||
|
cleanup_ceph
|
||||||
|
else
|
||||||
if [ "$CEPH_CONTAINERIZED" = "False" ]; then
|
if [ "$CEPH_CONTAINERIZED" = "False" ]; then
|
||||||
if [ "$REMOTE_CEPH" = "True" ]; then
|
if [ "$REMOTE_CEPH" = "True" ]; then
|
||||||
cleanup_ceph_remote
|
cleanup_ceph_remote
|
||||||
|
@ -134,13 +159,18 @@ if [[ "$1" == "unstack" ]]; then
|
||||||
cleanup_containerized_ceph
|
cleanup_containerized_ceph
|
||||||
fi
|
fi
|
||||||
cleanup_ceph_general
|
cleanup_ceph_general
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$1" == "clean" ]]; then
|
if [[ "$1" == "clean" ]]; then
|
||||||
|
if [[ "$CEPHADM_DEPLOY" = "True" ]]; then
|
||||||
|
cleanup_ceph
|
||||||
|
else
|
||||||
if [ "$REMOTE_CEPH" = "True" ]; then
|
if [ "$REMOTE_CEPH" = "True" ]; then
|
||||||
cleanup_ceph_remote
|
cleanup_ceph_remote
|
||||||
else
|
else
|
||||||
cleanup_ceph_embedded
|
cleanup_ceph_embedded
|
||||||
fi
|
fi
|
||||||
cleanup_ceph_general
|
cleanup_ceph_general
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -23,8 +23,13 @@ CEPH_LOOPBACK_DISK_SIZE=${CEPH_LOOPBACK_DISK_SIZE:-$VOLUME_BACKING_FILE_SIZE}
|
||||||
# Disable manage/unmanage snapshot tests on Tempest
|
# Disable manage/unmanage snapshot tests on Tempest
|
||||||
TEMPEST_VOLUME_MANAGE_SNAPSHOT=False
|
TEMPEST_VOLUME_MANAGE_SNAPSHOT=False
|
||||||
|
|
||||||
# Source plugin's lib/ceph
|
# Source plugin's lib/cephadm or lib/ceph
|
||||||
source $CEPH_PLUGIN_DIR/lib/ceph
|
# depending on chosen deployment method
|
||||||
|
if [[ "$CEPHADM_DEPLOY" = "True" ]]; then
|
||||||
|
source $CEPH_PLUGIN_DIR/lib/cephadm
|
||||||
|
else
|
||||||
|
source $CEPH_PLUGIN_DIR/lib/ceph
|
||||||
|
fi
|
||||||
|
|
||||||
# Set Manila related global variables used by Manila's DevStack plugin.
|
# Set Manila related global variables used by Manila's DevStack plugin.
|
||||||
if (is_ceph_enabled_for_service manila); then
|
if (is_ceph_enabled_for_service manila); then
|
||||||
|
|
Loading…
Reference in New Issue