diff --git a/scripts/ansible b/scripts/ansible index b2252e4fc..868ed67cc 100755 --- a/scripts/ansible +++ b/scripts/ansible @@ -5,13 +5,15 @@ URL="NA" # TODO add check for version - to revese patching if upgrading if [ $(which ansible-playbook) ]; then VER=`ansible --version|head -n 1|cut -f 2 -d " "` - if [ $VER="2.2.0.0" ]; then + GOOD_VER="$VER | grep 2.4 | wc -l" + if [ $VER = "2.2.0.0" ]; then echo "Ansible $VER installed updating to 2.4.0" pip install --upgrade ansible==2.4.0 --disable-pip-version-check -# sed -i 's/StrictVersion/LooseVersion/g' /usr/lib/python2.7/dist-packages/ansible/modules/core/web_infrastructure/htpasswd.py - fi exit 0 + fi fi + + # TODO add check for version - to revese patching if upgrading #if [ $(which ansible-playbook) ]; then # VER=`ansible --version|head -n 1|cut -f 2 -d " "` @@ -93,21 +95,20 @@ fi ### start ansible pip install TODO add venv location /opt/iiab/anisble if [ $FAMILY = "olpc" ]; then - pip install ansible==2.2.1 --disable-pip-version-check + pip install ansible==2.4.0 --disable-pip-version-check VER=`ansible --version|head -n 1|cut -f 2 -d " "` echo "ansible version installed via pip $VER" fi -# TODO add check for version to skip patching -# APPLY TEMPORARY PATCH -# https://github.com/ansible/ansible/pull/20202 -# https://github.com/iiab/iiab/issues/249 -#if [ $FAMILY != "redhat" ]; then -# echo "Patching..." -# sed -i 's/StrictVersion/LooseVersion/g' /usr/lib/python2.7/dist-packages/ansible/modules/core/web_infrastructure/htpasswd.py -#fi +# handle 2.2.1 2.2.0.0 <-> 2.4.0 +if [ $FAMILY = "debian" ]; then + if [ $GOOD_VER -lt 1 ]; then + sed -i 's/LooseVersion/StrictVersion/g' /usr/lib/python2.7/dist-packages/ansible/modules/core/web_infrastructure/htpasswd.py + apt-get -y upgrade ansible + fi +fi VER=`ansible --version|head -n 1|cut -f 2 -d " "` -echo "ansible version installed via package manager $VER" +echo "Current ansible version installed is $VER" # sample only #if [ $FAMILY = "debian" ]; then