install-ansible: refactor install on Red Hat

Merge both lsb_release and /etc/redhat-release cases.
Also testing if epel is already installed or not.

Signed-off-by: Sébastien Han <seb@redhat.com>
pull/756/head
Sébastien Han 2016-05-04 17:33:07 +02:00
parent 28bf3aab44
commit c65a9f9dc4
1 changed files with 25 additions and 25 deletions

View File

@ -10,31 +10,31 @@ if [[ $EUID -ne 0 ]]; then
exit 1 exit 1
fi fi
if [[ -x $(which lsb_release 2>/dev/null) ]]; then os_VENDOR=$(lsb_release -i -s)
os_VENDOR=$(lsb_release -i -s) os_VERSION=$(lsb_release -c -s)
os_VERSION=$(lsb_release -c -s) if [[ "Debian" =~ $os_VENDOR ]]; then
if [[ "Debian" =~ $os_VENDOR ]]; then apt-get update
apt-get update apt-get install -y python-pip python-dev git build-essential
apt-get install -y python-pip python-dev git build-essential pip install PyYAML jinja2 paramiko
pip install PyYAML jinja2 paramiko git clone https://github.com/ansible/ansible.git
git clone https://github.com/ansible/ansible.git cd ansible
cd ansible make install
make install mkdir /etc/ansible
mkdir /etc/ansible elif [[ "Ubuntu" =~ $os_VENDOR ]]; then
elif [[ "Ubuntu" =~ $os_VENDOR ]]; then add-apt-repository -y ppa:ansible/ansible
add-apt-repository -y ppa:ansible/ansible apt-get update
apt-get update apt-get install -y ansible
apt-get install -y ansible elif [[ "RedHatEnterpriseServer" =~ $os_VENDOR || "CentOS" =~ $os_VENDOR || -r /etc/redhat-release ]]; then
elif [[ "RedHatEnterpriseServer" =~ $os_VENDOR || "CentOS" =~ $os_VENDOR ]]; then rpm -q epel-release-* || rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm yum install -y ansible
yum install -y ansible else
else if [[ ! -x $(which lsb_release 2>/dev/null) ]]; then
echo "Unsupported platform ${os_VENDOR}: ${os_VERSION}" echo "lsb_release is not installed"
echo "Please send a pull-request or open an issue" echo "Can not evaluate the platform"
echo "on https://github.com/ceph/ceph-ansible/"
exit 1 exit 1
fi fi
elif [[ -r /etc/redhat-release ]]; then echo "Unsupported platform ${os_VENDOR}: ${os_VERSION}"
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm echo "Please send a pull-request or open an issue"
yum install -y ansible echo "on https://github.com/ceph/ceph-ansible/"
exit 1
fi fi