From c65a9f9dc417b69fb84c7126311ac502217f5529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Wed, 4 May 2016 17:33:07 +0200 Subject: [PATCH] install-ansible: refactor install on Red Hat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge both lsb_release and /etc/redhat-release cases. Also testing if epel is already installed or not. Signed-off-by: Sébastien Han --- install-ansible.sh | 50 +++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/install-ansible.sh b/install-ansible.sh index 8954b3ac7..b3127d7b8 100755 --- a/install-ansible.sh +++ b/install-ansible.sh @@ -10,31 +10,31 @@ if [[ $EUID -ne 0 ]]; then exit 1 fi -if [[ -x $(which lsb_release 2>/dev/null) ]]; then - os_VENDOR=$(lsb_release -i -s) - os_VERSION=$(lsb_release -c -s) - 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 - elif [[ "Ubuntu" =~ $os_VENDOR ]]; then - add-apt-repository -y ppa:ansible/ansible - apt-get update - apt-get install -y ansible - elif [[ "RedHatEnterpriseServer" =~ $os_VENDOR || "CentOS" =~ $os_VENDOR ]]; then - rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm - yum install -y ansible - 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/" +os_VENDOR=$(lsb_release -i -s) +os_VERSION=$(lsb_release -c -s) +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 +elif [[ "Ubuntu" =~ $os_VENDOR ]]; then + add-apt-repository -y ppa:ansible/ansible + apt-get update + apt-get install -y ansible +elif [[ "RedHatEnterpriseServer" =~ $os_VENDOR || "CentOS" =~ $os_VENDOR || -r /etc/redhat-release ]]; then + rpm -q epel-release-* || rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm + yum install -y ansible +else + if [[ ! -x $(which lsb_release 2>/dev/null) ]]; then + echo "lsb_release is not installed" + echo "Can not evaluate the platform" exit 1 fi -elif [[ -r /etc/redhat-release ]]; then - rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm - yum install -y ansible + 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/" + exit 1 fi