Skip to content

Commit b6604ba

Browse files
author
lerndevops
authored
Update installAnsible.sh
1 parent e236dac commit b6604ba

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

ansible/install/installAnsible.sh

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,38 @@
11
#!/bin/bash
22

3-
which ansible
4-
5-
if [ $? -eq "0" ];then
6-
echo "`ansible --version | head -1` - is already installed"
7-
exit
3+
if [ -f /etc/os-release ];then
4+
osname=`grep ID /etc/os-release | egrep -v 'VERSION|LIKE|VARIANT' | cut -d'=' -f2 | sed -e 's/"//' -e 's/"//'`
5+
echo $osname
86
else
7+
echo "can not locate /etc/os-release - unable find the osname"
8+
exit 8
9+
fi
10+
11+
if [ $osname == "ubuntu" ];then
12+
913
clear
1014
echo "No ansible installation found -- proceeding with ansible installation..."
1115
sudo apt-get update
1216
sudo apt-get install -y software-properties-common
1317
sudo apt-add-repository --yes --update ppa:ansible/ansible
1418
sudo apt-get install -y ansible
1519
echo "`ansible --version | head -1` installed Successfully"
20+
21+
elif [ $osname == "amzn" ]; then
22+
23+
clear
24+
echo "No ansible installation found -- proceeding with ansible installation..."
25+
sudo yum install -y epel-release
26+
sudo yum install -y ansible
27+
echo "`ansible --version | head -1` installed Successfully"
28+
29+
elif [ $1 == "centos" ];then
30+
31+
clear
32+
echo "No ansible installation found -- proceeding with ansible installation..."
33+
sudo yum install -y epel-release
34+
sudo yum install -y ansible
35+
echo "`ansible --version | head -1` installed Successfully"
1636
fi
17-
exit
37+
38+
exit 0

0 commit comments

Comments
 (0)