-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·53 lines (43 loc) · 1.22 KB
/
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
set -euo pipefail
determine_platform() {
platform="unknown"
if [[ "$(uname)" == "Linux" ]]; then
platform="linux"
elif [[ "$(uname)" == "Darwin" ]]; then
platform="macos"
else
echo "Unknown OS"
exit 1
fi
}
install_ansible() {
if [[ "$platform" == "linux" ]]; then
sudo apt install ansible -y
elif [[ "$platform" == "macos" ]]; then
log "Installing/upgrading Homebrew"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/gcipriano/.bashrc
log "Installing Ansible"
brew install ansible
fi
}
log() {
echo
echo "----------------------------------------------------------------------"
echo "$1"
echo "----------------------------------------------------------------------"
echo
}
log "Oh boy, here I go installin' again!"
determine_platform
if ! which ansible-playbook > /dev/null 2>&1 ; then
echo "ansible-playbook not found on \$PATH, installing"
install_ansible
fi
(
cd "$(dirname "$0")"
cmd="ansible-playbook -i localhost, --tags ${platform} -c local playbook.yml"
$cmd
)
log "Don't forget to read the post install steps for your OS in README.md."