summaryrefslogtreecommitdiff
path: root/apply-role.sh
blob: 5af348d4b87a633cdcb518628fd77e84d8ad9298 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/bash

if [ -z "$1" ] || [ -z "$2" ]; then
  echo "$0 <host(s)> <role>"
  exit 1
fi
hosts="$1"
shift
role="$1"
shift

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"