-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathansible-run.sh
executable file
·59 lines (50 loc) · 1.36 KB
/
ansible-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
54
55
56
57
58
59
#!/bin/bash
set -eu -o pipefail
# Prep environment for running ansible.
# 1. sync submodules
# 2. potentially install ansible
bootstrap() {
sync_submodules() {
git submodule sync --recursive
git submodule update --init --recursive
}
install_homebrew() {
if ! command -v brew &>/dev/null; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
if [[ -d /opt/homebrew/bin ]] ; then
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
brew upgrade
brew install ansible
}
setup_apt() {
sudo apt update
sudo apt install -y ansible
}
setup_dnf() {
sudo dnf config-manager --enable crb
sudo dnf install epel-release
sudo dnf update
sudo dnf install ansible
}
sync_submodules
if ! command -v ansible &>/dev/null ; then
if [[ "$(uname -s)" =~ "Darwin" ]]; then
install_homebrew
elif grep -q "^Rocky Linux release 9.*$" /etc/redhat-release ; then
setup_dnf
elif [[ "$(lsb_release -s -i)" =~ "Ubuntu" ]]; then
setup_apt
else
echo "Unable to determine base OS. Not installing"
return 1
fi
fi
}
# install ansible if necessary
bootstrap
# Run playbooks that require root
ansible-playbook --verbose --ask-become-pass ansible/root.yml
# Run playbooks that are for me
ansible-playbook --verbose ansible/jakeman.yml