-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-ansible.sh
executable file
·39 lines (34 loc) · 1014 Bytes
/
install-ansible.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
#!/usr/bin/env bash
# This script uses ansible to install dotfiles, so make sure it's installed.
# Set OS & Distro variables
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
DISTRO="sed -n -e 's/^ID_LIKE=//p' /etc/os-release"
if [[ "$DISTRO" == "fedora"||"centos" ]]; then
CMD_PKG_INSTALL="yum"
elif [[ "$DISTRO" == "debian"||"ubuntu" ]]; then
CMD_PKG_INSTALL="apt"
else
echo "Check '\$DISTRO' has a match condition: $DISTRO"
fi
if [[ "id -u" != 0 ]]; then
SUDO="sudo"
else
SUDO=""
fi
elif [[ "$OSTYPE" == "darwin".* ]]; then
CMD_PKG_INSTALL="brew"
# Makes sure Homebrew is ready to go
if [[ ! "command -v brew" ]]; then
echo "Installing homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
SUDO = ""
fi
# Makes sure Ansible is ready to go
if ! command -v ansible &> /dev/null ; then
echo "Installing Ansible..."
$SUDO $CMD_PKG_INSTALL install ansible -y
fi
if command -v ansible &> /dev/null ; then
echo "Ansible is ready."
fi