-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathup
executable file
·56 lines (49 loc) · 1.21 KB
/
up
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
53
54
55
#!/bin/bash
# Brings up Ansible to install the Kubernetes environment.
## Check the dependencies before running the rest of the script
echo "Checking dependencies..."
echo "Checking kubectl..."
if ! command -v kubectl &> /dev/null
then
echo "You must have Kubernetes installed!"
exit 1
fi
echo "OK"
echo "Checking ansible-playbook..."
if ! command -v ansible-playbook &> /dev/null
then
echo "You must have Ansible installed!"
exit 1
fi
echo "OK"
## Retrieving the arguments
while getopts f:d:h flag
do
case "${flag}" in
f) flags=${OPTARG};;
d) deploy=${OPTARG};;
h) help="true";;
*) exit 1;;
esac
done
## Setting default values
deploy=${deploy:-"deploy.yaml"}
flags=${flags:-"-vvvv"}
## Print help
if [ "${help}" == "true" ]
then
echo "usage: $0 [OPTIONS]"
echo " -d: deploy file to be used (defaults to deploy.yaml)"
echo " -f: Ansible flags to be passed, like -vvvv, --tags=100k (defaults to -vvvv)"
echo " -h: shows the script help (this message)"
exit 1
fi
## Creating the volumes
echo "Bringing volumes up..."
if ! kubectl apply -f local_storage_example/volumes/
then
echo "Error while bringing volumes up!"
exit 1
fi
## Running Ansible
ansible-playbook -K -k -i inventories/example_local ${deploy} ${flags}