From ee42cc8340f26be2316120a1434c5289d5927da2 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sat, 8 Dec 2018 16:53:43 +0100 Subject: improve handling of environment groups --- apply-role.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'apply-role.sh') 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 " +if [ -z "$1" ] || [ -z "$2" ]; then + echo "$0 " 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" -- cgit v1.2.3