Patch __consul_* to discover remote consul configuration dir

This commit is contained in:
fnux 2020-01-21 10:07:21 +01:00
parent 70200cd28f
commit f595664924
18 changed files with 33 additions and 11 deletions

View file

@ -0,0 +1 @@
../../__consul_service/explorer/conf-dir

View file

@ -19,7 +19,7 @@
# #
name="$(cat "$__object/parameter/name" 2>/dev/null || echo "$__object_id")" name="$(cat "$__object/parameter/name" 2>/dev/null || echo "$__object_id")"
conf_dir="/etc/consul/conf.d" conf_dir=$(cat "$__object/explorer/conf-dir")
conf_file="check_${name}.json" conf_file="check_${name}.json"
state="$(cat "$__object/parameter/state")" state="$(cat "$__object/parameter/state")"

View file

@ -0,0 +1,15 @@
# Determine the configuration directory used by consul.
check_dir () {
if [ -d "$1" ]; then
echo -n "$1"
exit
fi
}
check_dir '/etc/consul/conf.d'
check_dir '/etc/consul.d'
check_dir '/etc/consul'
echo 'Could not determine consul configuration dir. Exiting.' >&2
exit 1

View file

@ -19,7 +19,7 @@
# #
name="$(cat "$__object/parameter/name" 2>/dev/null || echo "$__object_id")" name="$(cat "$__object/parameter/name" 2>/dev/null || echo "$__object_id")"
conf_dir="/etc/consul/conf.d" conf_dir=$(cat "$__object/explorer/conf-dir")
conf_file="service_${name}.json" conf_file="service_${name}.json"
state="$(cat "$__object/parameter/state")" state="$(cat "$__object/parameter/state")"
@ -45,7 +45,7 @@ printf ' "name": "%s"\n' "$name"
cd "$__object/parameter/" cd "$__object/parameter/"
for param in *; do for param in *; do
case "$param" in case "$param" in
state|name|check-interval) continue ;; state|name|check-interval|conf-dir) continue ;;
check-script) check-script)
printf ' ,"check": {\n' printf ' ,"check": {\n'
printf ' "script": "%s"\n' "$(cat "$__object/parameter/check-script")" printf ' "script": "%s"\n' "$(cat "$__object/parameter/check-script")"
@ -86,7 +86,6 @@ echo " }"
# end json file # end json file
echo "}" echo "}"
) | \ ) | \
require="__directory${conf_dir}" \
__config_file "${conf_dir}/${conf_file}" \ __config_file "${conf_dir}/${conf_file}" \
--owner root --group consul --mode 640 \ --owner root --group consul --mode 640 \
--state "$state" \ --state "$state" \

View file

@ -0,0 +1 @@
../../__consul_service/explorer/conf-dir

View file

@ -20,7 +20,7 @@
cdist_type="${__type##*/}" cdist_type="${__type##*/}"
watch_type="${cdist_type##*_}" watch_type="${cdist_type##*_}"
conf_dir="/etc/consul/conf.d" conf_dir=$(cat "$__object/explorer/conf-dir")
conf_file="watch_${watch_type}_${__object_id}.json" conf_file="watch_${watch_type}_${__object_id}.json"
state="$(cat "$__object/parameter/state")" state="$(cat "$__object/parameter/state")"

View file

@ -0,0 +1 @@
../../__consul_service/explorer/conf-dir

View file

@ -20,7 +20,7 @@
cdist_type="${__type##*/}" cdist_type="${__type##*/}"
watch_type="${cdist_type##*_}" watch_type="${cdist_type##*_}"
conf_dir="/etc/consul/conf.d" conf_dir=$(cat "$__object/explorer/conf-dir")
conf_file="watch_${watch_type}_${__object_id}.json" conf_file="watch_${watch_type}_${__object_id}.json"
state="$(cat "$__object/parameter/state")" state="$(cat "$__object/parameter/state")"

View file

@ -0,0 +1 @@
../../__consul_service/explorer/conf-dir

View file

@ -20,7 +20,7 @@
cdist_type="${__type##*/}" cdist_type="${__type##*/}"
watch_type="${cdist_type##*_}" watch_type="${cdist_type##*_}"
conf_dir="/etc/consul/conf.d" conf_dir=$(cat "$__object/explorer/conf-dir")
conf_file="watch_${watch_type}_${__object_id}.json" conf_file="watch_${watch_type}_${__object_id}.json"
state="$(cat "$__object/parameter/state")" state="$(cat "$__object/parameter/state")"

View file

@ -0,0 +1 @@
../../__consul_service/explorer/conf-dir

View file

@ -20,7 +20,7 @@
cdist_type="${__type##*/}" cdist_type="${__type##*/}"
watch_type="${cdist_type##*_}" watch_type="${cdist_type##*_}"
conf_dir="/etc/consul/conf.d" conf_dir=$(cat "$__object/explorer/conf-dir")
conf_file="watch_${watch_type}_${__object_id}.json" conf_file="watch_${watch_type}_${__object_id}.json"
state="$(cat "$__object/parameter/state")" state="$(cat "$__object/parameter/state")"

View file

@ -0,0 +1 @@
../../__consul_service/explorer/conf-dir

View file

@ -20,7 +20,7 @@
cdist_type="${__type##*/}" cdist_type="${__type##*/}"
watch_type="${cdist_type##*_}" watch_type="${cdist_type##*_}"
conf_dir="/etc/consul/conf.d" conf_dir=$(cat "$__object/explorer/conf-dir")
conf_file="watch_${watch_type}_${__object_id}.json" conf_file="watch_${watch_type}_${__object_id}.json"
state="$(cat "$__object/parameter/state")" state="$(cat "$__object/parameter/state")"

View file

@ -0,0 +1 @@
../../__consul_service/explorer/conf-dir

View file

@ -20,7 +20,7 @@
cdist_type="${__type##*/}" cdist_type="${__type##*/}"
watch_type="${cdist_type##*_}" watch_type="${cdist_type##*_}"
conf_dir="/etc/consul/conf.d" conf_dir=$(cat "$__object/explorer/conf-dir")
conf_file="watch_${watch_type}_${__object_id}.json" conf_file="watch_${watch_type}_${__object_id}.json"
state="$(cat "$__object/parameter/state")" state="$(cat "$__object/parameter/state")"

View file

@ -0,0 +1 @@
../../__consul_service/explorer/conf-dir

View file

@ -20,7 +20,7 @@
cdist_type="${__type##*/}" cdist_type="${__type##*/}"
watch_type="${cdist_type##*_}" watch_type="${cdist_type##*_}"
conf_dir="/etc/consul/conf.d" conf_dir=$(cat "$__object/explorer/conf-dir")
conf_file="watch_${watch_type}_${__object_id}.json" conf_file="watch_${watch_type}_${__object_id}.json"
state="$(cat "$__object/parameter/state")" state="$(cat "$__object/parameter/state")"