-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-ansible.sh
executable file
·44 lines (37 loc) · 1.07 KB
/
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
40
41
42
43
44
#!/usr/bin/env bash
# This script uses ansible to install dotfiles, so make sure it's installed.
if command -v ansible &> /dev/null ; then
echo "Ansible is ready."
exit 0
fi
echo "Installing Ansible..."
# Set OS & Distro variables
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
DISTRO="sed -n -e 's/^ID_LIKE=//p' /etc/os-release"
if [[ "$DISTRO" == "fedora" ]]; then
CMD_PKG_INSTALL="dnf"
elif [[ "$DISTRO" == "centos"||"redhat" ]]; then
CMD_PKG_INSTALL="yum"
elif [[ "$DISTRO" == "debian"||"ubuntu" ]]; then
CMD_PKG_INSTALL="apt"
else
echo "This script wasn't written for your distro: $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 = ""
else
echo "Can't determine package installer. Check your OS is in the list"
exit 1
fi
$SUDO $CMD_PKG_INSTALL install ansible -y