2017-09-26 04:42:00 +00:00
|
|
|
#!/bin/bash -e
|
2017-12-12 03:08:17 +00:00
|
|
|
|
2017-12-12 16:09:00 +00:00
|
|
|
# Installs or upgrades to the best possible Ansible release, so iiab-install
|
|
|
|
# can proceed. Ensure you're online before running this script!
|
|
|
|
|
|
|
|
GOOD_VER="2.4.2" # Ansible version for OLPC, for pip.
|
|
|
|
# On other OS's we install/upgrade to the latest Ansible.
|
|
|
|
# Pin all to 2.4.x in future, if really/truly nec?
|
|
|
|
CURR_VER="undefined"
|
|
|
|
# FOUND="false" # NOT USED AS OF 2017-12-12
|
|
|
|
# FAMILY="undefined" # NOT USED AS OF 2017-12-12
|
2017-09-28 13:37:48 +00:00
|
|
|
# below are unused for future use
|
2017-12-12 00:33:35 +00:00
|
|
|
# URL="NA"
|
|
|
|
|
2017-11-30 23:15:21 +00:00
|
|
|
export DEBIAN_FRONTEND=noninteractive
|
2017-12-12 00:33:35 +00:00
|
|
|
|
|
|
|
if ! [ `which ansible-playbook` ]; then
|
2017-11-30 23:15:21 +00:00
|
|
|
echo "Installing --- Please Wait"
|
|
|
|
if [ -f /etc/centos-release ]; then
|
|
|
|
yum -y install ca-certificates nss epel-release
|
|
|
|
yum -y install git bzip2 file findutils gzip hg svn sudo tar which unzip xz zip libselinux-python
|
|
|
|
yum -y install python-pip python-setuptools python-wheel patch
|
|
|
|
yum -y install http://releases.ansible.com/ansible/rpm/release/epel-7-x86_64/ansible-2.4.2.0-1.el7.ans.noarch.rpm
|
2017-12-12 02:35:47 +00:00
|
|
|
# FOUND="true"
|
2017-12-12 16:09:00 +00:00
|
|
|
# FAMILY="redhat"
|
2017-11-30 23:15:21 +00:00
|
|
|
# elif [ -f /etc/fedora-release ]; then
|
2017-12-12 16:09:00 +00:00
|
|
|
# CURR_VER=`grep VERSION_ID /etc/*elease | cut -d= -f2`
|
|
|
|
# URL=https://github.com/jvonau/iiab/blob/ansible/vars/fedora-$CURR_VER.yml
|
2017-11-30 23:15:21 +00:00
|
|
|
# dnf -y install ansible git bzip2 file findutils gzip hg svn sudo tar which unzip xz zip libselinux-python
|
|
|
|
# dnf -y install python-pip python-setuptools python-wheel patch
|
2017-12-12 00:33:35 +00:00
|
|
|
# FOUND="true"
|
2017-11-30 23:15:21 +00:00
|
|
|
# FAMILY="redhat"
|
|
|
|
elif [ -f /etc/olpc-release ]; then
|
|
|
|
yum -y install ca-certificates nss
|
|
|
|
yum -y install git bzip2 file findutils gzip hg svn sudo tar which unzip xz zip libselinux-python
|
|
|
|
yum -y install python-pip python-setuptools python-wheel patch
|
|
|
|
pip install --upgrade pip setuptools wheel #EOL just do it
|
|
|
|
pip install ansible==$GOOD_VER --disable-pip-version-check
|
2017-12-12 02:35:47 +00:00
|
|
|
# FOUND="true"
|
2017-12-12 16:09:00 +00:00
|
|
|
# FAMILY="olpc"
|
|
|
|
elif [ -f /etc/debian_version ] || (grep -qi raspbian /etc/*elease) ; then
|
|
|
|
if ( ! grep -qi ansible /etc/apt/sources.list) && [ ! -f /etc/apt/sources.list.d/ansible ]; then
|
2017-12-12 00:33:35 +00:00
|
|
|
apt -y install dirmngr python-pip python-setuptools python-wheel patch
|
2017-12-05 16:20:20 +00:00
|
|
|
echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu xenial main" \
|
2017-12-12 00:33:35 +00:00
|
|
|
>> /etc/apt/sources.list.d/ansible.list
|
2017-12-05 16:20:20 +00:00
|
|
|
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367
|
|
|
|
fi
|
2017-12-12 02:35:47 +00:00
|
|
|
# FOUND="true"
|
2017-12-12 16:09:00 +00:00
|
|
|
# FAMILY="debian"
|
|
|
|
# Parens are optional, but greatly clarify :)
|
|
|
|
elif (grep -qi ubuntu /etc/lsb-release) || (grep -qi ubuntu /etc/os-release); then
|
2017-12-12 00:33:35 +00:00
|
|
|
apt -y install python-pip python-setuptools python-wheel patch
|
2017-11-30 23:15:21 +00:00
|
|
|
apt-add-repository -y ppa:ansible/ansible
|
2017-12-12 02:35:47 +00:00
|
|
|
# FOUND="true"
|
2017-12-12 16:09:00 +00:00
|
|
|
# FAMILY="debian"
|
2017-12-12 02:35:47 +00:00
|
|
|
# fi
|
|
|
|
# if [ ! $FOUND = "true" ]; then
|
|
|
|
else
|
2017-12-12 00:33:35 +00:00
|
|
|
echo "WARN: Could not detect distro or distro unsupported"
|
2017-11-30 23:15:21 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
else
|
2017-12-12 16:09:00 +00:00
|
|
|
CURR_VER=`ansible --version | head -n 1 | cut -f 2 -d " "`
|
|
|
|
echo "Current ansible version installed is $CURR_VER"
|
2017-11-30 23:15:21 +00:00
|
|
|
if [ -f /etc/centos-release ] || [ -f /etc/fedora-release ]; then
|
|
|
|
echo "Please use your system's package manager to update ansible"
|
2017-09-28 03:50:16 +00:00
|
|
|
exit 0
|
2017-12-12 02:35:47 +00:00
|
|
|
elif [ -f /etc/olpc-release ]; then
|
2017-11-30 23:15:21 +00:00
|
|
|
echo "Please use pip package manager to update ansible"
|
2017-09-28 03:50:16 +00:00
|
|
|
exit 0
|
2017-12-12 02:35:47 +00:00
|
|
|
#fi
|
2017-12-12 00:33:35 +00:00
|
|
|
#if [[ `grep -qi ansible /etc/apt/sources.list` ]] || [ -f /etc/apt/sources.list.d/ansible*.list ]; then
|
2017-12-12 16:09:00 +00:00
|
|
|
elif (grep -qi ansible /etc/apt/sources.list) || (ls /etc/apt/sources.list.d/ansible*.list >/dev/null 2>&1) ; then
|
2017-12-12 02:21:39 +00:00
|
|
|
echo "Ansible repo(s) found within /etc/apt/sources.list*"
|
2017-12-05 18:42:52 +00:00
|
|
|
else
|
2017-12-05 16:20:20 +00:00
|
|
|
echo "Upstream ansible source repo not found, please uninstall ansible and re-run this script"
|
|
|
|
exit 1
|
|
|
|
fi
|
2017-09-27 05:10:24 +00:00
|
|
|
fi
|
2017-09-27 20:38:00 +00:00
|
|
|
|
2017-12-12 00:33:35 +00:00
|
|
|
if [ ! -f /etc/centos-release ] && [ ! -f /etc/fedora-release ] && [ ! -f /etc/olpc-release ]; then
|
2017-12-12 02:21:39 +00:00
|
|
|
echo "Using apt to check for updates, then install/upgrade ansible"
|
2017-12-12 00:33:35 +00:00
|
|
|
apt update
|
|
|
|
apt -y install ansible
|
2017-09-27 20:38:00 +00:00
|
|
|
fi
|
2017-09-26 15:05:05 +00:00
|
|
|
|
2017-12-05 16:20:20 +00:00
|
|
|
# needed?
|
2017-09-26 04:42:00 +00:00
|
|
|
mkdir -p /etc/ansible/
|
|
|
|
echo -e '[local]\nlocalhost\n' > /etc/ansible/hosts
|