2014-09-03 21:41:02 +08:00
|
|
|
#!/bin/bash
|
2015-06-09 22:06:54 +08:00
|
|
|
#
|
|
|
|
# THIS SCRIPT INSTALLS ANSIBLE
|
2016-05-31 22:49:40 +08:00
|
|
|
# DO NOT RUN IF ANSIBLE IS ALREADY INSTALLED ON YOUR SYSTEM
|
|
|
|
|
2016-04-04 21:09:44 +08:00
|
|
|
set -e
|
2014-09-03 21:41:02 +08:00
|
|
|
|
|
|
|
if [[ $EUID -ne 0 ]]; then
|
|
|
|
echo "You are NOT running this script as root."
|
|
|
|
echo "You should."
|
|
|
|
echo "Really."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2016-05-31 22:49:40 +08:00
|
|
|
if [[ ! -x $(which lsb_release 2>/dev/null) ]]; then
|
|
|
|
echo "ERROR: lsb_release is not installed"
|
|
|
|
echo "Cannot evaluate the platform"
|
|
|
|
echo "Please install lsb_release and retry"
|
|
|
|
echo "Red Hat based Systems : yum install redhat-lsb-core"
|
|
|
|
echo "Debian based Systems : apt-get install lsb-release"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# GET OS VENDOR
|
2016-05-04 23:33:07 +08:00
|
|
|
os_VENDOR=$(lsb_release -i -s)
|
2016-05-31 22:49:40 +08:00
|
|
|
# GET OS MAJOR VERSION
|
|
|
|
os_VERSION=$(lsb_release -r -s | cut -d. -f 1)
|
|
|
|
|
|
|
|
echo "*** Detected Linux $os_VENDOR $os_VERSION ***"
|
|
|
|
|
2016-05-04 23:33:07 +08:00
|
|
|
if [[ "Debian" =~ $os_VENDOR ]]; then
|
|
|
|
apt-get update
|
|
|
|
apt-get install -y python-pip python-dev git build-essential
|
|
|
|
pip install PyYAML jinja2 paramiko
|
|
|
|
git clone https://github.com/ansible/ansible.git
|
|
|
|
cd ansible
|
|
|
|
make install
|
|
|
|
mkdir /etc/ansible
|
2016-05-10 03:00:56 +08:00
|
|
|
elif [[ "Ubuntu" =~ $os_VENDOR || "LinuxMint" =~ $os_VENDOR ]]; then
|
2016-05-04 23:33:07 +08:00
|
|
|
add-apt-repository -y ppa:ansible/ansible
|
|
|
|
apt-get update
|
|
|
|
apt-get install -y ansible
|
2016-05-31 22:49:40 +08:00
|
|
|
elif [[ "RedHatEnterpriseServer" =~ $os_VENDOR || "CentOS" =~ $os_VENDOR ]]; then
|
|
|
|
if ( rpm -q epel-release &> /dev/null ); then
|
|
|
|
echo "*** WARNING : EPEL Already installed - We won't remove it but be aware that it might conflict if you plan using other Ceph repo source ***"
|
|
|
|
echo "*** Installing Ansible from EPEL... ***"
|
|
|
|
yum install -y ansible
|
|
|
|
else
|
|
|
|
echo "*** Installing EPEL... ***"
|
|
|
|
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-${os_VERSION}.noarch.rpm
|
|
|
|
echo "*** Installing Ansible from EPEL... ***"
|
|
|
|
yum install -y ansible
|
|
|
|
echo "*** Removing EPEL... ***"
|
|
|
|
yum remove -y epel-release
|
2014-09-30 20:12:48 +08:00
|
|
|
fi
|
2016-05-31 22:49:40 +08:00
|
|
|
else
|
|
|
|
echo "*** Unsupported platform ${os_VENDOR}: ${os_VERSION} ***"
|
|
|
|
echo "*** Please send a pull-request or open an issue ***"
|
|
|
|
echo "*** on https://github.com/ceph/ceph-ansible/ ***"
|
2016-05-04 23:33:07 +08:00
|
|
|
exit 1
|
2014-09-03 21:41:02 +08:00
|
|
|
fi
|
2016-05-31 22:49:40 +08:00
|
|
|
|
|
|
|
if ( ansible --version &> /dev/null ); then
|
|
|
|
echo "*** $(ansible --version | head -n1) installed successfully ***"
|
|
|
|
else
|
|
|
|
echo "Something went wrong, please have a look at the script output"
|
|
|
|
fi
|