-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·34 lines (29 loc) · 900 Bytes
/
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
#!/usr/bin/env bash
ARGS="$@"
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
VENV_PATH="$DIR/venv"
prerequisites() {
if ! command -v /usr/bin/virtualenv >/dev/null 2>&1; then
sudo apt install -y virtualenv
fi
if ! command -v pip >/dev/null 2>&1; then
sudo apt install -y python3-pip
fi
if ! command -v python >/dev/null 2>&1; then
sudo apt install -y python-is-python3
fi
}
setup_venv() {
# Create a virtual environment if it doesn't exist
if [ ! -d "$VENV_PATH" ]; then
echo "Creating a virtual environment..."
/usr/bin/virtualenv "$VENV_PATH"
fi
source "$VENV_PATH/bin/activate"
echo "Installing pip requirements..."
pip install -r "$DIR/requirements.txt"
}
prerequisites
setup_venv
ansible-galaxy collection install -r ansible-requirements.yml
ansible-playbook -K playbook.yml $ARGS