From 5bcd0c9dede7bd387bbdfc865f0b8dec60421950 Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Tue, 18 Feb 2025 01:10:48 -0600 Subject: [PATCH] for discussion --- ansible.cfg | 1 + scripts/ansible | 32 ++++++++++++++++++++++---------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/ansible.cfg b/ansible.cfg index deb5328ed..e1087d483 100644 --- a/ansible.cfg +++ b/ansible.cfg @@ -6,3 +6,4 @@ #squash_actions = apk, apt, dnf, homebrew, openbsd_pkg, pacman, pkgng, yum, zypper, package [defaults] interpreter_python=/usr/local/ansible/bin/python3 +collections_path=/usr/local/ansible/collections/ansible_collections/ diff --git a/scripts/ansible b/scripts/ansible index c5ab3e074..5ef9dfed9 100755 --- a/scripts/ansible +++ b/scripts/ansible @@ -9,6 +9,7 @@ APT_PATH=/usr/bin # Avoids problematic /usr/local/bin/apt on Linux Mint CURR_VER=undefined # Ansible version you have installed, e.g. [core 2.18.2] GOOD_VER=2.18.2 # Orig for 'yum install [rpm]' & XO laptops (pip install) +CWD=$(pwd) # 2021-06-22: The apt approach (with PPA source in /etc/apt/sources.list.d/ and # .gpg key etc) are commented out with ### below. Associated guidance/comments @@ -221,6 +222,15 @@ if [[ $(dpkg --print-architecture) == "i386" ]] && apt-cache show ansible-core > # 2023-08-10 #3613/#3615/#3617: apt-not-pip kludge for legacy 32-bit i386 # (DEBIAN 12+ ETC) avoids #3547 rust/wheels/cryptography compiling mess! $APT_PATH/apt -y install ansible-core # Bookworm ~= ansible-core 2.14.3 + 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: 'ansible-galaxy collection list' lists those installed. (#2659) +# 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: [~24MB for 4 Collections as of 2021-05-19] +# /usr/share/ansible/collections/ansible_collections else # 2023-03-22: OS's like Ubuntu 23.04 and Debian 12 (e.g. with Python 3.11+) ask # that virtual environments (venv) be used to safely isolate pip installs: @@ -285,21 +295,22 @@ EOF for bin in ansible*; do ln -sf /usr/local/ansible/bin/"$bin" /usr/local/bin/"$bin" done -fi # (Re)running collection installs appears safe, with --force-with-deps to force # upgrade of collection and dependencies it pulls in. Note Ansible may support # 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: 'ansible-galaxy collection list' lists those installed. (#2659) -# 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: [~24MB for 4 Collections as of 2021-05-19] -# /usr/share/ansible/collections/ansible_collections + echo "start is $CWD" + echo "current is $(pwd)" + echo -e "\n\nIIAB requires these ~4 Ansible Collections: (we upgrade them here if possible!)\n" + cp $CWD/collections.yml /usr/local/ansible/ + cd /usr/local/ansible/ + . bin/activate + bin/ansible-galaxy collection install --force-with-deps -r collections.yml -p collections + deactivate +fi +# But going forward they'll be stored herein: [~24MB for 4 Collections as of 2025-02-18] +# /usr/local/ansible/collections/ansible_collections # 2021-04-19: No longer needed, per PR #2743 testing #echo -e "\n\nCreating/verifying directory /etc/ansible & installing /etc/ansible/hosts\n" @@ -309,6 +320,7 @@ ansible-galaxy collection install --force-with-deps \ echo -e "\n\nSUCCESS! PLEASE VERIFY ANSIBLE WITH COMMANDS LIKE:\n" echo -e " ansible --version" echo -e " /usr/local/ansible/bin/pip3 show ansible-core" +echo -e " /usr/local/ansible/bin/ansible-galaxy collection list\n\n" echo -e ' apt -a list "ansible*"' echo -e " ansible-galaxy collection list\n\n" #echo -e "WARNING: Start a new Linux shell, if it changed from /usr/bin to /usr/local/bin\n\n"