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

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

cd "${BASH_SOURCE%/*}"
source common/utils.sh
ansible_variable__get env_group "$hosts" || exit 1
vault_environment__set "$env_group" || exit 1

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.yml"