Fixing roles variable filtering when exists

This commit is contained in:
2022-09-30 20:39:41 +00:00
parent f26c9dc1a2
commit 69921b224f

View File

@@ -31,6 +31,7 @@ set | grep ROLES
DEBUG=1 DEBUG=1
fi; fi;
# finding IPv4 addresses from application names. # finding IPv4 addresses from application names.
name_resolver() { name_resolver() {
@@ -50,10 +51,10 @@ name_resolver() {
UPS="" UPS=""
for ROLE in $(echo $ROLES); do for ROLE in $(echo $ROLES); do
FILTERED_BY_ROLE=$(docker inspect $UP -f '{{.Config.Labels.roles}}' | uniq | grep $ROLE) FILTERED_BY_ROLE=$(docker inspect $UP -f '{{.Name}} {{.Config.Labels.roles}}' | uniq | grep $ROLE| awk '{print $1}')
if [[ "$(echo $FILTERED_BY_ROLE)" != "" ]]; then if [[ "$(echo $FILTERED_BY_ROLE)" != "" ]]; then
UPS="$UPS $UP"; UPS="$UPS $FILTERED_BY_ROLE";
fi fi
done done
UP=$UPS UP=$UPS
@@ -166,7 +167,6 @@ prerouting() {
postrouting() { postrouting() {
if [[ ! -z "$SOURCE_IP" ]]; then if [[ ! -z "$SOURCE_IP" ]]; then
SOURCE_IP_FOR_POSTROUTING="$(echo $SOURCE_IP | cut -d . -f1-3).0/24"; SOURCE_IP_FOR_POSTROUTING="$(echo $SOURCE_IP | cut -d . -f1-3).0/24";
debug "source ip is $SOURCE_IP_FOR_POSTROUTING" debug "source ip is $SOURCE_IP_FOR_POSTROUTING"