-
Notifications
You must be signed in to change notification settings - Fork 1
/
run-ansible-playbook
executable file
·46 lines (38 loc) · 1.81 KB
/
run-ansible-playbook
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
#!/bin/bash -xe
#
# Example
# ./run-ansible-playbook development deploy.yml --limit balancer_servers --check
#
export LC_ALL='en_US.UTF-8'
# Prepare the upstream Open edX configuration repository
# clone if not exists and checkout the branch defined on the environment variable `BRANCH_CONFIGURATION`
# or use the default `nau-release/nutmeg` branch
BRANCH_CONFIGURATION="${BRANCH_CONFIGURATION:=nau/nutmeg.master}"
[ -d configuration ] || rm -f configuration
[ -d configuration ] || git clone -b ${BRANCH_CONFIGURATION} [email protected]:fccn/configuration.git configuration
git -C configuration clean -fdx
git -C configuration pull
git -C configuration checkout ${BRANCH_CONFIGURATION}
# Prepare the secure-nau-data
# clone if not exists and checkout the branch defined on the environment variable `BRANCH_SECURE_DATA`
# or use the default `master` branch
BRANCH_SECURE_DATA="${BRANCH_SECURE_DATA:=master}"
[ -d "nau-data" ] || rm -f nau-data
[ -d "nau-data" ] || git clone -b "${BRANCH_SECURE_DATA}" [email protected]:fccn/secure-nau-data.git nau-data
git -C "nau-data" clean -fdx
git -C "nau-data" pull
git -C "nau-data" checkout ${BRANCH_SECURE_DATA}
# Create the virtual environment
# rm -rf venv_ops
python3.8 -m venv venv_ops
. venv_ops/bin/activate
# Install pip requirements including the upstream Open edX configuration repo requirements
# including specific pip version, setuptools and other pip modules
pip install -r requirements.txt --exists-action w --no-compile --disable-pip-version-check
# Install additional roles from ansible galaxy and directly from git
ansible-galaxy install -p vendor/roles -r requirements.yml --force --ignore-errors
NAU_ENVIRONMENT=$1
shift
HOSTS_FILE="nau-data/envs/${NAU_ENVIRONMENT}/hosts.ini"
test -f $HOSTS_FILE || { echo "Missing hosts file $HOSTS_FILE" ; exit 1; }
ansible-playbook -i $HOSTS_FILE $@