forked from model-driven-devops/mdd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
play.sh
executable file
·41 lines (35 loc) · 1.04 KB
/
play.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env bash
IMAGE=ghcr.io/model-driven-devops/mdd:1.2.3
OPTIONS="--env ANSIBLE_PYTHON_INTERPRETER=/usr/bin/python3"
if [[ ! -z "$ANSIBLE_VAULT_PASSWORD_FILE" ]]; then
OPTIONS="--env ANSIBLE_VAULT_PASSWORD_FILE=/tmp/vault.pw -v $ANSIBLE_VAULT_PASSWORD_FILE:/tmp/vault.pw"
fi
OPTION_LIST=( \
"CML_HOST" \
"CML_USERNAME" \
"CML_PASSWORD" \
"CML_LAB" \
"CML_VERIFY_CERT" \
"ANSIBLE_INVENTORY" \
"NSO_URL" \
"NSO_USERNAME" \
"NSO_PASSWORD" \
)
for OPTION in ${OPTION_LIST[*]}; do
if [[ ! -z "${!OPTION}" ]]; then
OPTIONS="$OPTIONS --env $OPTION=${!OPTION}"
fi
done
while getopts ":sl" opt; do
case $opt in
s)
docker run -it --rm -v $PWD:/ansible --env PWD="/ansible" --env USER="$USER" $OPTIONS $IMAGE /bin/bash
exit
;;
l)
docker run -it --rm -v $PWD:/ansible --env PWD="/ansible" --env USER="$USER" $OPTIONS $IMAGE ansible-lint
exit
;;
esac
done
docker run -it --rm -v $PWD:/ansible --env PWD="/ansible" --env USER="$USER" $OPTIONS $IMAGE ansible-playbook "$@"