-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_once_ansible_playbooks.sh
45 lines (39 loc) · 1.03 KB
/
run_once_ansible_playbooks.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
#!/bin/bash
setup_os() {
case $(uname -s) in
Darwin*)
setup_macos ;;
Linux*)
setup_linux ;;
*)
echo "Unsupported OS" && exit 1 ;;
esac
}
setup_macos() {
install_homebrew
brew install ansible
ansible-playbook -i ~/.bootstrap/inventory.yml ~/.bootstrap/setup_macos.yml --ask-become-pass
}
install_homebrew() {
if ! command -v brew &> /dev/null; then
echo "Homebrew not found. Installing..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
else
echo "Homebrew is already installed. Skipping installation."
fi
}
setup_linux() {
if [ -f /etc/lsb-release ]; then
setup_ubuntu
else
echo "Unsupported Linux distribution"
exit 1
fi
}
setup_ubuntu() {
sudo apt-get update
sudo apt-get install -y ansible
ansible-playbook -i ~/.bootstrap/inventory.yml ~/.bootstrap/setup_ubuntu.yml --ask-become-pass
}
setup_os
echo "Ansible installation complete."