forked from kshlm/gd2-k8s
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprepare.sh
executable file
·67 lines (55 loc) · 1.7 KB
/
prepare.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
## This script sets up the environment to allow GCS deployments using kubespray and ansible
DEP_NOT_FOUND=()
function check_dep() {
if ! which $1 &>/dev/null; then
echo $1 not found
DEP_NOT_FOUND+=($2)
return 1
fi
return 0
}
check_dep ansible ansible
check_dep virtualenv python-virtualenv
if check_dep vagrant vagrant; then
if ! (vagrant plugin list | grep -q vagrant-libvirt); then
echo vagrant-libvirt not found
DEP_NOT_FOUND+=(vagrant-libvirt)
else
cat <<EOF
vagrant and vagrant-libvirt were found.
For easier operation, ensure that libvirt has been configured to work without passwords.
Ref: https://developer.fedoraproject.org/tools/vagrant/vagrant-libvirt.html
EOF
fi
fi
if [[ "${DEP_NOT_FOUND[@]}" != "" ]]; then
echo Please install the following packages before proceeding
echo "\t${DEP_NOT_FOUND[@]}"
exit 1
fi
## Ensure kubespray submodule is present
echo "Ensuring kubespray is present"
git submodule --quiet init
git submodule --quiet update
## Create a python virtualenv for kubespray requirements
### REQUIRES: python-virtualenv installed for you system
VENV="gcs-venv"
echo "Creating a python virtualenv $VENV"
virtualenv -q $VENV
. $VENV/bin/activate
echo "Installing requirements into $VENV"
pip install -q -r ./kubespray/requirements.txt
pip install -q jmespath
echo
cat <<EOF
Virtualenv $VENV has been created
The virtualenv needs to be activated before doing any operations. Operations may fail if virtualenv is not activated.
To activate the virutalenv, run:
\$ source $VENV/bin/activate
($VENV) \$
To deactivate an activated virtualenv, run:
($VENV) \$ deactivate
\$
Note: The virtualenv should be activated for each shell session individually.
EOF