-
Notifications
You must be signed in to change notification settings - Fork 2
/
bootstrap.sh
executable file
·59 lines (49 loc) · 1.54 KB
/
bootstrap.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
#!/bin/bash
# Purpose:
# * bootstrap machine in order to prepare for ansible playbook run
set -e
# Download and install Command Line Tools if no developer tools exist
if [[ $(/usr/bin/gcc 2>&1) =~ "no developer tools were found" ]] || [[ ! -x /usr/bin/gcc ]]; then
echo "Info | Install | xcode"
xcode-select --install
fi
# Download and install Homebrew
if [[ ! -x /usr/local/bin/brew ]]; then
echo "Info | Install | homebrew"
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
# Download and install Ansible
if [[ ! -x /usr/local/bin/ansible ]]; then
echo "Info | Install | Ansible"
brew update
brew install ansible
fi
# ensure java is installed
if ! java --version; then
read -p "WARN: Please install Java before you continue. Continue anyway? [Y/n] " response
case $response in [yY][eE][sS]|[yY]|[jJ]|'')
echo
echo Try to continue...
echo
;;
*)
echo Exiting... Please run me again, after java has been installed
exit 1
;;
esac
fi
# Modify the PATH
# This should be subsequently updated in shell settings
export PATH=/usr/local/bin:$PATH
if [[ -d .git ]]; then
echo "Info | mac-ansible | Pull"
git pull
fi
# Use this if you use the vault
# if [[ ! -f ~/.ansible_vault_pass.py ]]; then
# echo "Please save your vault password in ~/.ansible_vault_pass.py"
# exit
# fi
#
# ansible-playbook local.yml --vault-password-file ~/.ansible_vault_pass.py
ansible-playbook local.yml --ask-become-pass --inventory-file=hosts