forked from rht-labs/labs-ci-cd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·54 lines (44 loc) · 1.98 KB
/
run.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
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
######################################################################################
#
# The objective of this script is to:
# 1) make the docker run command easier to use.
# 2) run ansible-galaxy install if required roles are missing.
# 3) print ASCII art.
#
# Please do not introduce any other logic
#
######################################################################################
set -e
function printBanner(){
# fpr info on colors, see https://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux
LIGHT_BLUE='\033[1;34m'
GREEN='\033[0;32m'
RED='\033[0;31m'
WHITE='\033[1;37m'
NC='\033[0m'
printf "
${RED} _ _ ${LIGHT_BLUE} ____ ___ ${WHITE} __${GREEN} ____ ____ \n\
${RED}| | __ _| |__ ___ ${LIGHT_BLUE} / ___|_ _|${WHITE} / /${GREEN}/ ___| _ \ \n\
${RED}| | / _' | ' \/ __| ${LIGHT_BLUE}| | | | ${WHITE} / /${GREEN}| | | | | | \n\
${RED}| |__| (_| | |_) \__ \ ${LIGHT_BLUE}| |___ | | ${WHITE} / / ${GREEN}| |___| |_| | \n\
${RED}|_____\__,_|_.__/|___/ ${LIGHT_BLUE} \____|___|${WHITE}/_/ ${GREEN} \____|____/ \n\
\n\n${NC}"
}
###########################
# Begin Script #
###########################
printBanner
if [[ "$#" == 0 ]]; then
DOCKER_RUN_COMMAND='ansible-playbook -i /tmp/src/inventory /tmp/src/apply.yml -e target=bootstrap && ansible-playbook -i /tmp/src/inventory /tmp/src/apply.yml -e target=tools'
printf "no arguments passed to run.sh. using default docker run command:\n- $DOCKER_RUN_COMMAND\n\n"
else
DOCKER_RUN_COMMAND="$@"
printf "using arguments passed to run.sh for docker run command:\n\t$DOCKER_RUN_COMMAND\n\n"
fi
DOCKER_RUN_COMMAND="ansible-galaxy install -r /tmp/src/requirements.yml --roles-path=/tmp/src/roles && $DOCKER_RUN_COMMAND"
docker run --rm -i \
-v $(pwd):/tmp/src:z \
-v $HOME/.kube:/root/.kube:z \
-t redhatcop/openshift-applier:v3.9.0 \
/bin/sh -c "$DOCKER_RUN_COMMAND"