forked from StreisandEffect/streisand
-
Notifications
You must be signed in to change notification settings - Fork 0
/
streisand
executable file
·47 lines (38 loc) · 1.41 KB
/
streisand
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
#!/usr/bin/env bash
# Streisand provisioning script
set -e
REQUIRED_ANSIBLE_VERSION="2.3.0"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd -P)"
echo -e "\n\033[38;5;255m\033[48;5;234m\033[1m S T R E I S A N D \033[0m\n"
if ! command -v ansible > /dev/null 2>&1; then
echo "Ansible is not installed."
exit 1
fi
if [[ $(ansible --version | grep -oe '2\(.[0-9]\)*') < $REQUIRED_ANSIBLE_VERSION ]]; then
echo "Ansible $REQUIRED_ANSIBLE_VERSION or higher is required."
exit 1
fi
PYTHON_VERSION="$(python --version 2>/dev/null)"
if [[ -n $PYTHON_VERSION && ! $PYTHON_VERSION =~ ^Python\ 2\..* ]]; then
sed 's/=python$/=python2/' "$SCRIPT_DIR/inventory" > "$SCRIPT_DIR/inventory.new"
mv "$SCRIPT_DIR/inventory.new" "$SCRIPT_DIR/inventory"
git -C "$SCRIPT_DIR" update-index --assume-unchanged inventory 2>/dev/null || true
fi
export PYTHONPATH="$SCRIPT_DIR/monkey:$PYTHONPATH"
read -r -p "Which provider are you using?
1. Amazon
2. Azure
3. DigitalOcean
4. Google
5. Linode
6. Rackspace
: " reply
case "$reply" in
1) echo; echo; ansible-playbook playbooks/amazon.yml;;
2) echo; echo; ansible-playbook playbooks/azure.yml;;
3) echo; echo; ansible-playbook playbooks/digitalocean.yml;;
4) echo; echo; ansible-playbook playbooks/google.yml;;
5) echo; echo; ansible-playbook playbooks/linode.yml;;
6) echo; echo; ansible-playbook playbooks/rackspace.yml;;
*) echo; echo "Invalid provider selected."; exit 1;;
esac