1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-12 19:22:24 +00:00
iiab/scripts/ansible-2.4.x-deprecated

94 lines
5.3 KiB
Text
Raw Normal View History

2017-09-26 04:42:00 +00:00
#!/bin/bash -e
2017-12-12 03:08:17 +00:00
2018-04-05 09:29:16 +00:00
echo -e '\nATTEMPTING TO INSTALL THE LATEST ANSIBLE 2.4.x'
echo -e 'Ensure you'"'"'re online before running this script!'
2018-04-05 18:00:45 +00:00
echo -e 'OR: consider scripts/ansible-2.5.x\nOR: consider scripts/ansible to keep up-to-date with Ansible'"'"'s evolution.\n'
2018-04-05 09:29:16 +00:00
GOOD_VER="2.4.4" # Ansible version for OLPC XO laptops (pip install).
# On other OS's we attempt to install/upgrade/pin to the latest Ansible 2.4.x
# WARNING: IIAB 6.6 will likely recommend the very latest Ansible 2.5.x or higher.
CURR_VER="undefined"
2017-09-28 13:37:48 +00:00
# below are unused for future use
# URL="NA"
export DEBIAN_FRONTEND=noninteractive
2018-04-05 09:36:25 +00:00
if [ ! `command -v ansible-playbook` ]; then # "command -v" is POSIX compliant; also catches built-in commands like "cd"
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.4.0-1.el7.ans.noarch.rpm
# elif [ -f /etc/fedora-release ]; then
# CURR_VER=`grep VERSION_ID /etc/*elease | cut -d= -f2`
# URL=https://github.com/jvonau/iiab/blob/ansible/vars/fedora-$CURR_VER.yml
# 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
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
2018-04-05 17:11:33 +00:00
# Parens are optional, but greatly clarify :)
2018-04-09 20:06:52 +00:00
elif (grep -qi ubuntu /etc/lsb-release 2> /dev/null) || (grep -qi ubuntu /etc/os-release); then
apt -y install python-pip python-setuptools python-wheel patch
#apt-add-repository -y ppa:ansible/ansible
apt-add-repository -y ppa:ansible/ansible-2.4
2018-04-05 17:14:13 +00:00
# elif UBUNTU MUST REMAIN ABOVE (as Ubuntu ALSO contains /etc/debian_version, which would trigger the line just below)
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
apt update
apt -y install dirmngr python-pip python-setuptools python-wheel patch
#echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu xenial main" \
# >> /etc/apt/sources.list.d/iiab-ansible.list
echo "deb http://ppa.launchpad.net/ansible/ansible-2.4/ubuntu xenial main" \
>> /etc/apt/sources.list.d/iiab-ansible.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367
fi
2017-12-12 02:35:47 +00:00
else
echo "WARN: Could not detect distro or distro unsupported"
exit 1
fi
else
#CURR_VER=`ansible --version | head -n 1 | cut -f 2 -d " "`
2017-12-13 12:03:01 +00:00
CURR_VER=`ansible --version | head -1 | awk '{print $2}'` # to match iiab-install
echo "Current ansible version installed is $CURR_VER"
if [ -f /etc/centos-release ] || [ -f /etc/fedora-release ]; then
echo "Please use your system's package manager to update ansible"
exit 0
2017-12-12 02:35:47 +00:00
elif [ -f /etc/olpc-release ]; then
echo "Please use pip package manager to update ansible"
exit 0
2017-12-12 02:35:47 +00:00
#fi
#if [[ `grep -qi ansible /etc/apt/sources.list` ]] || [ -f /etc/apt/sources.list.d/ansible*.list ]; then
elif (grep -qi ansible /etc/apt/sources.list) || (ls /etc/apt/sources.list.d/*ansible*.list >/dev/null 2>&1) ; then
#echo "Ansible repo(s) found within /etc/apt/sources.list*"
2018-04-05 18:00:45 +00:00
echo -e '\nMANUAL INTERVENTION URGED: ANSIBLE REPO(S) FOUND WITHIN /etc/apt/sources.list AND/OR /etc/apt/sources.list.d/*ansible*.list -- MUST CONTAIN LINE "deb http://ppa.launchpad.net/ansible/ansible-2.4/ubuntu xenial main" IF YOU WANT THE LATEST ANSIBLE 2.4.x -- AND REMOVE ALL SIMILAR LINES TO ENSURE ANSIBLE UPDATES CLEANLY -- then re-run this script.\n'
2017-12-05 18:42:52 +00:00
else
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
if [ ! -f /etc/centos-release ] && [ ! -f /etc/fedora-release ] && [ ! -f /etc/olpc-release ]; then
2018-03-23 16:52:23 +00:00
# Align IIAB with Ansible community's latest official release
echo "Using apt to check for updates, then install/upgrade ansible"
apt update
2018-04-05 10:32:12 +00:00
apt -y --allow-downgrades install ansible=2.4*
2018-04-05 08:48:56 +00:00
# TEMPORARILY USE ANSIBLE 2.4.4 (REMOVE IT WITH "pip uninstall ansible")
#pip install ansible==2.4.4
# TEMPORARILY USE ANSIBLE 2.4.2 DUE TO 2.4.3 MEMORY BUG. DETAILS @ https://github.com/iiab/iiab/issues/669
#echo "Install http://download.iiab.io/packages/ansible_2.4.2.0-1ppa~xenial_all.deb"
#cd /tmp
#wget http://download.iiab.io/packages/ansible_2.4.2.0-1ppa~xenial_all.deb
#apt -y --allow-downgrades install ./ansible_2.4.2.0-1ppa~xenial_all.deb
fi
2017-09-26 15:05:05 +00:00
# needed?
2017-09-26 04:42:00 +00:00
mkdir -p /etc/ansible/
echo -e '[local]\nlocalhost\n' > /etc/ansible/hosts