diff --git a/.travis.yml b/.travis.yml index 83c627442..119893b55 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,27 +1,32 @@ ---- language: python -python: "2.7" +python: 3.8 # "3.8" also works +dist: focal -# Use the new container infrastructure -dist: trusty -sudo: false - -# Install ansible addons: apt: + sources: + - sourceline: ppa:ansible/ansible packages: - - python-pip +# - python-pip # @arky had used this starting in 2018 + - ansible-base # Install latest ansible-base e.g. 2.10.6+, similar to https://github.com/iiab/iiab/blob/master/scripts/ansible +# - python3-pymysql # These 7-or-8 packages are not needed during this very rapid --syntax-check +# - python3-psycopg2 +# - python3-passlib +# - python3-pip +# - python3-setuptools + - python3-packaging # To avoid warning "packaging Python module unavailable; unable to validate collection..." +# - python3-venv +# - virtualenv install: - # Install ansible - - pip install ansible - - # Create ansible.cfg with correct roles_path and local_tmp - - "{ echo '[defaults]'; echo 'roles_path = ./roles/'; } >> ansible.cfg" +# - scripts/ansible # See #2105: fails to install latest Ansible (& ~4 Ansible Collections from collections.yml) due to Travis VM's disk layout/perms being different +# - pip install ansible # SLOW/OVERWEIGHT: installs Ansible 3.0.0+ with ~80 Ansible Collections +# - pip install ansible-base # ALSO WORKS e.g. if the above addons: / apt: section is commented out. To install latest ansible-base e.g. 2.10.6+, similar to https://github.com/iiab/iiab/blob/master/scripts/ansible + - ansible-galaxy collection install -r collections.yml # Install ~4 Ansible Collections + - "{ echo 'roles_path = ./roles/'; } >> ansible.cfg" # Add correct roles_path to ansible.cfg, appending to https://github.com/iiab/iiab/blob/master/ansible.cfg +# - "{ echo '[defaults]'; echo 'roles_path = ./roles/'; } >> ansible.cfg" # 2021-02-24: suddenly no longer works, with the newer ansible-base install methods above (error arises due to '[defaults]' appearing twice) +# - cat ansible.cfg # UNCOMMENT TO VERIFY! + - apt -a list ansible-base # VERIFY ansible-base VERSIONS OFFERED BY apt script: - # Basic role syntax check - ansible-playbook tests/test.yml -i tests/inventory --syntax-check - -#notifications: -# webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/scripts/ansible b/scripts/ansible index b7060d5b6..9000700f5 100755 --- a/scripts/ansible +++ b/scripts/ansible @@ -6,17 +6,36 @@ APT_PATH=/usr/bin # Avoids problematic /usr/local/bin/apt on Linux Mint CURR_VER="undefined" # Ansible version you currently have installed GOOD_VER="2.10.6" # Orig for 'yum install [rpm]' & XO laptops (pip install) -# We install latest 'ansible-base' from PPA: (may be more recent than GOOD-VER) -# https://launchpad.net/~ansible/+archive/ubuntu/ansible -# https://launchpad.net/~ansible/+archive/ubuntu/ansible-2.10 -# http://ppa.launchpad.net/ansible/ansible/ubuntu/pool/main/a/ansible-base/ -# https://github.com/ansible/ansible/commits/stable-2.10/changelogs/CHANGELOG-v2.10.rst -# IIAB implementers might instead consider these 2 GENERAL TECHNIQUES below +# We install the latest 'ansible-base' from PPA, using an OS 'CODENAME' below: +# https://launchpad.net/~ansible/+archive/ubuntu/ansible + +# 'lsb_release -sc' gives Mint 20 codename 'ulyana' etc: (TOO FINE-GRAINED) +if grep -q buster /etc/os-release /etc/debian_version; then + CODENAME=bionic # Debian 10, RaspiOS 10 & Buster-like distros +else + CODENAME=focal # Debian 11+, RaspiOS 11+, Ubuntu 20.04+, Mint 20+ (ETC) +fi + +# 'ansible-base' RELEASE LINKS FOR REFERENCE: +# http://ppa.launchpad.net/ansible/ansible/ubuntu/pool/main/a/ansible-base/ +# https://launchpad.net/~ansible/+archive/ubuntu/ansible-2.10 +# https://github.com/ansible/ansible/commits/stable-2.10/changelogs/CHANGELOG-v2.10.rst +# https://github.com/ansible/ansible/releases +# https://releases.ansible.com/ansible-base/ + +# FYI .travis.yml installs ansible-base in a slightly different way (PR #2689). + +# IIAB implementers might instead consider these 3 GENERAL TECHNIQUES below # ("in an emergency!") e.g. if you must install an older version of Ansible: -# TEMPORARILY USE ANSIBLE 2.9.17 (REMOVE IT WITH "pip uninstall ansible") -#pip install ansible==2.9.17 +# TEMPORARILY USE ansible-base 2.10.6 (REMOVE W/ "pip3 uninstall ansible-base") +#pip3 install ansible-base==2.10.6 # Start new shell, so /usr/local/bin works +#ansible-galaxy collection install -r collections.yml + +# TEMPORARILY USE ANSIBLE 2.9.18 (REMOVE IT WITH "pip uninstall ansible") +#apt install python-pip +#pip install ansible==2.9.18 # TEMPORARILY USE ANSIBLE 2.4.2 DUE TO 2.4.3 MEMORY BUG. Details: iiab/iiab#669 #echo "Install http://download.iiab.io/packages/ansible_2.4.2.0-1ppa~xenial_all.deb" @@ -61,7 +80,7 @@ fi echo -e "\napt update; install dirmngr; PPA to /etc/apt/sources.list.d/iiab-ansible.list\n" $APT_PATH/apt update $APT_PATH/apt -y install dirmngr -echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu bionic main" \ +echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu $CODENAME main" \ > /etc/apt/sources.list.d/iiab-ansible.list # In future we might instead consider 'add-apt-repository ppa:ansible/ansible' # or 'apt-add-repository ppa:ansible/bionic/ansible' etc, e.g. for streamlined @@ -78,7 +97,7 @@ echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu bionic main" \ echo -e '\nIF YOU FACE ERROR "signatures couldn'"'"'t be verified because the public key is not available" THEN REPEATEDLY RE-RUN "sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 93C4A3FD7BB9C367"\n' apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 93C4A3FD7BB9C367 -echo -e 'PPA source "deb http://ppa.launchpad.net/ansible/ansible/ubuntu bionic main"' +echo -e 'PPA source "deb http://ppa.launchpad.net/ansible/ansible/ubuntu '$CODENAME' main"' echo -e "successfully saved to /etc/apt/sources.list.d/iiab-ansible.list\n" echo -e "IF *OTHER* ANSIBLE SOURCES APPEAR BELOW, PLEASE MANUALLY REMOVE THEM TO" echo -e 'ENSURE ANSIBLE UPDATES CLEANLY: (then re-run this script to be sure!)\n' @@ -93,11 +112,13 @@ $APT_PATH/apt -y --allow-downgrades install ansible-base \ # (Re)running collection installs appears safe, with --force-with-deps to force # upgrade of collection and dependencies it pulls in. Note Ansible may support -# upgrading all collections cleanly in future. See PRs #2647 #2652 #2653 #2655 +# explicit upgrading of collections (--upgrade / -U flag) in version "2.11" +# with PR ansible/ansible#73336. See also IIAB PRs #2647 #2652 #2653 #2655. echo -e "\n\nIIAB requires these ~4 Ansible Collections: (we upgrade them here if possible!)\n" ansible-galaxy collection install --force-with-deps \ -r /opt/iiab/iiab/collections.yml \ -p /usr/share/ansible/collections +# 2021-02-24: Run 'ansible-galaxy collection list' to list those installed. # 2020-11-28: The ~3 Ansible Collections used by IIAB (~37MB) once lived here: # /root/.ansible/collections/ansible_collections # But going forward they'll be stored herein: