diff options
Diffstat (limited to 'bin/ceph-dns')
-rwxr-xr-x | bin/ceph-dns | 82 |
1 files changed, 61 insertions, 21 deletions
diff --git a/bin/ceph-dns b/bin/ceph-dns index 4bf7a8f..59c5150 100755 --- a/bin/ceph-dns +++ b/bin/ceph-dns @@ -3,6 +3,8 @@ # storage-tools - Additional utilities to manage storage related tasks # Copyright (C) 2014-2017 Daniel Baumann <daniel.baumann@open-infrastructure.net> # +# SPDX-License-Identifier: GPL-3.0+ +# # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or @@ -22,7 +24,7 @@ PROGRAM="$(basename ${0})" Parameters () { - GETOPT_LONGOPTIONS="number:,release:,zone:,with-reverse,with-round-robin,master:,mds:,mgr:,mon:,osd:,rgw:," + GETOPT_LONGOPTIONS="number:,release:,zone:,ipv4-address:,with-reverse,with-round-robin,master:,mds:,mgr:,mon:,osd:,rgw:," GETOPT_OPTIONS="n:,r:,z:,f:," PARAMETERS="$(getopt --longoptions ${GETOPT_LONGOPTIONS} --name=${PROGRAM} --options ${GETOPT_OPTIONS} --shell sh -- ${@})" @@ -53,6 +55,11 @@ Parameters () shift 2 ;; + --ipv4-address) + IPV4_ADDRESS="${2}" + shift 2 + ;; + --with-reverse) WITH_REVERSE="true" shift 1 @@ -108,7 +115,7 @@ Parameters () Usage () { - echo "Usage: ${PROGRAM} {create|check} [-n|--number NUMBER] [-r|--release RELEASE] [-z|--zone ZONE] [--with-reverse] [--with-round-robin] [--master MASTER_NUMBER] [--mds MDS_NUMBER] [--mgr MGR_NUMBER] [--mon MON_NUMBER] [--osd OSD_NUMBER] [--rgw RGW_NUMBER]" >&2 + echo "Usage: ${PROGRAM} {create|check} [-n|--number NUMBER] [-r|--release RELEASE] [-z|--zone ZONE|none] [--ipv4-address IPV4_ADDRESS] [--with-reverse] [--with-round-robin] [--master MASTER_NUMBER] [--mds MDS_NUMBER] [--mgr MGR_NUMBER] [--mon MON_NUMBER] [--osd OSD_NUMBER] [--rgw RGW_NUMBER]" >&2 exit 1 } @@ -132,7 +139,22 @@ Parameters "${@}" NUMBER="${NUMBER:-3}" RELEASE="${RELEASE:-luminous}" -ZONE="${ZONE:-ceph.example.net}" + +case "${ZONE}" in + "") + ZONE=".ceph.example.net." + ;; + + none) + ZONE="" + ;; + + *) + ZONE=".${ZONE}" + ;; +esac + +IPV4_ADDRESS="${IPV4_ADDRESS:-10.0.0.11}" MASTER="${MASTER:-1}" MDS="${MDS:-${NUMBER}}" @@ -151,19 +173,24 @@ STATUS_BAD="${RED}✘${NORMAL}" STATUS_UGLY="${WHITE}○${NORMAL}" cat << EOF -; Ceph DNS: Forward Entries for ${ZONE} +; Ceph DNS: Forward Entries EOF # Run forward zone -for SERVICE in master mds mgr mon osd rgw +for SERVICE in master mon mgr mds rgw osd do NUMBERS="$(eval "echo \$$(echo "${SERVICE}" | tr [a-z] [A-Z])")" + if [ -z "${NUMBERS}" ] + then + continue + fi + for NUMBER in $(seq 1 ${NUMBERS}) do case "${SERVICE}" in master) - CONTAINER="master" + CONTAINER="${SERVICE}" ;; *) @@ -173,7 +200,7 @@ do case "${CHECK}" in true) - IP_ADDRESS="$(dig +short ${CONTAINER}.${RELEASE}.${ZONE} | tail -n1)" + IP_ADDRESS="$(dig +short ${CONTAINER}.${RELEASE}${ZONE} | tail -n1)" if [ -n "${IP_ADDRESS}" ] then @@ -182,34 +209,42 @@ do IP_ADDRESS="${STATUS_BAD}" fi ;; - - *) - IP_ADDRESS="FIXME" - ;; esac + case "${SERVICE}" in + master) + cat << EOF -${CONTAINER}.${RELEASE}.${ZONE} IN A ${IP_ADDRESS} -${CONTAINER}.${ZONE} IN CNAME ${CONTAINER}.${RELEASE}.${ZONE}. +${CONTAINER}${ZONE} IN A ${IP_ADDRESS} +dashboard${ZONE} IN CNAME master${ZONE} +${ZONE} IN A ${IP_ADDRESS} EOF - case "${SERVICE}" in - master) ;; *) + +cat << EOF + +${CONTAINER}.${RELEASE}${ZONE} IN A ${IP_ADDRESS} +${CONTAINER}${ZONE} IN CNAME ${CONTAINER}.${RELEASE}${ZONE} +EOF + + if [ "${WITH_ROUND_ROBIN}" = "true" ] then cat << EOF -${SERVICE}.${RELEASE}.${ZONE} IN A ${IP_ADDRESS} -${SERVICE}.${ZONE} IN A ${IP_ADDRESS} +${SERVICE}.${RELEASE}${ZONE} IN A ${IP_ADDRESS} +${SERVICE}${ZONE} IN A ${IP_ADDRESS} EOF fi ;; esac + + IP_ADDRESS="$((${IP_ADDRESS} + 1))" done done @@ -218,15 +253,20 @@ case "${WITH_REVERSE}" in cat << EOF -; Ceph DNS: Reverse Entries for ${ZONE} +; Ceph DNS: Reverse Entries EOF # Run reverse zone - for SERVICE in master mds mgr mon osd rgw + for SERVICE in master mon mgr mds rgw osd do NUMBERS="$(eval "echo \$$(echo "${SERVICE}" | tr [a-z] [A-Z])")" + if [ -z "${NUMBERS}" ] + then + continue + fi + for NUMBER in $(seq 1 ${NUMBERS}) do case "${SERVICE}" in @@ -241,7 +281,7 @@ EOF case "${CHECK}" in true) - IP_ADDRESS="$(dig +short ${CONTAINER}.${RELEASE}.${ZONE} | tail -n1)" + IP_ADDRESS="$(dig +short ${CONTAINER}.${RELEASE}${ZONE} | tail -n1)" if [ -n "${IP_ADDRESS}" ] then @@ -263,7 +303,7 @@ EOF esac cat << EOF -${IP_ADDRESS} IN PTR ${CONTAINER}.${RELEASE}.${ZONE}. ${STATUS} +${IP_ADDRESS} IN PTR ${CONTAINER}.${RELEASE}${ZONE} ${STATUS} EOF done |