From 6951b317b0093c9043ad02b3fc2e7b29a36ab7ce Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Thu, 24 Aug 2017 18:03:17 -0500 Subject: [PATCH 01/21] ansible 2.3.1 --- scripts/install_ansible | 98 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100755 scripts/install_ansible diff --git a/scripts/install_ansible b/scripts/install_ansible new file mode 100755 index 000000000..56c35f788 --- /dev/null +++ b/scripts/install_ansible @@ -0,0 +1,98 @@ +#!/bin/bash -x +# required to start loading IIAB with ansible +set -e +FOUND="" +URL="NA" +if [ $(which ansible-playbook) ]; then + echo "Ansible installed exiting..." + exit 0 +fi +echo "Installing --- Please Wait" +if [ -f /etc/fedora-release ]; then + VER=`grep VERSION_ID /etc/*elease | cut -d= -f2` + URL=https://github.com/jvonau/iiab/blob/ansible/vars/fedora-$VER.yml + dnf -y upgrade + 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 + FOUND="yes" + FAMILY="redhat" +fi +if [ -f /etc/centos-release ]; then + yum -y upgrade + yum -y install ca-certificates nss epel-release + yum -y install ansible 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 + FOUND="yes" + FAMILY="redhat" +fi +if [ -f /etc/olpc-release ]; then + yum -y upgrade + 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 + FOUND="yes" + FAMILY="debian" +fi + +if [ -f /etc/debian_version ]; then + echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main" >> /etc/apt/sources.list +# apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 +# apt-get update +# apt-get install ansible git python-pip python-setuptools python-wheel patch + apt-get install git bzip2 file findutils gzip hg svn sudo tar which unzip xz zip libselinux-python + FOUND="yes" + FAMILY="debian" +fi +if [ `grep -qi ubuntu /etc/lsb-release` ] || [ `grep -qi ubuntu /etc/os-release` ]; then + apt-get update +# apt-get install software-properties-common +# apt-add-repository ppa:ansible/ansible +# apt-get update +# apt-get install ansible git python-pip python-setuptools python-wheel patch + apt-get install git bzip2 file findutils gzip hg svn sudo tar which unzip xz zip libselinux-python + FOUND="yes" + FAMILY="debian" +fi +if [ `grep -qi raspbian /etc/*elease` ]; then + apt-get update +# apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 +# apt-get update +# apt-get install ansible git python-pip python-setuptools python-wheel patch + apt-get install git bzip2 file findutils gzip hg svn sudo tar which unzip xz zip libselinux-python + FOUND="yes" + FAMILY="debian" +fi + +if [ ! $FOUND = "yes" ]; then + echo 'WARN: Could not detect distro or distro unsupported' + exit 1 +fi + +# ansible-2.3.1.0-1.el7.noarch.rpm from 2017-06-01 +if [ $FAMILY = "redhat" ]; then + VER=`ansible --version|head -n 1|cut -f 2 -d " "` #(returns 2.3.1.0) 2017-07-07 + echo "ansible version installed via package manager $VER" + # rpm -e ansible +fi + +### start pip isolation +if [ $FAMILY = "debian" ]; then + apt-get install python-pip python-setuptools python-wheel patch +fi +### + +### +#pip upgrades here if needed +### + +# latest 2.2 is 2.2.3.0 2017-07-07 +if [ $FAMILY = "debian" ]; then + echo 'WARN: Trying to install ansible via pip without some dependencies' + echo 'WARN: Not all functionality of ansible may be available' + pip install ansible==2.3.1 --disable-pip-version-check +fi +mkdir -p /etc/ansible/ +echo -e '[local]\nlocalhost\n' > /etc/ansible/hosts + +### end ansible routine From e6f8d6d314208bd4e30a98a976bd15e484de45d3 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sun, 17 Sep 2017 01:41:24 -0500 Subject: [PATCH 02/21] Notes from PR #249 --- scripts/install_ansible | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/install_ansible b/scripts/install_ansible index 56c35f788..e7db96e19 100755 --- a/scripts/install_ansible +++ b/scripts/install_ansible @@ -36,11 +36,11 @@ if [ -f /etc/olpc-release ]; then fi if [ -f /etc/debian_version ]; then - echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main" >> /etc/apt/sources.list +# echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main" >> /etc/apt/sources.list # apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 # apt-get update # apt-get install ansible git python-pip python-setuptools python-wheel patch - apt-get install git bzip2 file findutils gzip hg svn sudo tar which unzip xz zip libselinux-python + apt-get install ansible python-kerberos python-selinux python-winrm python-xmltodict sshpass bzip2 file findutils gzip tar unzip zip python-keyczar python-boto python-dnspython python-pyrax python-sphere FOUND="yes" FAMILY="debian" fi @@ -50,7 +50,7 @@ if [ `grep -qi ubuntu /etc/lsb-release` ] || [ `grep -qi ubuntu /etc/os-release # apt-add-repository ppa:ansible/ansible # apt-get update # apt-get install ansible git python-pip python-setuptools python-wheel patch - apt-get install git bzip2 file findutils gzip hg svn sudo tar which unzip xz zip libselinux-python + apt-get install ansible python-kerberos python-selinux python-winrm python-xmltodict sshpass bzip2 file findutils gzip tar unzip zip python-keyczar python-boto python-dnspython python-pyrax python-sphere FOUND="yes" FAMILY="debian" fi @@ -59,7 +59,7 @@ if [ `grep -qi raspbian /etc/*elease` ]; then # apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 # apt-get update # apt-get install ansible git python-pip python-setuptools python-wheel patch - apt-get install git bzip2 file findutils gzip hg svn sudo tar which unzip xz zip libselinux-python + apt-get install ansible python-kerberos python-selinux python-winrm python-xmltodict sshpass bzip2 file findutils gzip tar unzip zip python-keyczar python-boto python-dnspython python-pyrax python-sphere FOUND="yes" FAMILY="debian" fi @@ -88,8 +88,8 @@ fi # latest 2.2 is 2.2.3.0 2017-07-07 if [ $FAMILY = "debian" ]; then - echo 'WARN: Trying to install ansible via pip without some dependencies' - echo 'WARN: Not all functionality of ansible may be available' +# echo 'WARN: Trying to install ansible via pip without some dependencies' +# echo 'WARN: Not all functionality of ansible may be available' pip install ansible==2.3.1 --disable-pip-version-check fi mkdir -p /etc/ansible/ From dd6c91b3d0343ee94760def57664458af9cdef70 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sun, 17 Sep 2017 16:11:23 -0500 Subject: [PATCH 03/21] stach thoughts --- scripts/install_ansible | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/scripts/install_ansible b/scripts/install_ansible index e7db96e19..8ede3d923 100755 --- a/scripts/install_ansible +++ b/scripts/install_ansible @@ -17,6 +17,9 @@ if [ -f /etc/fedora-release ]; then FOUND="yes" FAMILY="redhat" fi +# might have to revisit dependencies with a redhat dialect +# ansible python-kerberos python-selinux python-winrm python-xmltodict sshpass bzip2 file findutils gzip tar unzip zip python-keyczar python-boto python-dnspython python-pyrax python-sphere + if [ -f /etc/centos-release ]; then yum -y upgrade yum -y install ca-certificates nss epel-release @@ -36,7 +39,8 @@ if [ -f /etc/olpc-release ]; then fi if [ -f /etc/debian_version ]; then -# echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main" >> /etc/apt/sources.list +# might pickup usbmount + echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main" >> /etc/apt/sources.list # apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 # apt-get update # apt-get install ansible git python-pip python-setuptools python-wheel patch @@ -69,7 +73,9 @@ if [ ! $FOUND = "yes" ]; then exit 1 fi +# latest pip 2.2 is 2.2.3.0 on 2017-07-07 # ansible-2.3.1.0-1.el7.noarch.rpm from 2017-06-01 + if [ $FAMILY = "redhat" ]; then VER=`ansible --version|head -n 1|cut -f 2 -d " "` #(returns 2.3.1.0) 2017-07-07 echo "ansible version installed via package manager $VER" @@ -78,6 +84,7 @@ fi ### start pip isolation if [ $FAMILY = "debian" ]; then + VER=`ansible --version|head -n 1|cut -f 2 -d " "` #(returns 2.3.1.0) 2017-07-07 apt-get install python-pip python-setuptools python-wheel patch fi ### @@ -86,12 +93,11 @@ fi #pip upgrades here if needed ### -# latest 2.2 is 2.2.3.0 2017-07-07 -if [ $FAMILY = "debian" ]; then +#if [ $FAMILY = "debian" ]; then # echo 'WARN: Trying to install ansible via pip without some dependencies' # echo 'WARN: Not all functionality of ansible may be available' - pip install ansible==2.3.1 --disable-pip-version-check -fi +# pip install ansible==2.3.1 --disable-pip-version-check +#fi mkdir -p /etc/ansible/ echo -e '[local]\nlocalhost\n' > /etc/ansible/hosts From 4890eeb64e7e086b6f83032c03513b645f9785d7 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Fri, 22 Sep 2017 02:50:44 -0500 Subject: [PATCH 04/21] slim down install, workflow, and notes/thoughts --- scripts/install_ansible | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/scripts/install_ansible b/scripts/install_ansible index 8ede3d923..6631ebfb7 100755 --- a/scripts/install_ansible +++ b/scripts/install_ansible @@ -3,7 +3,7 @@ set -e FOUND="" URL="NA" -if [ $(which ansible-playbook) ]; then +if [ $(which ansible-playbookx) ]; then echo "Ansible installed exiting..." exit 0 fi @@ -39,31 +39,33 @@ if [ -f /etc/olpc-release ]; then fi if [ -f /etc/debian_version ]; then -# might pickup usbmount - echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main" >> /etc/apt/sources.list +# might pickup usbmount confirm ppa location +# echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main" >> /etc/apt/sources.list # apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 # apt-get update -# apt-get install ansible git python-pip python-setuptools python-wheel patch - apt-get install ansible python-kerberos python-selinux python-winrm python-xmltodict sshpass bzip2 file findutils gzip tar unzip zip python-keyczar python-boto python-dnspython python-pyrax python-sphere + apt-get install ansible git python-pip python-setuptools python-wheel patch +# apt-get install ansible python-kerberos python-selinux python-winrm python-xmltodict sshpass bzip2 file findutils gzip tar unzip zip python-keyczar python-boto python-dnspython python-pyrax python-sphere FOUND="yes" FAMILY="debian" fi if [ `grep -qi ubuntu /etc/lsb-release` ] || [ `grep -qi ubuntu /etc/os-release` ]; then apt-get update +# confirm PPA location # apt-get install software-properties-common # apt-add-repository ppa:ansible/ansible # apt-get update -# apt-get install ansible git python-pip python-setuptools python-wheel patch - apt-get install ansible python-kerberos python-selinux python-winrm python-xmltodict sshpass bzip2 file findutils gzip tar unzip zip python-keyczar python-boto python-dnspython python-pyrax python-sphere + apt-get install ansible git python-pip python-setuptools python-wheel patch +# apt-get install ansible python-kerberos python-selinux python-winrm python-xmltodict sshpass bzip2 file findutils gzip tar unzip zip python-keyczar python-boto python-dnspython python-pyrax python-sphere FOUND="yes" FAMILY="debian" fi +# Has 2.2.1 if [ `grep -qi raspbian /etc/*elease` ]; then apt-get update # apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 # apt-get update -# apt-get install ansible git python-pip python-setuptools python-wheel patch - apt-get install ansible python-kerberos python-selinux python-winrm python-xmltodict sshpass bzip2 file findutils gzip tar unzip zip python-keyczar python-boto python-dnspython python-pyrax python-sphere + apt-get install ansible git python-pip python-setuptools python-wheel patch +# apt-get install ansible python-kerberos python-selinux python-winrm python-xmltodict sshpass bzip2 file findutils gzip tar unzip zip python-keyczar python-boto python-dnspython python-pyrax python-sphere FOUND="yes" FAMILY="debian" fi @@ -75,22 +77,23 @@ fi # latest pip 2.2 is 2.2.3.0 on 2017-07-07 # ansible-2.3.1.0-1.el7.noarch.rpm from 2017-06-01 - -if [ $FAMILY = "redhat" ]; then VER=`ansible --version|head -n 1|cut -f 2 -d " "` #(returns 2.3.1.0) 2017-07-07 echo "ansible version installed via package manager $VER" - # rpm -e ansible + +### start ansible pip install TODO add venv location /opt/iiab/anisble +if [ $FAMILY = "redhat" ]; then + # rpm -e ansible + # pip install ansible==2.3.1 --disable-pip-version-check fi -### start pip isolation if [ $FAMILY = "debian" ]; then - VER=`ansible --version|head -n 1|cut -f 2 -d " "` #(returns 2.3.1.0) 2017-07-07 - apt-get install python-pip python-setuptools python-wheel patch + # apt remove ansible + # pip install ansible==2.3.1 --disable-pip-version-check fi ### ### -#pip upgrades here if needed +# other pip upgrades here if needed ### #if [ $FAMILY = "debian" ]; then From 1006b31a5f951eb0ef3c709baf667d74afe485ce Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Fri, 22 Sep 2017 05:12:06 -0400 Subject: [PATCH 05/21] workflow --- scripts/install_ansible | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/scripts/install_ansible b/scripts/install_ansible index 6631ebfb7..0a039c342 100755 --- a/scripts/install_ansible +++ b/scripts/install_ansible @@ -1,9 +1,8 @@ -#!/bin/bash -x +#!/bin/bash -e # required to start loading IIAB with ansible -set -e FOUND="" URL="NA" -if [ $(which ansible-playbookx) ]; then +if [ $(which ansible-playbook) ]; then echo "Ansible installed exiting..." exit 0 fi @@ -35,7 +34,7 @@ if [ -f /etc/olpc-release ]; then yum -y install python-pip python-setuptools python-wheel patch pip install --upgrade pip setuptools wheel #EOL just do it FOUND="yes" - FAMILY="debian" + FAMILY="olpc" fi if [ -f /etc/debian_version ]; then @@ -77,24 +76,20 @@ fi # latest pip 2.2 is 2.2.3.0 on 2017-07-07 # ansible-2.3.1.0-1.el7.noarch.rpm from 2017-06-01 - VER=`ansible --version|head -n 1|cut -f 2 -d " "` #(returns 2.3.1.0) 2017-07-07 - echo "ansible version installed via package manager $VER" ### start ansible pip install TODO add venv location /opt/iiab/anisble -if [ $FAMILY = "redhat" ]; then - # rpm -e ansible - # pip install ansible==2.3.1 --disable-pip-version-check +if [ $FAMILY = "olpc" ]; then + pip install ansible==2.2.1 --disable-pip-version-check + VER=`ansible --version|head -n 1|cut -f 2 -d " "` + echo "ansible version installed via pip $VER" fi -if [ $FAMILY = "debian" ]; then - # apt remove ansible - # pip install ansible==2.3.1 --disable-pip-version-check -fi -### - -### -# other pip upgrades here if needed -### +#if [ $FAMILY = "debian" ]; then +# rpm -e ansible +# pip install ansible==2.2.1 --disable-pip-version-check +#fi +VER=`ansible --version|head -n 1|cut -f 2 -d " "` +echo "ansible version installed via package manager $VER" #if [ $FAMILY = "debian" ]; then # echo 'WARN: Trying to install ansible via pip without some dependencies' @@ -105,3 +100,6 @@ mkdir -p /etc/ansible/ echo -e '[local]\nlocalhost\n' > /etc/ansible/hosts ### end ansible routine +### +# other pip upgrades here if needed +### From c3b0435f32c4ce863cec56fb11f5a93ab6f41d63 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Mon, 25 Sep 2017 23:42:00 -0500 Subject: [PATCH 06/21] promote install_ansible --- scripts/ansible | 203 ++++++++++++++++++++-------------------- scripts/ansible-2.2.0 | 106 +++++++++++++++++++++ scripts/install_ansible | 105 --------------------- 3 files changed, 207 insertions(+), 207 deletions(-) create mode 100755 scripts/ansible-2.2.0 delete mode 100755 scripts/install_ansible diff --git a/scripts/ansible b/scripts/ansible index c861c7c4e..0a039c342 100755 --- a/scripts/ansible +++ b/scripts/ansible @@ -1,106 +1,105 @@ -#!/bin/bash -x -#TODO.md -yum_makecache_retry() { - tries=0 - until [ $tries -ge 5 ] - do - yum makecache && break - let tries++ - sleep 1 - done -} - -if [ "x$KITCHEN_LOG" = "xDEBUG" -o "x$OMNIBUS_ANSIBLE_LOG" = "xDEBUG" ]; then - export PS4='(${BASH_SOURCE}:${LINENO}): - [${SHLVL},${BASH_SUBSHELL},$?] $ ' - set -x +#!/bin/bash -e +# required to start loading IIAB with ansible +FOUND="" +URL="NA" +if [ $(which ansible-playbook) ]; then + echo "Ansible installed exiting..." + exit 0 fi +echo "Installing --- Please Wait" +if [ -f /etc/fedora-release ]; then + VER=`grep VERSION_ID /etc/*elease | cut -d= -f2` + URL=https://github.com/jvonau/iiab/blob/ansible/vars/fedora-$VER.yml + dnf -y upgrade + 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 + FOUND="yes" + FAMILY="redhat" +fi +# might have to revisit dependencies with a redhat dialect +# ansible python-kerberos python-selinux python-winrm python-xmltodict sshpass bzip2 file findutils gzip tar unzip zip python-keyczar python-boto python-dnspython python-pyrax python-sphere -if [ ! $(which ansible-playbook) ]; then - if [ -f /etc/centos-release ] || [ -f /etc/redhat-release ] || [ -f /etc/oracle-release ] || [ -f /etc/system-release ] || grep -q 'Amazon Linux' /etc/system-release; then - - # Install required Python libs and pip - # Fix EPEL Metalink SSL error - # - workaround: https://community.hpcloud.com/article/centos-63-instance-giving-cannot-retrieve-metalink-repository-epel-error - # - SSL secure solution: Update ca-certs!! - # - http://stackoverflow.com/q/26734777/645491#27667111 - # - http://serverfault.com/q/637549/77156 - # - http://unix.stackexchange.com/a/163368/7688 +if [ -f /etc/centos-release ]; then + yum -y upgrade + yum -y install ca-certificates nss epel-release + yum -y install ansible 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 + FOUND="yes" + FAMILY="redhat" +fi +if [ -f /etc/olpc-release ]; then + yum -y upgrade yum -y install ca-certificates nss - yum clean all - rm -rf /var/cache/yum - yum_makecache_retry - yum -y install epel-release - # One more time with EPEL to avoid failures - yum_makecache_retry - - yum -y install python-pip PyYAML python-jinja2 python-httplib2 python-keyczar python-paramiko git - # If python-pip install failed and setuptools exists, try that - if [ -z "$(which pip)" -a -z "$(which easy_install)" ]; then - yum -y install python-setuptools - easy_install pip - elif [ -z "$(which pip)" -a -n "$(which easy_install)" ]; then - easy_install pip - fi - - # Install passlib for encrypt - yum -y groupinstall "Development tools" - yum -y install python-devel MySQL-python sshpass && pip install pyrax pysphere boto passlib dnspython - - # Install Ansible module dependencies - yum -y install bzip2 file findutils git gzip hg svn sudo tar which unzip xz zip libselinux-python - [ -n "$(yum search procps-ng)" ] && yum -y install procps-ng || yum -y install procps - elif [ -f /etc/debian_version ] || [ grep -qi ubuntu /etc/lsb-release ] || grep -qi ubuntu /etc/os-release; then - apt-get update - # Install via package - # apt-get update && \ - # apt-get install --no-install-recommends -y software-properties-common && \ - # apt-add-repository ppa:ansible/ansible && \ - # apt-get update && \ - # apt-get install -y ansible - - # Install required Python libs and pip - apt-get install -y python-pip python-yaml python-jinja2 python-httplib2 python-paramiko python-pkg-resources - [ -n "$( apt-cache search python-keyczar )" ] && apt-get install -y python-keyczar - if ! apt-get install -y git ; then - apt-get install -y git-core - fi - # If python-pip install failed and setuptools exists, try that - if [ -z "$(which pip)" -a -z "$(which easy_install)" ]; then - apt-get -y install python-setuptools - easy_install pip - elif [ -z "$(which pip)" -a -n "$(which easy_install)" ]; then - easy_install pip - fi - # If python-keyczar apt package does not exist, use pip - [ -z "$( apt-cache search python-keyczar )" ] && sudo pip install python-keyczar - - # Install passlib for encrypt - apt-get install -y build-essential - apt-get install -y python-all-dev python-mysqldb sshpass && pip install pyrax pysphere boto passlib dnspython - - # Install Ansible module dependencies - apt-get install -y bzip2 file findutils git gzip mercurial procps subversion sudo tar debianutils unzip xz-utils zip python-selinux - - else - echo 'WARN: Could not detect distro or distro unsupported' - echo 'WARN: Trying to install ansible via pip without some dependencies' - echo 'WARN: Not all functionality of ansible may be available' - fi - - mkdir /etc/ansible/ - echo -e '[local]\nlocalhost\n' > /etc/ansible/hosts - pip install ansible==2.2 - - if [ -f /etc/centos-release ] || [ -f /etc/redhat-release ] || [ -f /etc/oracle-release ] || [ -f /etc/system-release ] || grep -q 'Amazon Linux' /etc/system-release; then - # Fix for pycrypto pip / yum issue - # https://github.com/ansible/ansible/issues/276 - if ansible --version 2>&1 | grep -q "AttributeError: 'module' object has no attribute 'HAVE_DECL_MPZ_POWM_SEC'" ; then - echo 'WARN: Re-installing python-crypto package to workaround ansible/ansible#276' - echo 'WARN: https://github.com/ansible/ansible/issues/276' - pip uninstall -y pycrypto - yum erase -y python-crypto - yum install -y python-crypto python-paramiko - fi - fi - + 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 + FOUND="yes" + FAMILY="olpc" fi + +if [ -f /etc/debian_version ]; then +# might pickup usbmount confirm ppa location +# echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main" >> /etc/apt/sources.list +# apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 +# apt-get update + apt-get install ansible git python-pip python-setuptools python-wheel patch +# apt-get install ansible python-kerberos python-selinux python-winrm python-xmltodict sshpass bzip2 file findutils gzip tar unzip zip python-keyczar python-boto python-dnspython python-pyrax python-sphere + FOUND="yes" + FAMILY="debian" +fi +if [ `grep -qi ubuntu /etc/lsb-release` ] || [ `grep -qi ubuntu /etc/os-release` ]; then + apt-get update +# confirm PPA location +# apt-get install software-properties-common +# apt-add-repository ppa:ansible/ansible +# apt-get update + apt-get install ansible git python-pip python-setuptools python-wheel patch +# apt-get install ansible python-kerberos python-selinux python-winrm python-xmltodict sshpass bzip2 file findutils gzip tar unzip zip python-keyczar python-boto python-dnspython python-pyrax python-sphere + FOUND="yes" + FAMILY="debian" +fi +# Has 2.2.1 +if [ `grep -qi raspbian /etc/*elease` ]; then + apt-get update +# apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 +# apt-get update + apt-get install ansible git python-pip python-setuptools python-wheel patch +# apt-get install ansible python-kerberos python-selinux python-winrm python-xmltodict sshpass bzip2 file findutils gzip tar unzip zip python-keyczar python-boto python-dnspython python-pyrax python-sphere + FOUND="yes" + FAMILY="debian" +fi + +if [ ! $FOUND = "yes" ]; then + echo 'WARN: Could not detect distro or distro unsupported' + exit 1 +fi + +# latest pip 2.2 is 2.2.3.0 on 2017-07-07 +# ansible-2.3.1.0-1.el7.noarch.rpm from 2017-06-01 + +### 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 + VER=`ansible --version|head -n 1|cut -f 2 -d " "` + echo "ansible version installed via pip $VER" +fi + +#if [ $FAMILY = "debian" ]; then +# rpm -e ansible +# pip install ansible==2.2.1 --disable-pip-version-check +#fi +VER=`ansible --version|head -n 1|cut -f 2 -d " "` +echo "ansible version installed via package manager $VER" + +#if [ $FAMILY = "debian" ]; then +# echo 'WARN: Trying to install ansible via pip without some dependencies' +# echo 'WARN: Not all functionality of ansible may be available' +# pip install ansible==2.3.1 --disable-pip-version-check +#fi +mkdir -p /etc/ansible/ +echo -e '[local]\nlocalhost\n' > /etc/ansible/hosts + +### end ansible routine +### +# other pip upgrades here if needed +### diff --git a/scripts/ansible-2.2.0 b/scripts/ansible-2.2.0 new file mode 100755 index 000000000..c861c7c4e --- /dev/null +++ b/scripts/ansible-2.2.0 @@ -0,0 +1,106 @@ +#!/bin/bash -x +#TODO.md +yum_makecache_retry() { + tries=0 + until [ $tries -ge 5 ] + do + yum makecache && break + let tries++ + sleep 1 + done +} + +if [ "x$KITCHEN_LOG" = "xDEBUG" -o "x$OMNIBUS_ANSIBLE_LOG" = "xDEBUG" ]; then + export PS4='(${BASH_SOURCE}:${LINENO}): - [${SHLVL},${BASH_SUBSHELL},$?] $ ' + set -x +fi + +if [ ! $(which ansible-playbook) ]; then + if [ -f /etc/centos-release ] || [ -f /etc/redhat-release ] || [ -f /etc/oracle-release ] || [ -f /etc/system-release ] || grep -q 'Amazon Linux' /etc/system-release; then + + # Install required Python libs and pip + # Fix EPEL Metalink SSL error + # - workaround: https://community.hpcloud.com/article/centos-63-instance-giving-cannot-retrieve-metalink-repository-epel-error + # - SSL secure solution: Update ca-certs!! + # - http://stackoverflow.com/q/26734777/645491#27667111 + # - http://serverfault.com/q/637549/77156 + # - http://unix.stackexchange.com/a/163368/7688 + yum -y install ca-certificates nss + yum clean all + rm -rf /var/cache/yum + yum_makecache_retry + yum -y install epel-release + # One more time with EPEL to avoid failures + yum_makecache_retry + + yum -y install python-pip PyYAML python-jinja2 python-httplib2 python-keyczar python-paramiko git + # If python-pip install failed and setuptools exists, try that + if [ -z "$(which pip)" -a -z "$(which easy_install)" ]; then + yum -y install python-setuptools + easy_install pip + elif [ -z "$(which pip)" -a -n "$(which easy_install)" ]; then + easy_install pip + fi + + # Install passlib for encrypt + yum -y groupinstall "Development tools" + yum -y install python-devel MySQL-python sshpass && pip install pyrax pysphere boto passlib dnspython + + # Install Ansible module dependencies + yum -y install bzip2 file findutils git gzip hg svn sudo tar which unzip xz zip libselinux-python + [ -n "$(yum search procps-ng)" ] && yum -y install procps-ng || yum -y install procps + elif [ -f /etc/debian_version ] || [ grep -qi ubuntu /etc/lsb-release ] || grep -qi ubuntu /etc/os-release; then + apt-get update + # Install via package + # apt-get update && \ + # apt-get install --no-install-recommends -y software-properties-common && \ + # apt-add-repository ppa:ansible/ansible && \ + # apt-get update && \ + # apt-get install -y ansible + + # Install required Python libs and pip + apt-get install -y python-pip python-yaml python-jinja2 python-httplib2 python-paramiko python-pkg-resources + [ -n "$( apt-cache search python-keyczar )" ] && apt-get install -y python-keyczar + if ! apt-get install -y git ; then + apt-get install -y git-core + fi + # If python-pip install failed and setuptools exists, try that + if [ -z "$(which pip)" -a -z "$(which easy_install)" ]; then + apt-get -y install python-setuptools + easy_install pip + elif [ -z "$(which pip)" -a -n "$(which easy_install)" ]; then + easy_install pip + fi + # If python-keyczar apt package does not exist, use pip + [ -z "$( apt-cache search python-keyczar )" ] && sudo pip install python-keyczar + + # Install passlib for encrypt + apt-get install -y build-essential + apt-get install -y python-all-dev python-mysqldb sshpass && pip install pyrax pysphere boto passlib dnspython + + # Install Ansible module dependencies + apt-get install -y bzip2 file findutils git gzip mercurial procps subversion sudo tar debianutils unzip xz-utils zip python-selinux + + else + echo 'WARN: Could not detect distro or distro unsupported' + echo 'WARN: Trying to install ansible via pip without some dependencies' + echo 'WARN: Not all functionality of ansible may be available' + fi + + mkdir /etc/ansible/ + echo -e '[local]\nlocalhost\n' > /etc/ansible/hosts + pip install ansible==2.2 + + if [ -f /etc/centos-release ] || [ -f /etc/redhat-release ] || [ -f /etc/oracle-release ] || [ -f /etc/system-release ] || grep -q 'Amazon Linux' /etc/system-release; then + # Fix for pycrypto pip / yum issue + # https://github.com/ansible/ansible/issues/276 + if ansible --version 2>&1 | grep -q "AttributeError: 'module' object has no attribute 'HAVE_DECL_MPZ_POWM_SEC'" ; then + echo 'WARN: Re-installing python-crypto package to workaround ansible/ansible#276' + echo 'WARN: https://github.com/ansible/ansible/issues/276' + pip uninstall -y pycrypto + yum erase -y python-crypto + yum install -y python-crypto python-paramiko + fi + fi + +fi diff --git a/scripts/install_ansible b/scripts/install_ansible deleted file mode 100755 index 0a039c342..000000000 --- a/scripts/install_ansible +++ /dev/null @@ -1,105 +0,0 @@ -#!/bin/bash -e -# required to start loading IIAB with ansible -FOUND="" -URL="NA" -if [ $(which ansible-playbook) ]; then - echo "Ansible installed exiting..." - exit 0 -fi -echo "Installing --- Please Wait" -if [ -f /etc/fedora-release ]; then - VER=`grep VERSION_ID /etc/*elease | cut -d= -f2` - URL=https://github.com/jvonau/iiab/blob/ansible/vars/fedora-$VER.yml - dnf -y upgrade - 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 - FOUND="yes" - FAMILY="redhat" -fi -# might have to revisit dependencies with a redhat dialect -# ansible python-kerberos python-selinux python-winrm python-xmltodict sshpass bzip2 file findutils gzip tar unzip zip python-keyczar python-boto python-dnspython python-pyrax python-sphere - -if [ -f /etc/centos-release ]; then - yum -y upgrade - yum -y install ca-certificates nss epel-release - yum -y install ansible 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 - FOUND="yes" - FAMILY="redhat" -fi -if [ -f /etc/olpc-release ]; then - yum -y upgrade - 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 - FOUND="yes" - FAMILY="olpc" -fi - -if [ -f /etc/debian_version ]; then -# might pickup usbmount confirm ppa location -# echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main" >> /etc/apt/sources.list -# apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 -# apt-get update - apt-get install ansible git python-pip python-setuptools python-wheel patch -# apt-get install ansible python-kerberos python-selinux python-winrm python-xmltodict sshpass bzip2 file findutils gzip tar unzip zip python-keyczar python-boto python-dnspython python-pyrax python-sphere - FOUND="yes" - FAMILY="debian" -fi -if [ `grep -qi ubuntu /etc/lsb-release` ] || [ `grep -qi ubuntu /etc/os-release` ]; then - apt-get update -# confirm PPA location -# apt-get install software-properties-common -# apt-add-repository ppa:ansible/ansible -# apt-get update - apt-get install ansible git python-pip python-setuptools python-wheel patch -# apt-get install ansible python-kerberos python-selinux python-winrm python-xmltodict sshpass bzip2 file findutils gzip tar unzip zip python-keyczar python-boto python-dnspython python-pyrax python-sphere - FOUND="yes" - FAMILY="debian" -fi -# Has 2.2.1 -if [ `grep -qi raspbian /etc/*elease` ]; then - apt-get update -# apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 -# apt-get update - apt-get install ansible git python-pip python-setuptools python-wheel patch -# apt-get install ansible python-kerberos python-selinux python-winrm python-xmltodict sshpass bzip2 file findutils gzip tar unzip zip python-keyczar python-boto python-dnspython python-pyrax python-sphere - FOUND="yes" - FAMILY="debian" -fi - -if [ ! $FOUND = "yes" ]; then - echo 'WARN: Could not detect distro or distro unsupported' - exit 1 -fi - -# latest pip 2.2 is 2.2.3.0 on 2017-07-07 -# ansible-2.3.1.0-1.el7.noarch.rpm from 2017-06-01 - -### 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 - VER=`ansible --version|head -n 1|cut -f 2 -d " "` - echo "ansible version installed via pip $VER" -fi - -#if [ $FAMILY = "debian" ]; then -# rpm -e ansible -# pip install ansible==2.2.1 --disable-pip-version-check -#fi -VER=`ansible --version|head -n 1|cut -f 2 -d " "` -echo "ansible version installed via package manager $VER" - -#if [ $FAMILY = "debian" ]; then -# echo 'WARN: Trying to install ansible via pip without some dependencies' -# echo 'WARN: Not all functionality of ansible may be available' -# pip install ansible==2.3.1 --disable-pip-version-check -#fi -mkdir -p /etc/ansible/ -echo -e '[local]\nlocalhost\n' > /etc/ansible/hosts - -### end ansible routine -### -# other pip upgrades here if needed -### From ce340e0d80a7293185553d7f0c1732d51e16dfbc Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Tue, 26 Sep 2017 00:20:55 -0500 Subject: [PATCH 07/21] use -y for automation --- scripts/ansible | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/ansible b/scripts/ansible index 0a039c342..f192876c6 100755 --- a/scripts/ansible +++ b/scripts/ansible @@ -41,19 +41,19 @@ if [ -f /etc/debian_version ]; then # might pickup usbmount confirm ppa location # echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main" >> /etc/apt/sources.list # apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 -# apt-get update - apt-get install ansible git python-pip python-setuptools python-wheel patch + apt-get -y update + apt-get -y install ansible git python-pip python-setuptools python-wheel patch # apt-get install ansible python-kerberos python-selinux python-winrm python-xmltodict sshpass bzip2 file findutils gzip tar unzip zip python-keyczar python-boto python-dnspython python-pyrax python-sphere FOUND="yes" FAMILY="debian" fi if [ `grep -qi ubuntu /etc/lsb-release` ] || [ `grep -qi ubuntu /etc/os-release` ]; then - apt-get update + apt-get -y update # confirm PPA location # apt-get install software-properties-common # apt-add-repository ppa:ansible/ansible # apt-get update - apt-get install ansible git python-pip python-setuptools python-wheel patch + apt-get -y install ansible git python-pip python-setuptools python-wheel patch # apt-get install ansible python-kerberos python-selinux python-winrm python-xmltodict sshpass bzip2 file findutils gzip tar unzip zip python-keyczar python-boto python-dnspython python-pyrax python-sphere FOUND="yes" FAMILY="debian" @@ -62,8 +62,8 @@ fi if [ `grep -qi raspbian /etc/*elease` ]; then apt-get update # apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 -# apt-get update - apt-get install ansible git python-pip python-setuptools python-wheel patch + apt-get -y update + apt-get -y install ansible git python-pip python-setuptools python-wheel patch # apt-get install ansible python-kerberos python-selinux python-winrm python-xmltodict sshpass bzip2 file findutils gzip tar unzip zip python-keyczar python-boto python-dnspython python-pyrax python-sphere FOUND="yes" FAMILY="debian" From ff1e3a297878409fcb084a9780c06a2dd061b79c Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Tue, 26 Sep 2017 10:05:05 -0500 Subject: [PATCH 08/21] add patching routine --- scripts/ansible | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/scripts/ansible b/scripts/ansible index f192876c6..de3351d12 100755 --- a/scripts/ansible +++ b/scripts/ansible @@ -2,8 +2,10 @@ # required to start loading IIAB with ansible FOUND="" URL="NA" +# TODO add check for version - to revese patching if upgrading if [ $(which ansible-playbook) ]; then - echo "Ansible installed exiting..." + VER=`ansible --version|head -n 1|cut -f 2 -d " "` + echo "Ansible $VER installed exiting..." exit 0 fi echo "Installing --- Please Wait" @@ -84,12 +86,22 @@ if [ $FAMILY = "olpc" ]; then 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 +VER=`ansible --version|head -n 1|cut -f 2 -d " "` +echo "ansible version installed via package manager $VER" + +# sample only #if [ $FAMILY = "debian" ]; then # rpm -e ansible # pip install ansible==2.2.1 --disable-pip-version-check #fi -VER=`ansible --version|head -n 1|cut -f 2 -d " "` -echo "ansible version installed via package manager $VER" #if [ $FAMILY = "debian" ]; then # echo 'WARN: Trying to install ansible via pip without some dependencies' From fce0b482cb5be539d2f743713fb1c6feb4a3fd46 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Tue, 26 Sep 2017 10:10:41 -0500 Subject: [PATCH 09/21] avoid snowballing - add exits codes --- runansible | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/runansible b/runansible index 8368c0312..2970efdc2 100755 --- a/runansible +++ b/runansible @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -e # copy var files to /etc/iiab for subsequent use # if vars/local_vars.yml is missing, put a default one in place if [ ! -f ./vars/local_vars.yml ]; then @@ -14,7 +14,7 @@ if [ ! -f ./vars/local_vars.yml ]; then ;; *) echo "IIAB supports raspbian, debian, ubuntu, centos, and OLPC - exiting now..." - exit 0 + exit 1 ;; esac fi @@ -33,7 +33,7 @@ then echo "IIAB Playbook not found." echo "Please run this command from the top level of the git repo." echo "Exiting." - exit + exit 1 fi if [ ! -f /etc/ansible/facts.d/local_facts.fact ]; then From aafc29d1859150fef62d6289c016b21717b37a0f Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 27 Sep 2017 00:10:24 -0500 Subject: [PATCH 10/21] add upgrade check --- scripts/ansible | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/ansible b/scripts/ansible index de3351d12..cf92be708 100755 --- a/scripts/ansible +++ b/scripts/ansible @@ -3,6 +3,16 @@ FOUND="" 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 + echo "Ansible $VER installed updating" + pip install --upgrade ansible==2.2.1 --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 +# 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 " "` echo "Ansible $VER installed exiting..." From f9ad29959eccbeb8689d6d246e34d675399efb31 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 27 Sep 2017 00:11:15 -0500 Subject: [PATCH 11/21] have runansible execute scripts/ansible --- runansible | 1 + 1 file changed, 1 insertion(+) diff --git a/runansible b/runansible index 2970efdc2..d4b95bda6 100755 --- a/runansible +++ b/runansible @@ -1,4 +1,5 @@ #!/bin/bash -e +./scripts/ansible # copy var files to /etc/iiab for subsequent use # if vars/local_vars.yml is missing, put a default one in place if [ ! -f ./vars/local_vars.yml ]; then From 649ebb50815e61edcde185d5c1478bc617577b71 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 27 Sep 2017 00:44:46 -0500 Subject: [PATCH 12/21] add ppa for unbutu --- scripts/ansible | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/ansible b/scripts/ansible index cf92be708..d00a9d533 100755 --- a/scripts/ansible +++ b/scripts/ansible @@ -62,8 +62,8 @@ fi if [ `grep -qi ubuntu /etc/lsb-release` ] || [ `grep -qi ubuntu /etc/os-release` ]; then apt-get -y update # confirm PPA location -# apt-get install software-properties-common -# apt-add-repository ppa:ansible/ansible + apt-get install software-properties-common + apt-add-repository ppa:ansible/ansible # apt-get update apt-get -y install ansible git python-pip python-setuptools python-wheel patch # apt-get install ansible python-kerberos python-selinux python-winrm python-xmltodict sshpass bzip2 file findutils gzip tar unzip zip python-keyczar python-boto python-dnspython python-pyrax python-sphere From c7df5eb93d570438f12d8705476c872aebf2a20f Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 27 Sep 2017 13:32:47 -0500 Subject: [PATCH 13/21] enable ansible ppa for version 2.4.0 --- scripts/ansible | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/scripts/ansible b/scripts/ansible index d00a9d533..5d841e634 100755 --- a/scripts/ansible +++ b/scripts/ansible @@ -51,8 +51,8 @@ fi if [ -f /etc/debian_version ]; then # might pickup usbmount confirm ppa location -# echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main" >> /etc/apt/sources.list -# apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 + echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu xenial main" >> /etc/apt/sources.list + apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 apt-get -y update apt-get -y install ansible git python-pip python-setuptools python-wheel patch # apt-get install ansible python-kerberos python-selinux python-winrm python-xmltodict sshpass bzip2 file findutils gzip tar unzip zip python-keyczar python-boto python-dnspython python-pyrax python-sphere @@ -60,10 +60,12 @@ if [ -f /etc/debian_version ]; then FAMILY="debian" fi if [ `grep -qi ubuntu /etc/lsb-release` ] || [ `grep -qi ubuntu /etc/os-release` ]; then + echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu xenial main" >> /etc/apt/sources.list + apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 apt-get -y update # confirm PPA location - apt-get install software-properties-common - apt-add-repository ppa:ansible/ansible +# apt-get install software-properties-common +# apt-add-repository ppa:ansible/ansible # apt-get update apt-get -y install ansible git python-pip python-setuptools python-wheel patch # apt-get install ansible python-kerberos python-selinux python-winrm python-xmltodict sshpass bzip2 file findutils gzip tar unzip zip python-keyczar python-boto python-dnspython python-pyrax python-sphere @@ -72,8 +74,8 @@ if [ `grep -qi ubuntu /etc/lsb-release` ] || [ `grep -qi ubuntu /etc/os-release fi # Has 2.2.1 if [ `grep -qi raspbian /etc/*elease` ]; then - apt-get update -# apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 + echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu xenial main" >> /etc/apt/sources.list + apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 apt-get -y update apt-get -y install ansible git python-pip python-setuptools python-wheel patch # apt-get install ansible python-kerberos python-selinux python-winrm python-xmltodict sshpass bzip2 file findutils gzip tar unzip zip python-keyczar python-boto python-dnspython python-pyrax python-sphere @@ -100,10 +102,10 @@ fi # 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 +#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 VER=`ansible --version|head -n 1|cut -f 2 -d " "` echo "ansible version installed via package manager $VER" From 874d5a650d01b3547333e0d52ee928b855060712 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 27 Sep 2017 13:35:01 -0500 Subject: [PATCH 14/21] pip upgrade to 2.4.0 for older installs --- scripts/ansible | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/ansible b/scripts/ansible index 5d841e634..d67cac31b 100755 --- a/scripts/ansible +++ b/scripts/ansible @@ -7,8 +7,8 @@ if [ $(which ansible-playbook) ]; then VER=`ansible --version|head -n 1|cut -f 2 -d " "` if [ $VER="2.2.0.0" ]; then echo "Ansible $VER installed updating" - pip install --upgrade ansible==2.2.1 --disable-pip-version-check - sed -i 's/StrictVersion/LooseVersion/g' /usr/lib/python2.7/dist-packages/ansible/modules/core/web_infrastructure/htpasswd.py + 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 From f8d663d713cf4c0f71e23a4f6e941bff063f2392 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 27 Sep 2017 14:02:57 -0500 Subject: [PATCH 15/21] everybody will need to upgrade for now --- scripts/ansible | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/ansible b/scripts/ansible index d67cac31b..b2252e4fc 100755 --- a/scripts/ansible +++ b/scripts/ansible @@ -6,18 +6,18 @@ URL="NA" if [ $(which ansible-playbook) ]; then VER=`ansible --version|head -n 1|cut -f 2 -d " "` if [ $VER="2.2.0.0" ]; then - echo "Ansible $VER installed updating" + 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 # 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 " "` - echo "Ansible $VER installed exiting..." - exit 0 -fi +#if [ $(which ansible-playbook) ]; then +# VER=`ansible --version|head -n 1|cut -f 2 -d " "` +# echo "Ansible $VER installed exiting..." +# exit 0 +#fi echo "Installing --- Please Wait" if [ -f /etc/fedora-release ]; then VER=`grep VERSION_ID /etc/*elease | cut -d= -f2` From 88cd7d0fb6f077ee7e3f5de65b522521fad1ef04 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 27 Sep 2017 15:38:00 -0500 Subject: [PATCH 16/21] handle apt upgrades from 2.2.1 to 2.4.0 --- scripts/ansible | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) 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 From 8804ac926352f5fd0d389ffd251cb985ae621962 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 27 Sep 2017 16:04:43 -0500 Subject: [PATCH 17/21] add dirmngr so apt-key works --- scripts/ansible | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/ansible b/scripts/ansible index 868ed67cc..63565717e 100755 --- a/scripts/ansible +++ b/scripts/ansible @@ -5,7 +5,7 @@ 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 " "` - GOOD_VER="$VER | grep 2.4 | wc -l" + GOOD_VER=`echo $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 @@ -54,6 +54,7 @@ fi if [ -f /etc/debian_version ]; then # might pickup usbmount confirm ppa location echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu xenial main" >> /etc/apt/sources.list + apt-get -y install dirmngr apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 apt-get -y update apt-get -y install ansible git python-pip python-setuptools python-wheel patch @@ -63,6 +64,7 @@ if [ -f /etc/debian_version ]; then fi if [ `grep -qi ubuntu /etc/lsb-release` ] || [ `grep -qi ubuntu /etc/os-release` ]; then echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu xenial main" >> /etc/apt/sources.list + apt-get -y install dirmngr apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 apt-get -y update # confirm PPA location @@ -77,6 +79,7 @@ fi # Has 2.2.1 if [ `grep -qi raspbian /etc/*elease` ]; then echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu xenial main" >> /etc/apt/sources.list + apt-get -y install dirmngr apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 apt-get -y update apt-get -y install ansible git python-pip python-setuptools python-wheel patch From 1b2d4e1c7d90b219b969b078f1d508c3abf8e5f4 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 27 Sep 2017 16:40:03 -0500 Subject: [PATCH 18/21] tighten up regexp --- scripts/ansible | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/ansible b/scripts/ansible index 63565717e..64a7a4370 100755 --- a/scripts/ansible +++ b/scripts/ansible @@ -5,7 +5,7 @@ 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 " "` - GOOD_VER=`echo $VER | grep 2.4 | wc -l` + GOOD_VER=`echo $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 @@ -13,7 +13,6 @@ if [ $(which ansible-playbook) ]; then 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 " "` From 54b4a3c2b09f66980217d25a2f45674e7dcb7784 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Wed, 27 Sep 2017 22:50:16 -0500 Subject: [PATCH 19/21] find unbutu as a last resort to quite looking for /etc/lsb-release - exit if version is 2.4.0.0 --- scripts/ansible | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/scripts/ansible b/scripts/ansible index 64a7a4370..19f54d9f6 100755 --- a/scripts/ansible +++ b/scripts/ansible @@ -9,16 +9,19 @@ if [ $(which ansible-playbook) ]; then 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 - exit 0 + exit 0 + fi +# keep an eye out for 2.4.0.X in the future + if [ $VER = "2.4.0.0" ]; then + echo "Ansible $VER installed exiting..." + 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 " "` -# echo "Ansible $VER installed exiting..." -# exit 0 -#fi + echo "Installing --- Please Wait" if [ -f /etc/fedora-release ]; then VER=`grep VERSION_ID /etc/*elease | cut -d= -f2` @@ -51,7 +54,6 @@ if [ -f /etc/olpc-release ]; then fi if [ -f /etc/debian_version ]; then -# might pickup usbmount confirm ppa location echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu xenial main" >> /etc/apt/sources.list apt-get -y install dirmngr apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 @@ -61,20 +63,6 @@ if [ -f /etc/debian_version ]; then FOUND="yes" FAMILY="debian" fi -if [ `grep -qi ubuntu /etc/lsb-release` ] || [ `grep -qi ubuntu /etc/os-release` ]; then - echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu xenial main" >> /etc/apt/sources.list - apt-get -y install dirmngr - apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 - apt-get -y update -# confirm PPA location -# apt-get install software-properties-common -# apt-add-repository ppa:ansible/ansible -# apt-get update - apt-get -y install ansible git python-pip python-setuptools python-wheel patch -# apt-get install ansible python-kerberos python-selinux python-winrm python-xmltodict sshpass bzip2 file findutils gzip tar unzip zip python-keyczar python-boto python-dnspython python-pyrax python-sphere - FOUND="yes" - FAMILY="debian" -fi # Has 2.2.1 if [ `grep -qi raspbian /etc/*elease` ]; then echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu xenial main" >> /etc/apt/sources.list @@ -86,7 +74,22 @@ if [ `grep -qi raspbian /etc/*elease` ]; then FOUND="yes" FAMILY="debian" fi - +if [ ! $FOUND = "yes" ]; then + if [ `grep -qi ubuntu /etc/lsb-release` ] || [ `grep -qi ubuntu /etc/os-release` ]; then + echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu xenial main" >> /etc/apt/sources.list + apt-get -y install dirmngr + apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367 + apt-get -y update +#confirm PPA location +# apt-get install software-properties-common +# apt-add-repository ppa:ansible/ansible +# apt-get update + apt-get -y install ansible git python-pip python-setuptools python-wheel patch +# apt-get install ansible python-kerberos python-selinux python-winrm python-xmltodict sshpass bzip2 file findutils gzip tar unzip zip python-keyczar python-boto python-dnspython python-pyrax python-sphere + FOUND="yes" + FAMILY="debian" + fi +fi if [ ! $FOUND = "yes" ]; then echo 'WARN: Could not detect distro or distro unsupported' exit 1 From fd1fb25d06c53f3e90049b482f2b13f28548e1ed Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Thu, 28 Sep 2017 08:37:48 -0500 Subject: [PATCH 20/21] better undo patching - notes --- scripts/ansible | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/ansible b/scripts/ansible index 19f54d9f6..c8d9012d1 100755 --- a/scripts/ansible +++ b/scripts/ansible @@ -1,11 +1,15 @@ #!/bin/bash -e # required to start loading IIAB with ansible FOUND="" +VER="" +# below are unused for future use +GOOD_VER="" 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 " "` - GOOD_VER=`echo $VER | grep ^2.4 | wc -l` + GOOD_VER=`echo $VER | grep ^2.4` +# 2.2.0.0 -> 2.4.0 patching was not applied -just upgrade via pip 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 @@ -105,9 +109,10 @@ if [ $FAMILY = "olpc" ]; then echo "ansible version installed via pip $VER" fi -# handle 2.2.1 2.2.0.0 <-> 2.4.0 +# handle 2.2.1 -> 2.4.0 deb install undo patching +# unsure if install above will upgrade or skip - cover that now if [ $FAMILY = "debian" ]; then - if [ $GOOD_VER -lt 1 ]; then + if [ ! $VER == "" ]; 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 From ae1a64a970dce251c189895a5066717d1e9f860e Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Thu, 28 Sep 2017 11:00:05 -0500 Subject: [PATCH 21/21] remove autorun of scripts/ansible --- runansible | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runansible b/runansible index d4b95bda6..74c7013d0 100755 --- a/runansible +++ b/runansible @@ -1,5 +1,5 @@ #!/bin/bash -e -./scripts/ansible +# ./scripts/ansible # copy var files to /etc/iiab for subsequent use # if vars/local_vars.yml is missing, put a default one in place if [ ! -f ./vars/local_vars.yml ]; then