summaryrefslogtreecommitdiff
path: root/apply-role.sh
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2018-12-08 16:53:43 +0100
committerChristian Pointner <equinox@spreadspace.org>2018-12-08 16:53:43 +0100
commitee42cc8340f26be2316120a1434c5289d5927da2 (patch)
tree638ec7b167869c730fd7398a35118c330644276e /apply-role.sh
parentstrip old and not yet used hosts (diff)
improve handling of environment groups
Diffstat (limited to 'apply-role.sh')
-rwxr-xr-xapply-role.sh16
1 files changed, 10 insertions, 6 deletions
diff --git a/apply-role.sh b/apply-role.sh
index a2b0ac4f..5af348d4 100755
--- a/apply-role.sh
+++ b/apply-role.sh
@@ -1,15 +1,19 @@
#!/bin/bash
-if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ] ; then
- echo "$0 <environment> <host(s)> <role>"
+if [ -z "$1" ] || [ -z "$2" ]; then
+ echo "$0 <host(s)> <role>"
exit 1
fi
-env="$1"
-shift
hosts="$1"
shift
role="$1"
shift
-echo "######## applying the role '$role' to host(s) '$hosts' in environment '$env' ########"
-exec ansible-playbook -e "myhosts=$hosts" -e "myrole=$role" $@ "$env/generic.yaml"
+source "${BASH_SOURCE%/*}/common/utils.sh"
+get_ansible_variable env_group "$hosts"
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+
+echo "######## applying the role '$role' to host(s) '$hosts' in environment '$env_group' ########"
+exec ansible-playbook -e "myhosts=$hosts" -e "myrole=$role" $@ "$env_group/generic.yaml"