|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +source bootstrap-cluster.sh > /dev/null 2>&1 |
| 4 | + |
| 5 | +set +x |
| 6 | + |
| 7 | +show_help() { |
| 8 | + echo "Usage: ./quick-bootstrap.sh [OPTIONS]" |
| 9 | + echo "" |
| 10 | + echo "Options:" |
| 11 | + echo " -u, --use-cached-image Uses the existing podman image in local. Only use this if there is such an image present." |
| 12 | + echo " -dir, --ceph-dir Use this to provide the local ceph directory. eg. --ceph-dir=/path/to/ceph" |
| 13 | + echo " -e, --expanded-cluster To add all the hosts and deploy OSDs on top of it." |
| 14 | + echo " -h, --help Display this help message." |
| 15 | + echo "" |
| 16 | + echo "Example:" |
| 17 | + echo " ./quick-bootstrap.sh --use-cached-image" |
| 18 | +} |
| 19 | + |
| 20 | +use_cached_image=false |
| 21 | +extra_args="-P quick_install=True" |
| 22 | + |
| 23 | +for arg in "$@"; do |
| 24 | + case "$arg" in |
| 25 | + -u|--use-cached-image) |
| 26 | + use_cached_image=true |
| 27 | + ;; |
| 28 | + -dir=*|--ceph-dir=*) |
| 29 | + extra_args+=" -P ceph_dev_folder=${arg#*=}" |
| 30 | + ;; |
| 31 | + -e|--expanded-cluster) |
| 32 | + extra_args+=" -P expanded_cluster=True" |
| 33 | + ;; |
| 34 | + -h|--help) |
| 35 | + show_help |
| 36 | + exit 0 |
| 37 | + ;; |
| 38 | + *) |
| 39 | + echo "Unknown option: $arg" |
| 40 | + show_help |
| 41 | + exit 1 |
| 42 | + ;; |
| 43 | + esac |
| 44 | +done |
| 45 | + |
| 46 | +image_name=$(echo "$CEPHADM_IMAGE") |
| 47 | +ceph_cluster_yml='ceph_cluster.yml' |
| 48 | +node_count=$(awk '/nodes:/ {print $2}' "${ceph_cluster_yml}") |
| 49 | + |
| 50 | +if [[ ${use_cached_image} == false ]]; then |
| 51 | + printf "Pulling the image: %s\n" "$image_name" |
| 52 | + podman pull "${image_name}" |
| 53 | +fi |
| 54 | + |
| 55 | +rm -f ceph_image.tar |
| 56 | + |
| 57 | +printf "Saving the image: %s\n" "$image_name" |
| 58 | +podman save -o ceph_image.tar quay.ceph.io/ceph-ci/ceph:main |
| 59 | + |
| 60 | +printf "Creating the plan\n" |
| 61 | +kcli create plan -f ceph_cluster.yml ${extra_args} ceph |
| 62 | + |
| 63 | +attempt=0 |
| 64 | + |
| 65 | +MAX_ATTEMPTS=10 |
| 66 | +SLEEP_INTERVAL=5 |
| 67 | + |
| 68 | +printf "Waiting for the host to be reachable\n" |
| 69 | +while [[ ${attempt} -lt ${MAX_ATTEMPTS} ]]; do |
| 70 | + if ssh -o StrictHostKeyChecking=no -o BatchMode=yes -o ConnectTimeout=10 [email protected] exit; then |
| 71 | + break |
| 72 | + else |
| 73 | + echo "Waiting for ssh connection to be available..., attempt: ${attempt}" |
| 74 | + ((attempt++)) |
| 75 | + sleep ${SLEEP_INTERVAL} |
| 76 | + fi |
| 77 | +done |
| 78 | + |
| 79 | +printf "Copying the image to the hosts\n" |
| 80 | + |
| 81 | +for node in $(seq 0 $((node_count - 1))); do |
| 82 | + scp -o StrictHostKeyChecking=no ceph_image.tar [email protected]"${node}":/root/ |
| 83 | +done |
| 84 | + |
| 85 | +rm -f ceph_image.tar |
| 86 | +kcli ssh -u root -- ceph-node-00 'journalctl -n all -ft cloud-init' |
0 commit comments