diff --git a/ansible/playbooks/group_vars/all.yml b/ansible/playbooks/group_vars/all.yml index 2dfa2741..3a65717b 100644 --- a/ansible/playbooks/group_vars/all.yml +++ b/ansible/playbooks/group_vars/all.yml @@ -6,8 +6,8 @@ # below. Cargo tools install unversioned. Go # and rustup fetch the current version with the checksum published beside it. # -# What remains below is a selection rather than a version -- a Node LTS line, -# which NodeSource's signed repo then keeps patched. +# Node's LTS majors come from the Node.js release schedule at run time. The pair +# below is only the fallback for a run that cannot read it. # GitHub's anonymous release API allows 60 requests an hour PER IP, and a run # selecting infrastructure plus a couple of languages spends a good fraction of @@ -67,23 +67,22 @@ hyperi_release_env: # Two shapes, decided by what upstream actually publishes: # # signed repo node, gh, docker, git. The repo keeps the box current on -# its own via `apt/dnf upgrade`, so only the MAJOR is pinned -# here -- there is no patch version to chase, and routine OS -# updates carry the tool forward for free. +# its own via `apt/dnf upgrade`. NodeSource publishes one +# repo per major, so the role and hyperi-update move it to +# the newest LTS major the schedule names. # resolved artefact go, rustup, fnm. Upstream publishes no repo, so the role # asks upstream for the current release when it runs and # verifies the download against the checksum served with it. # -# Only the Node majors remain, because a major is a choice rather than a version -# to chase. Bumping one in a year is editing a number here. +# Every Node major past its LTS start and before its end of life is installed: +# the newest system-wide from NodeSource, so root, systemd units, +# semantic-release and CI resolve the same node, and the rest per user via fnm. +hyperi_node_schedule_url: https://raw.githubusercontent.com/nodejs/Release/main/schedule.json + hyperi_core_versions: - # Node n and n-1. n is installed system-wide from the NodeSource repo, so - # root, systemd units, semantic-release and CI all resolve the same node; - # n-1 is per-user via fnm, for projects not yet moved to n. 24 is Active LTS - # (Krypton), 22 is in maintenance. When 26 goes LTS in Oct 2026 these become - # 26 and 24. - node_major: 24 - node_major_previous: 22 + # Used only when the schedule above cannot be read. + node_major: 26 + node_majors_previous: [24, 22] # ============================================================================ # apt sources the roles own outright diff --git a/ansible/roles/contributor/tasks/git_scrub.yml b/ansible/roles/contributor/tasks/git_scrub.yml index dedd4342..4b5dd2a6 100644 --- a/ansible/roles/contributor/tasks/git_scrub.yml +++ b/ansible/roles/contributor/tasks/git_scrub.yml @@ -25,6 +25,15 @@ become: false environment: "{{ homebrew_env }}" + # Homebrew refuses formulae from a tap nobody has trusted. + - name: Trust the hyperi-io tap (macOS) + ansible.builtin.command: + cmd: brew trust --tap hyperi-io/tap + become: false + environment: "{{ homebrew_env }}" + register: contributor_git_scrub_trust + changed_when: "'Already trusted' not in contributor_git_scrub_trust.stdout" + # Earlier runs of this role put the release binary here. On an Intel Mac it # is also the path brew links into, so it has to go before the install. - name: Check for a git-scrub binary from the release tarball (macOS) diff --git a/ansible/roles/contributor/tasks/macbash.yml b/ansible/roles/contributor/tasks/macbash.yml index 4032af74..874d02d5 100644 --- a/ansible/roles/contributor/tasks/macbash.yml +++ b/ansible/roles/contributor/tasks/macbash.yml @@ -23,6 +23,15 @@ become: false environment: "{{ homebrew_env }}" + # Homebrew refuses formulae from a tap nobody has trusted. + - name: Trust the hyperi-io tap (macOS) + ansible.builtin.command: + cmd: brew trust --tap hyperi-io/tap + become: false + environment: "{{ homebrew_env }}" + register: contributor_macbash_trust + changed_when: "'Already trusted' not in contributor_macbash_trust.stdout" + - name: Install macbash via Homebrew (macOS) community.general.homebrew: name: macbash diff --git a/ansible/roles/developer/defaults/main.yml b/ansible/roles/developer/defaults/main.yml index af737cfe..1d9e403d 100644 --- a/ansible/roles/developer/defaults/main.yml +++ b/ansible/roles/developer/defaults/main.yml @@ -51,14 +51,15 @@ docker_fedora_supported_releases: # Node.js configuration # -# NodeSource publishes a repo PER MAJOR (node_24.x, node_22.x) and both provide -# the package `nodejs`, so a box can hold exactly one system-wide major. That is -# the n slot; fnm covers n-1 per user. Majors come from the SSoT -- see -# hyperi_core_versions in playbooks/group_vars/all.yml. +# NodeSource publishes a repo PER MAJOR (node_26.x, node_24.x) and each provides +# the package `nodejs`, so a box holds exactly one system-wide major and fnm +# holds the others per user. tasks/nodejs.yml replaces these fallbacks with the +# majors the Node.js release schedule supports today. # # The deb and rpm repos are signed by DIFFERENT keys, so both URLs are carried. node_major: "{{ hyperi_core_versions.node_major }}" -node_major_previous: "{{ hyperi_core_versions.node_major_previous }}" +node_majors_previous: "{{ hyperi_core_versions.node_majors_previous }}" +developer_node_schedule_url: "{{ hyperi_node_schedule_url }}" nodesource_deb_base_url: "https://deb.nodesource.com" nodesource_rpm_base_url: "https://rpm.nodesource.com" nodesource_deb_gpg_url: "{{ nodesource_deb_base_url }}/gpgkey/nodesource-repo.gpg.key" diff --git a/ansible/roles/developer/files/update/hyperi-update-linux.sh b/ansible/roles/developer/files/update/hyperi-update-linux.sh index 7a03a5d8..3b5fd988 100644 --- a/ansible/roles/developer/files/update/hyperi-update-linux.sh +++ b/ansible/roles/developer/files/update/hyperi-update-linux.sh @@ -6,6 +6,7 @@ # * System packages (apt or dnf, incl. 3rd-party repos: docker, vscode, # chrome, brave, git, gh, node, k8s, azure, gcloud, # opentofu, ...) +# * Node.js major (NodeSource repo -> newest LTS) -- needs sudo # * Snap (if installed) -- needs sudo # * Flatpak (apps + runtimes) -- user # * Firmware (fwupd) -- needs sudo @@ -14,7 +15,7 @@ # * rustup (Rust toolchains) -- user # * cargo, go, npm and pnpm global tools -- user # * Go toolchain (/usr/local/go, no upstream repo) -- needs sudo -# * fnm Node majors (the n-1 Node, per user) -- user +# * fnm Node majors (the other LTS majors, per user) -- user # * Release binaries (/usr/local/bin, no repo/snap) -- needs sudo # * Codex CLI (re-run of the installer) -- user # * Codex plugin (claude plugin update) -- user @@ -61,11 +62,11 @@ CARGO_BIN="${CARGO_HOME:-$HOME/.cargo}/bin" # Make user-level tools reachable even when launched from a GUI/.desktop entry # or the systemd unit, neither of which sources the login shell (rustup and the # cargo tools live in the cargo home, uv in ~/.local/bin, Go in -# /usr/local/go/bin, the go-installed tools in ~/go/bin and the pnpm globals in -# PNPM_HOME). +# /usr/local/go/bin, the go-installed tools in ~/go/bin, npm and pnpm in +# ~/.npm-global/bin and the pnpm globals in PNPM_HOME). export PNPM_HOME="${PNPM_HOME:-$HOME/.local/share/pnpm}" export FNM_DIR="${FNM_DIR:-$HOME/.local/share/fnm}" -export PATH="$HOME/.local/bin:$CARGO_BIN:/usr/local/go/bin:$HOME/go/bin:$PNPM_HOME:$PNPM_HOME/bin:$PATH" +export PATH="$HOME/.local/bin:$CARGO_BIN:/usr/local/go/bin:$HOME/go/bin:$HOME/.npm-global/bin:$PNPM_HOME:$PNPM_HOME/bin:$PATH" ASSUME_YES=0 @@ -313,6 +314,89 @@ case "$PKG_MGR" in ;; esac +# --- Node.js LTS majors ---------------------------------------------------- +# NodeSource never moves a box to the next major, so this section does. +NODE_SCHEDULE_URL='https://raw.githubusercontent.com/nodejs/Release/main/schedule.json' +NODE_OTHER_MAJORS='' +NODE_EOL_MAJORS='' + +# node_majors : the supported majors newest first, then the EOL ones. +node_majors() { + python3 - "$1" 2>/dev/null <<'PY' +import datetime +import json +import re +import sys + +today = datetime.datetime.now(datetime.UTC).date().isoformat() +with open(sys.argv[1], encoding="utf-8") as fh: + lines = {k: v for k, v in json.load(fh).items() if re.fullmatch(r"v\d+", k)} +supported = sorted( + (int(k[1:]) for k, v in lines.items() if v.get("lts", "9") <= today < v.get("end", "")), + reverse=True, +) +eol = sorted(int(k[1:]) for k, v in lines.items() if v.get("end", "9") <= today) +print(" ".join(map(str, supported))) +print(" ".join(map(str, eol))) +PY +} + +# move_nodesource : point the NodeSource repo at and install it. +move_nodesource() { + local file current + case "$PKG_MGR" in + apt) file=/etc/apt/sources.list.d/nodesource.sources ;; + dnf) file=/etc/yum.repos.d/nodesource.repo ;; + *) skip "no apt or dnf, system node left alone"; return 0 ;; + esac + if [[ ! -f "$file" ]]; then + skip "no NodeSource repo, system node left alone" + return 0 + fi + current="$(sed -nE 's#.*(node|pub)_([0-9]+)\.x.*#\2#p' "$file" | head -n 1)" + if [[ "$current" == "$1" ]]; then + ok "system node on the NodeSource $1.x repo" + return 0 + fi + if ! sudo sed -i -E "s#(node|pub)_[0-9]+\.x#\1_$1.x#g; s#Node\.js [0-9]+\.x#Node.js $1.x#" "$file"; then + fail "NodeSource repo $current.x -> $1.x" + return 1 + fi + case "$PKG_MGR" in + apt) + wait_for_apt_lock || return 1 + run "apt-get update (NodeSource $1.x)" sudo apt-get update + run "nodejs $current.x -> $1.x" sudo apt-get install -y nodejs + ;; + dnf) + run "nodejs $current.x -> $1.x" sudo dnf -y --refresh upgrade nodejs + ;; + esac +} + +section "Node.js LTS majors" +node_schedule="$(mktemp)" +if curl -fsSL "${CURL_LIMITS[@]}" "$NODE_SCHEDULE_URL" -o "$node_schedule" 2>/dev/null && + node_answer="$(node_majors "$node_schedule")" && [[ -n "${node_answer%%$'\n'*}" ]]; then + node_supported="${node_answer%%$'\n'*}" + NODE_EOL_MAJORS="${node_answer#*$'\n'}" + node_system="${node_supported%% *}" + NODE_OTHER_MAJORS="${node_supported#"$node_system"}" + ok "supported LTS majors: $node_supported" + move_nodesource "$node_system" +else + warn "Node.js release schedule unreadable, Node majors left as they are" +fi +rm -f "$node_schedule" + +# Node 25+ ships no corepack, so the links `corepack enable` wrote now dangle. +for link in pnpm pnpx yarn yarnpkg; do + target="/usr/bin/$link" + if [[ -L "$target" && "$(readlink "$target")" == *corepack* ]]; then + run "remove the corepack $link link" sudo rm -f "$target" + fi +done + # --- Snap ------------------------------------------------------------------ section "Snap — snap packages" if have snap; then @@ -399,13 +483,13 @@ else fi # --- npm and pnpm global tools --------------------------------------------- -# semantic-release, maid and wrangler are npm globals. eslint, prettier, -# typescript and tsx are pnpm globals, which `npm update -g` never -# sees. pnpm itself is corepack's, so it is re-activated at latest first. +# npm itself, pnpm, semantic-release, maid and wrangler are npm globals, and +# eslint, prettier, typescript and tsx are pnpm globals. +NPM_BEFORE="$(date -u -d "$RELEASE_MIN_AGE days ago" +%F)" section "npm global tools" if have npm; then - run "npm update -g" npm update -g - have corepack && run "corepack pnpm@latest" corepack prepare pnpm@latest --activate + run "npm and pnpm" npm install --global npm@latest pnpm@latest --before "$NPM_BEFORE" + run "npm update -g" npm update --global --before "$NPM_BEFORE" else skip "npm not found" fi @@ -413,8 +497,18 @@ fi section "pnpm global tools" if have pnpm; then # --latest, because the roles install each global at its latest release and - # the ranges pnpm recorded would otherwise hold them at that major. - run "pnpm update -g --latest" pnpm update -g --latest + # the ranges pnpm recorded would otherwise hold them at that major. A + # release inside the cooldown holds every global until it ages out. + pnpm_out="$(env PNPM_CONFIG_MINIMUM_RELEASE_AGE="$((RELEASE_MIN_AGE * 1440))" pnpm update -g --latest 2>&1)" + pnpm_rc=$? + printf '%s\n' "$pnpm_out" + if [[ "$pnpm_rc" -eq 0 ]]; then + ok "pnpm update -g --latest" + elif [[ "$pnpm_out" == *ERR_PNPM_NO_MATURE_MATCHING_VERSION* ]]; then + warn "pnpm globals held: a release is inside the $RELEASE_MIN_AGE-day cooldown" + else + fail "pnpm update -g --latest (exit $pnpm_rc)" + fi else skip "pnpm not found" fi @@ -514,20 +608,28 @@ else fi # --- fnm Node majors ------------------------------------------------------- -# The SYSTEM node comes from the NodeSource repo and is already updated by the -# system-packages section. This refreshes the extra major fnm manages (the n-1 -# slot) to its latest patch -- `fnm install ` is a no-op when it is -# already current. +# Every supported major but the system one, plus any other major already +# installed, at its latest patch. A version past end of life is removed. section "fnm Node majors" if have fnm; then - fnm_majors="$(fnm list 2>/dev/null | sed -n 's/.*v\([0-9]\{1,\}\)\..*/\1/p' | sort -u)" - if [[ -n "$fnm_majors" ]]; then - for fm in $fnm_majors; do - run "fnm install $fm" fnm install "$fm" - done - else - skip "fnm has no Node versions installed" + read -r -a fnm_eol <<<"$NODE_EOL_MAJORS" + read -r -a fnm_wanted <<<"$NODE_OTHER_MAJORS" + fnm_versions="$(fnm list 2>/dev/null | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+' | sort -u)" + for version in $fnm_versions; do + major="${version#v}" + major="${major%%.*}" + if [[ " ${fnm_eol[*]} " == *" $major "* ]]; then + run "fnm uninstall $version (end of life)" fnm uninstall "$version" + elif [[ " ${fnm_wanted[*]} " != *" $major "* ]]; then + fnm_wanted+=("$major") + fi + done + if [[ ${#fnm_wanted[@]} -eq 0 ]]; then + skip "no fnm Node majors to install or refresh" fi + for fm in "${fnm_wanted[@]}"; do + run "fnm install $fm" fnm install "$fm" + done else skip "fnm not found" fi diff --git a/ansible/roles/developer/files/update/hyperi-update-macos.sh b/ansible/roles/developer/files/update/hyperi-update-macos.sh index 2d65d5e9..794c9211 100644 --- a/ansible/roles/developer/files/update/hyperi-update-macos.sh +++ b/ansible/roles/developer/files/update/hyperi-update-macos.sh @@ -11,7 +11,8 @@ # * rustup (Rust toolchains, where rustup is used) -- user # * cargo tools (nextest, deny, cargo-audit, ...) -- user # * go tools (gopls) -- user -# * npm globals (maid, semantic-release, pnpm) -- user +# * Node.js majors (node@, fnm for the rest) -- user +# * npm globals (npm, pnpm, maid, semantic-release) -- user # * pnpm globals (eslint, prettier, typescript, ...) -- user # * Codex plugin (claude plugin update) -- user # @@ -23,15 +24,13 @@ # # Each section is independent and self-guarding: a tool that isn't installed is # skipped (printed, not fatal), and a failing step is recorded and reported in -# the summary without aborting the rest. At the end, if the system needs it, you -# get a reboot prompt (default: No). +# the summary without aborting the rest. A reboot an update needs is reported, +# never started, unless --ask was given. # -# ONE confirmation, up front. After the y/N everything runs unattended -- sudo -# is taken immediately after the gate and kept alive -- and the only other -# question is the reboot prompt at the end. +# The password is asked for once, at the start, and nothing else asks. # -# Run with: hyperi-update (confirms, then prompts once for sudo) -# hyperi-update --yes (no confirmation — for scripts/Ansible) +# Run with: hyperi-update (one sudo password, then unattended) +# hyperi-update --ask (confirm first, and offer a reboot) # hyperi-update --install (create the clickable "Hyperi Update" app) # hyperi-update --help @@ -45,9 +44,9 @@ setopt nounset pipefail # silicon and Intel, and brew's rustup is keg-only, so its shims are never linked # into the brew prefix. export PNPM_HOME="${PNPM_HOME:-$HOME/.local/share/pnpm}" -export PATH="$HOME/.local/bin:${CARGO_HOME:-$HOME/.cargo}/bin:$HOME/go/bin:$PNPM_HOME:$PNPM_HOME/bin:/opt/homebrew/bin:/opt/homebrew/opt/rustup/bin:/usr/local/bin:/usr/local/opt/rustup/bin:$PATH" +export PATH="$HOME/.local/bin:${CARGO_HOME:-$HOME/.cargo}/bin:$HOME/go/bin:$HOME/.npm-global/bin:$PNPM_HOME:$PNPM_HOME/bin:/opt/homebrew/bin:/opt/homebrew/opt/rustup/bin:/usr/local/bin:/usr/local/opt/rustup/bin:$PATH" -ASSUME_YES=0 +ASSUME_YES=1 # --- self-resolve: absolute path to this script (symlinks resolved) ------- SELF=${${(%):-%x}:A} @@ -58,9 +57,10 @@ hyperi-update -- update Homebrew, macOS, uv tools, rustup and cargo/go/npm/pnpm tools in one go. Usage: - hyperi-update Confirm, then run all updates (prompts once for sudo). - hyperi-update --yes Skip the confirmation. Still prompts for sudo unless - you have a cached ticket or passwordless sudo. + hyperi-update Run all updates. Asks for the sudo password once, + unless sudo is already passwordless. + hyperi-update --ask Confirm before starting, and offer a reboot if one + is needed. hyperi-update --install Create a clickable "Hyperi Update" app in /Applications. hyperi-update --help Show this help. EOF @@ -148,14 +148,13 @@ case "${1:-}" in --install) install_app; exit $? ;; -h|--help) usage; exit 0 ;; -y|--yes) ASSUME_YES=1 ;; + --ask) ASSUME_YES=0 ;; "") ;; *) print -u2 "hyperi-update: unknown option '$1'"; usage; exit 2 ;; esac # --- confirm --------------------------------------------------------------- -# This touches every formula, cask and system update on the box, so say so -# before doing it. --yes is how Ansible and any other unattended caller skips -# this -- and it is the ONLY question until the reboot prompt at the end. +# Only with --ask: this touches every formula, cask and system update on the box. if (( ! ASSUME_YES )); then printf '%s%shyperi-update%s will update EVERYTHING on this Mac:\n\n' "$BOLD" "$BLUE" "$RESET" have brew && printf ' - all Homebrew formulae and casks (including --greedy self-updaters)\n' @@ -175,19 +174,27 @@ if (( ! ASSUME_YES )); then esac fi -# --- sudo: ask once, keep alive ------------------------------------------- -# softwareupdate needs root, and asking for it mid-run breaks the one-question -# contract -- authenticate here, straight after the gate, and keep the ticket -# alive for the long sections. NOPASSWD leaves no timestamp to refresh, so the -# keepalive only starts when a password was actually entered. +# --- sudo: ask once, hold for the run ------------------------------------- +# Homebrew and softwareupdate call sudo from their own children, which a ticket +# for this terminal does not always cover. A sudoers drop-in lets this user sudo +# without a password until the run exits, when the trap removes it. +SUDOERS_DROPIN=/etc/sudoers.d/zz-hyperi-update section "Authenticating (sudo)" -if sudo -n true 2>/dev/null; then +# -k ignores a cached ticket, so only a standing NOPASSWD rule passes the first test. +if sudo -k -n true 2>/dev/null; then ok "sudo authenticated (passwordless)" -elif [[ -t 0 ]] && sudo -v; then - ok "sudo authenticated" - ( while true; do sudo -n true 2>/dev/null; sleep 50; kill -0 "$$" 2>/dev/null || exit; done ) & - SUDO_KEEPALIVE_PID=$! - trap '[[ -n "${SUDO_KEEPALIVE_PID:-}" ]] && kill "$SUDO_KEEPALIVE_PID" 2>/dev/null' EXIT +elif sudo -n true 2>/dev/null || { [[ -t 0 ]] && sudo -v; }; then + trap 'sudo -n rm -f "$SUDOERS_DROPIN"' EXIT + trap 'exit 130' INT TERM + dropin_tmp="$(mktemp)" + printf '%s ALL=(ALL) NOPASSWD: ALL\n' "$(id -un)" >"$dropin_tmp" + if sudo visudo -cqf "$dropin_tmp" && + sudo install -m 0440 -o root -g wheel "$dropin_tmp" "$SUDOERS_DROPIN"; then + ok "sudo held until this run ends" + else + fail "sudo drop-in (later steps may ask for the password again)" + fi + rm -f "$dropin_tmp" else printf '%s \xe2\x9c\x97 sudo authentication failed — aborting%s\n' "$RED" "$RESET" printf '%s No passwordless sudo and no terminal to prompt on.%s\n' "$RED" "$RESET" @@ -211,6 +218,63 @@ else skip "Homebrew not installed" fi +# --- Node.js LTS majors ---------------------------------------------------- +# brew upgrade keeps node@N on its major, so the newest LTS is installed and +# linked here. The other supported majors are fnm's (its section below). +NODE_SCHEDULE_URL='https://raw.githubusercontent.com/nodejs/Release/main/schedule.json' +NODE_OTHER_MAJORS='' +NODE_EOL_MAJORS='' + +# node_majors : the supported majors newest first, then the EOL ones. +node_majors() { + python3 - "$1" 2>/dev/null <<'PY' +import datetime +import json +import re +import sys + +today = datetime.datetime.now(datetime.UTC).date().isoformat() +with open(sys.argv[1], encoding="utf-8") as fh: + lines = {k: v for k, v in json.load(fh).items() if re.fullmatch(r"v\d+", k)} +supported = sorted( + (int(k[1:]) for k, v in lines.items() if v.get("lts", "9") <= today < v.get("end", "")), + reverse=True, +) +eol = sorted(int(k[1:]) for k, v in lines.items() if v.get("end", "9") <= today) +print(" ".join(map(str, supported))) +print(" ".join(map(str, eol))) +PY +} + +section "Node.js LTS majors" +node_schedule="$(mktemp)" +if ! have brew; then + skip "Homebrew not installed" +elif curl -fsSL --connect-timeout 20 --max-time 600 "$NODE_SCHEDULE_URL" -o "$node_schedule" 2>/dev/null && + node_answer="$(node_majors "$node_schedule")" && [[ -n "${node_answer%%$'\n'*}" ]]; then + node_supported="${node_answer%%$'\n'*}" + NODE_EOL_MAJORS="${node_answer#*$'\n'}" + node_system="${node_supported%% *}" + NODE_OTHER_MAJORS="${node_supported#$node_system}" + ok "supported LTS majors: $node_supported" + if brew list --versions "node@$node_system" >/dev/null 2>&1; then + ok "node@$node_system installed" + else + run "brew install node@$node_system" brew install "node@$node_system" + fi + # node@N can be an alias of the unversioned formula, so compare the binaries. + node_linked="$(realpath "$(brew --prefix)/bin/node" 2>/dev/null)" + node_wanted="$(realpath "$(brew --prefix "node@$node_system")/bin/node" 2>/dev/null)" + if [[ -n "$node_wanted" && "$node_linked" == "$node_wanted" ]]; then + ok "node@$node_system linked" + else + run "brew link node@$node_system" brew link --overwrite --force "node@$node_system" + fi +else + printf '%s ! Node.js release schedule unreadable, Node majors left as they are%s\n' "$YELLOW" "$RESET" +fi +rm -f "$node_schedule" + # --- macOS system updates -------------------------------------------------- # Early, like the firmware section on Linux, so a slow Apple download overlaps # nothing interactive. Output is kept: it is the only way to know a restart is @@ -294,14 +358,41 @@ else skip "go not found" fi +# --- fnm Node majors ------------------------------------------------------- +# Every supported major but the system one, plus any other major already +# installed, at its latest patch. A version past end of life is removed. +section "fnm Node majors" +if have fnm; then + fnm_eol=(${=NODE_EOL_MAJORS}) + fnm_wanted=(${=NODE_OTHER_MAJORS}) + for version in ${(f)"$(fnm list 2>/dev/null | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+' | sort -u)"}; do + major="${${version#v}%%.*}" + if (( ${fnm_eol[(Ie)$major]} )); then + run "fnm uninstall $version (end of life)" fnm uninstall "$version" + elif (( ! ${fnm_wanted[(Ie)$major]} )); then + fnm_wanted+=("$major") + fi + done + if (( ${#fnm_wanted} == 0 )); then + skip "no fnm Node majors to install or refresh" + fi + for fm in "${fnm_wanted[@]}"; do + run "fnm install $fm" fnm install "$fm" + done +else + skip "fnm not found" +fi + # --- npm and pnpm global tools --------------------------------------------- -# semantic-release and maid are npm globals. eslint, prettier, typescript and -# tsx are pnpm globals, which `npm update -g` never sees. pnpm itself is -# corepack's, so it is re-activated at latest first. +# npm itself, pnpm, semantic-release and maid are npm globals, and eslint, +# prettier, typescript and tsx are pnpm globals. +RELEASE_MIN_AGE="${HYPERI_RELEASE_MIN_AGE_DAYS:-7}" +[[ "$RELEASE_MIN_AGE" == <-> ]] || RELEASE_MIN_AGE=7 +NPM_BEFORE="$(date -u -v-"${RELEASE_MIN_AGE}"d +%F)" section "npm global tools" if have npm; then - run "npm update -g" npm update -g - have corepack && run "corepack pnpm@latest" corepack prepare pnpm@latest --activate + run "npm and pnpm" npm install --global npm@latest pnpm@latest --before "$NPM_BEFORE" + run "npm update -g" npm update --global --before "$NPM_BEFORE" else skip "npm not found" fi @@ -309,8 +400,18 @@ fi section "pnpm global tools" if have pnpm; then # --latest, because the roles install each global at its latest release and - # the ranges pnpm recorded would otherwise hold them at that major. - run "pnpm update -g --latest" pnpm update -g --latest + # the ranges pnpm recorded would otherwise hold them at that major. A + # release inside the cooldown holds every global until it ages out. + pnpm_out="$(env PNPM_CONFIG_MINIMUM_RELEASE_AGE="$((RELEASE_MIN_AGE * 1440))" pnpm update -g --latest 2>&1)" + pnpm_rc=$? + printf '%s\n' "$pnpm_out" + if (( pnpm_rc == 0 )); then + ok "pnpm update -g --latest" + elif [[ "$pnpm_out" == *ERR_PNPM_NO_MATURE_MATCHING_VERSION* ]]; then + printf '%s ! pnpm globals held: a release is inside the %s-day cooldown%s\n' "$YELLOW" "$RELEASE_MIN_AGE" "$RESET" + else + fail "pnpm update -g --latest (exit $pnpm_rc)" + fi else skip "pnpm not found" fi diff --git a/ansible/roles/developer/tasks/init.yml b/ansible/roles/developer/tasks/init.yml index d3ebcf1d..21b5c3e9 100644 --- a/ansible/roles/developer/tasks/init.yml +++ b/ansible/roles/developer/tasks/init.yml @@ -132,6 +132,9 @@ user_home }}/.npm-global/bin:{{ '/opt/homebrew/bin:/usr/local/bin:' if ansible_facts['distribution'] == 'MacOSX' else '' }}{{ ansible_facts['env'].PATH }} + # The release-age cooldown, in minutes. A global installed inside it + # would fail every later `pnpm update` until it ages out. + PNPM_CONFIG_MINIMUM_RELEASE_AGE: "{{ (hyperi_release_min_age_days | int) * 1440 }}" - name: Load macOS-specific variables ansible.builtin.include_vars: diff --git a/ansible/roles/developer/tasks/nodejs.yml b/ansible/roles/developer/tasks/nodejs.yml index 38ff75ce..62abdfad 100644 --- a/ansible/roles/developer/tasks/nodejs.yml +++ b/ansible/roles/developer/tasks/nodejs.yml @@ -13,14 +13,71 @@ # the trust ladder as a distro one. The sin was the `curl | bash` that used to # bootstrap it, and that is what is gone. # -# n system-wide + n-1 per user. NodeSource's per-major repos BOTH provide the -# package `nodejs`, so apt can hold only one of them; side-by-side genuinely -# needs a version manager, which is what fnm is doing here. +# Every LTS major still supported is installed: the newest system-wide, the +# rest per user via fnm. NodeSource's per-major repos all provide the package +# `nodejs`, so apt can hold only one of them. # -# npm is NOT installed as a separate package: NodeSource's nodejs bundles npm -# and corepack. On Ubuntu the distro `npm` package pulls node 18 as a -# dependency and apt refuses the pair outright ("held broken packages"), so -# asking for it by name breaks the run. +# npm and pnpm are npm globals in ~/.npm-global, at the newest release past the +# release-age cooldown. The distro `npm` package is never asked for: on Ubuntu +# it pulls node 18 and apt refuses the pair ("held broken packages"). Node 25+ +# ships no corepack, so pnpm no longer comes from it. + +# ============================================================================ +# Which majors -- the Node.js release schedule +# ============================================================================ + +- name: Read the Node.js release schedule + ansible.builtin.uri: + url: "{{ developer_node_schedule_url }}" + return_content: true + timeout: 30 + register: developer_node_schedule + become: false + check_mode: false + failed_when: false + +# A major is supported from its `lts` date until its `end` date. ISO dates +# compare correctly as strings. The file is served as text/plain, so uri leaves +# `.json` unset and the body is parsed here. +- name: Pick the supported Node LTS majors + ansible.builtin.set_fact: + developer_node_lts_majors: >- + {{ developer_node_lines + | selectattr('value.lts', 'defined') + | selectattr('value.lts', 'le', developer_node_today) + | selectattr('value.end', 'gt', developer_node_today) + | map(attribute='key') | map('regex_replace', '^v', '') | map('int') + | sort(reverse=true) | list }} + developer_node_eol_majors: >- + {{ developer_node_lines + | selectattr('value.end', 'defined') + | selectattr('value.end', 'le', developer_node_today) + | map(attribute='key') | map('regex_replace', '^v', '') | map('int') + | list }} + vars: + developer_node_today: "{{ now(utc=true, fmt='%Y-%m-%d') }}" + developer_node_lines: >- + {{ ((developer_node_schedule.content + if developer_node_schedule.status | default(0) == 200 else '{}') + | from_json | dict2items + | selectattr('key', 'match', '^v[0-9]+$') | list) }} + +- name: Take the Node majors from the schedule + # noqa: var-naming[no-role-prefix] -- overrides the role defaults of the same name. + ansible.builtin.set_fact: + node_major: "{{ developer_node_lts_majors[0] }}" + node_majors_previous: "{{ developer_node_lts_majors[1:] }}" + when: developer_node_lts_majors | length > 0 + +- name: Record that the Node schedule was unreadable + # noqa: var-naming[no-role-prefix] -- deploy_warnings is the shared + # accumulator reported by playbooks/main.yml post_tasks. + ansible.builtin.set_fact: + deploy_warnings: >- + {{ deploy_warnings | default([]) + + ['node: release schedule unreadable, used the fallback majors ' + ~ ([node_major] + node_majors_previous) | join(', ')] }} + when: developer_node_lts_majors | length == 0 # ============================================================================ # Ubuntu -- NodeSource apt repo @@ -61,10 +118,11 @@ architectures: "{{ hyperi_arch_deb | default('amd64') }}" state: present + # latest, because `present` keeps the old major after the repo moves. - name: Install Node.js (Ubuntu) ansible.builtin.apt: name: nodejs - state: present + state: latest # noqa: package-latest update_cache: true become: true @@ -94,10 +152,12 @@ # authoritative for the package regardless of what Fedora ships. priority: 10 + # latest, because `present` keeps the old major after the repo moves. - name: Install Node.js (Fedora) ansible.builtin.dnf: name: nodejs - state: present + state: latest # noqa: package-latest + update_cache: true become: true when: ansible_facts['distribution'] == 'Fedora' @@ -114,13 +174,13 @@ environment: "{{ homebrew_env }}" when: ansible_facts['distribution'] == 'MacOSX' -# Versioned brew formulae are keg-only, so `node@24` installs WITHOUT linking -# and `node` never appears on PATH -- every npm/corepack/semantic-release task -# below would then fail on a Mac. Linking it is what makes the pin usable. +# Versioned brew formulae are keg-only, so `node@N` installs WITHOUT linking +# and `node` never appears on PATH -- every npm and semantic-release task below +# would then fail on a Mac. Linking it is what makes the major usable. # -# The unversioned `node` formula is not an option: it tracks Current (26.x -# today), not the LTS major this file exists to pin. -- name: Link the pinned Node major into the Homebrew prefix (macOS) +# The unversioned `node` formula is not an option: it tracks Current, which is +# a non-LTS major from each April to October. +- name: Link the system Node major into the Homebrew prefix (macOS) ansible.builtin.command: cmd: brew link --overwrite --force node@{{ node_major }} become: false @@ -130,13 +190,13 @@ when: ansible_facts['distribution'] == 'MacOSX' # ============================================================================ -# n-1 major, per user, via fnm +# The other supported majors, per user, via fnm # ============================================================================ -# Only the n major can be a system package (see the header). fnm gives a -# developer the previous major for a project that has not moved yet, without -# disturbing the system node that CI and tooling resolve. +# Only one major can be a system package (see the header). fnm gives a +# developer the other supported majors for a project that has not moved yet, +# without disturbing the system node that CI and tooling resolve. -- name: Install fnm and the previous Node major (Linux) +- name: Install fnm and the other Node majors (Linux) block: - name: Resolve the fnm release ansible.builtin.include_role: @@ -177,9 +237,10 @@ group: root become: true - - name: Install the previous Node major via fnm + - name: Install the other Node majors via fnm ansible.builtin.command: - cmd: /usr/local/bin/fnm install {{ node_major_previous }} + cmd: /usr/local/bin/fnm install {{ item }} + loop: "{{ node_majors_previous }}" become: true become_user: "{{ actual_user }}" environment: @@ -189,11 +250,33 @@ # exits 0 when the major is present, so the message is the only signal. changed_when: "'already installed' not in developer_fnm_install.stderr" + - name: List the fnm Node versions + ansible.builtin.command: + cmd: /usr/local/bin/fnm list + become: true + become_user: "{{ actual_user }}" + environment: + FNM_DIR: "{{ user_home }}/.local/share/fnm" + register: developer_fnm_list + changed_when: false + check_mode: false + + - name: Remove fnm Node versions past end of life + ansible.builtin.command: + cmd: /usr/local/bin/fnm uninstall {{ item }} + loop: "{{ developer_fnm_list.stdout | regex_findall('v[0-9]+\\.[0-9]+\\.[0-9]+') | unique }}" + when: (item | regex_replace('^v([0-9]+)\\..*$', '\\1') | int) in developer_node_eol_majors + become: true + become_user: "{{ actual_user }}" + environment: + FNM_DIR: "{{ user_home }}/.local/share/fnm" + changed_when: true + # fnm sets the FIRST version it installs as its `default` alias, so without # this the base shell (which has no per-project pin) would resolve `node` to - # the n-1 major and shadow the system n -- backwards. Pinning default to - # `system` keeps the NodeSource node authoritative everywhere except a - # project that pins otherwise. Verified: base shell -> system 24. + # an older fnm major and shadow the system one. Pinning default to `system` + # keeps the NodeSource node authoritative everywhere except a project that + # pins otherwise. - name: Point the fnm default at the system Node ansible.builtin.command: cmd: /usr/local/bin/fnm default system @@ -230,12 +313,12 @@ ansible.builtin.set_fact: deploy_warnings: >- {{ deploy_warnings | default([]) - + ['fnm/node ' ~ node_major_previous ~ ': ' + + ['fnm/node ' ~ node_majors_previous | join(', ') ~ ': ' ~ (ansible_failed_result.msg | default('install failed'))] }} when: ansible_facts['distribution'] in ['Fedora', 'Ubuntu'] -- name: Install fnm and the previous Node major (macOS) +- name: Install fnm and the other Node majors (macOS) block: - name: Install fnm (macOS) community.general.homebrew: @@ -244,17 +327,36 @@ become: false environment: "{{ homebrew_env }}" - - name: Install the previous Node major via fnm (macOS) + - name: Install the other Node majors via fnm (macOS) ansible.builtin.command: - cmd: fnm install {{ node_major_previous }} + cmd: fnm install {{ item }} + loop: "{{ node_majors_previous }}" become: false environment: "{{ homebrew_env }}" register: developer_fnm_install_macos # See the Linux note above -- fnm exits 0 either way. changed_when: "'already installed' not in developer_fnm_install_macos.stderr" + - name: List the fnm Node versions (macOS) + ansible.builtin.command: + cmd: fnm list + become: false + environment: "{{ homebrew_env }}" + register: developer_fnm_list_macos + changed_when: false + check_mode: false + + - name: Remove fnm Node versions past end of life (macOS) + ansible.builtin.command: + cmd: fnm uninstall {{ item }} + loop: "{{ developer_fnm_list_macos.stdout | regex_findall('v[0-9]+\\.[0-9]+\\.[0-9]+') | unique }}" + when: (item | regex_replace('^v([0-9]+)\\..*$', '\\1') | int) in developer_node_eol_majors + become: false + environment: "{{ homebrew_env }}" + changed_when: true + # See the Linux note -- keep the system (Homebrew node@N) major as fnm's - # default so the base shell is not silently switched to n-1. + # default so the base shell is not silently switched to an fnm major. - name: Point the fnm default at the system Node (macOS) ansible.builtin.command: cmd: fnm default system @@ -279,7 +381,7 @@ ansible.builtin.set_fact: deploy_warnings: >- {{ deploy_warnings | default([]) - + ['fnm/node ' ~ node_major_previous ~ ': ' + + ['fnm/node ' ~ node_majors_previous | join(', ') ~ ': ' ~ (ansible_failed_result.msg | default('install failed'))] }} when: ansible_facts['distribution'] == 'MacOSX' @@ -366,49 +468,77 @@ when: ansible_facts['distribution'] == 'MacOSX' # ============================================================================ -# corepack / pnpm -- package managers, core rather than JS-specific +# npm and pnpm -- npm globals, the newest release past the cooldown # ============================================================================ -# corepack ships WITH node (NodeSource bundles it) and provides the pnpm/yarn -# shims. developer-typescript installs its tooling via `pnpm install -g`, so -# pnpm must exist before that role runs -- nothing installed it before, which -# left that tag broken. - -- name: Enable corepack (Linux) +# The npm NodeSource bundles trails npm's releases, and Node 25+ ships no +# corepack. ~/.npm-global/bin sits ahead of the system node on PATH, so every +# Node major resolves these copies. developer-node and developer-typescript +# install with `pnpm install -g`, so pnpm has to land before them. +# +# `--before` makes npm take the newest release published by that date, which is +# how hyperi_release_min_age_days reaches the registry. npm reports every +# reinstall as "changed", so the version list decides whether anything moved. + +- name: Set the npm release cutoff + ansible.builtin.set_fact: + developer_npm_before: >- + {{ '%Y-%m-%d' | strftime((now().timestamp() | int) + - (hyperi_release_min_age_days | int) * 86400, utc=true) }} + developer_npm_env: >- + {{ npm_config_env if ansible_facts['distribution'] == 'MacOSX' + else {'NPM_CONFIG_PREFIX': user_home ~ '/.npm-global'} }} + +- name: Read the npm globals before the update ansible.builtin.command: - cmd: corepack enable - become: true + cmd: npm ls --global --depth=0 --json + environment: "{{ developer_npm_env }}" + become: "{{ ansible_facts['distribution'] != 'MacOSX' }}" + become_user: "{{ actual_user if ansible_facts['distribution'] != 'MacOSX' else omit }}" + register: developer_npm_globals_before changed_when: false - when: ansible_facts['distribution'] in ['Fedora', 'Ubuntu'] + failed_when: false + check_mode: false -- name: Enable corepack (macOS) +- name: Install the latest npm and pnpm ansible.builtin.command: - cmd: corepack enable - environment: "{{ homebrew_env }}" - become: false + cmd: npm install --global npm@latest pnpm@latest --before {{ developer_npm_before }} + environment: "{{ developer_npm_env }}" + become: "{{ ansible_facts['distribution'] != 'MacOSX' }}" + become_user: "{{ actual_user if ansible_facts['distribution'] != 'MacOSX' else omit }}" changed_when: false - when: ansible_facts['distribution'] == 'MacOSX' -# corepack caches the activated pnpm under the user's home, so this one runs as -# actual_user rather than the connecting user -- on a fleet machine reached as a -# service account those are different, and the shim would land in a home nobody -# logs into. become_user is ignored while become is false, so both are needed. -- name: Activate the latest pnpm via corepack (Linux) +- name: Report whether npm or pnpm moved ansible.builtin.command: - cmd: corepack prepare pnpm@latest --activate - environment: - HOME: "{{ user_home }}" - become: true - become_user: "{{ actual_user }}" - changed_when: false + cmd: npm ls --global --depth=0 --json + environment: "{{ developer_npm_env }}" + become: "{{ ansible_facts['distribution'] != 'MacOSX' }}" + become_user: "{{ actual_user if ansible_facts['distribution'] != 'MacOSX' else omit }}" + register: developer_npm_globals_after + changed_when: developer_npm_globals_after.stdout != developer_npm_globals_before.stdout + check_mode: false + +# `corepack enable` wrote pnpm and yarn links beside the system node. They point +# into a corepack the NodeSource package no longer ships from Node 25. +- name: Find the corepack package-manager links (Linux) + ansible.builtin.stat: + path: "/usr/bin/{{ item }}" + follow: false + loop: [pnpm, pnpx, yarn, yarnpkg] + register: developer_corepack_links when: ansible_facts['distribution'] in ['Fedora', 'Ubuntu'] -- name: Activate the latest pnpm via corepack (macOS) - ansible.builtin.command: - cmd: corepack prepare pnpm@latest --activate - environment: "{{ homebrew_env }}" - become: false - changed_when: false - when: ansible_facts['distribution'] == 'MacOSX' +- name: Remove the corepack package-manager links (Linux) + ansible.builtin.file: + path: "{{ item.stat.path }}" + state: absent + loop: "{{ developer_corepack_links.results | default([]) }}" + loop_control: + label: "{{ item.item }}" + become: true + when: + - ansible_facts['distribution'] in ['Fedora', 'Ubuntu'] + - item.stat.islnk | default(false) + - "'corepack' in (item.stat.lnk_target | default(''))" # pnpm refuses `install -g` outright unless its global bin directory is on PATH # ("The configured global bin directory is not in PATH -- run pnpm setup"), so diff --git a/ansible/roles/soe/tasks/colima.yml b/ansible/roles/soe/tasks/colima.yml index 77bd1c3d..a3fc0909 100644 --- a/ansible/roles/soe/tasks/colima.yml +++ b/ansible/roles/soe/tasks/colima.yml @@ -125,6 +125,17 @@ or ((soe_colima_cfg.content | b64decode | from_yaml).cpu | default(0) | int < soe_colima_cpu | int) or ((soe_colima_cfg.content | b64decode | from_yaml).memory | default(0) | int < soe_colima_mem_gb | int) + - name: Check whether the colima launch agent is loaded + ansible.builtin.command: + cmd: launchctl print gui/{{ ansible_facts['user_uid'] }}/io.hyperi.colima + become: false + register: soe_colima_loaded + changed_when: false + failed_when: false + check_mode: false + + # Bootstrapping a loaded agent fails with 5 or 37 depending on the macOS + # release, so only an unloaded agent is bootstrapped. - name: Load the colima launch agent ansible.builtin.command: cmd: >- @@ -132,9 +143,7 @@ {{ ansible_facts['env'].HOME }}/Library/LaunchAgents/io.hyperi.colima.plist become: false register: soe_colima_bootstrap - # Runs every time, not just when the plist changed: 37 is "already - # bootstrapped", so a re-run is a no-op, and it also re-loads the agent if - # someone unloaded it by hand. Gating on `changed` would leave that broken. + when: soe_colima_loaded.rc != 0 failed_when: soe_colima_bootstrap.rc not in [0, 37] changed_when: soe_colima_bootstrap.rc == 0 diff --git a/docs/install-matrix.md b/docs/install-matrix.md index 05ab56b4..0851f736 100644 --- a/docs/install-matrix.md +++ b/docs/install-matrix.md @@ -271,14 +271,17 @@ The base ships the Astral suite (uv, ruff, ty) and `uv` bundles `uv audit` / | Tool(s) | Platforms | Method | |---|---|---| -| eslint, prettier | all | npm global | - -The runtime is NOT here. node, npm, semantic-release, pnpm and corepack live in -the `developer` base -- they are core tooling that semantic-release and CI need, -so the base installs them and this role adds only the linters. That matters -because it decides which tag fixes a missing node: `developer`, not -`developer-node`. developer-ai's plugin gate says so in its warning, and this -table used to say the opposite. +| eslint, prettier | all | pnpm global | + +The runtime is NOT here. node, npm, pnpm and semantic-release live in the +`developer` base, because semantic-release and CI need them, so the tag that +fixes a missing node is `developer`, not `developer-node`. The base installs +every Node LTS major the [Node.js release schedule](https://github.com/nodejs/Release/blob/main/schedule.json) +supports: the newest from NodeSource (Homebrew `node@N` on macOS), the rest per +user through fnm. npm and pnpm are npm globals in `~/.npm-global`, at the newest +release at least `hyperi_release_min_age_days` old. `hyperi-update` moves the +system node to a new LTS major, adds or removes fnm majors as the schedule +changes, and updates npm and pnpm with the same cooldown. #### developer-typescript (dep: developer-node) @@ -530,9 +533,7 @@ this repo, and there is no flag that changes it. | cargo / go tools | `cargo install X`, `go install X@latest`. | | go, rustup | The publisher's current release, verified against the checksum it serves beside it. | -Three things are deliberately not versions. **Node's major** (`node_major`) picks -an LTS line rather than a release, and NodeSource's signed repo patches it in -place. **Rust's edition** comes with whatever stable rustup installs, so edition +Two things are deliberately not versions. **Rust's edition** comes with whatever stable rustup installs, so edition 2024 needs no pin. **kubectl's minor** (`infrastructure_kubectl_minor`) picks the pkgs.k8s.io repository, which publishes one per Kubernetes minor and patches it in place. Left empty it follows the stable minor at https://dl.k8s.io/release/stable.txt. kubectl supports one minor either side of the API server, so this is the knob for cluster version skew. Set it to the minor of the clusters you work against, such as `v1.36`, and the next converge moves the repository and kubectl with it, up or down. A kubectl held with `apt-mark hold` or `dnf versionlock add` is left alone and the run warns. **GitHub releases wait 7 days.** Every tool taken from a GitHub release installs the newest release at least `hyperi_release_min_age_days` old (default 7; set it in `local-config/vars.yml` or with `-e`), so a compromised or broken release has time to be pulled first. With none that old the installed copy stays and the run warns. Nothing newer is ever installed in its place. Releases from the hyperi-io org skip the wait (`hyperi_release_cooldown_exempt`). diff --git a/install.sh b/install.sh index ad3c21ee..554f7e75 100755 --- a/install.sh +++ b/install.sh @@ -544,19 +544,25 @@ case "$OS_FAMILY" in ;; esac -# Create temporary Python venv -python3 -m venv "$TEMP_ANSIBLE_DIR" || { - print_error "Failed to create Python venv" - exit 1 -} - -# Install latest Ansible + ansible-lint via pip +# Install latest Ansible + ansible-lint via pip, on the first Python it runs on. +# A Python newer than ansible-core supports installs it and then fails on import. print_info "Installing latest Ansible + ansible-lint via pip..." -"$TEMP_ANSIBLE_DIR/bin/pip" install --upgrade pip setuptools wheel >/dev/null 2>&1 -"$TEMP_ANSIBLE_DIR/bin/pip" install ansible ansible-lint >/dev/null 2>&1 || { - print_error "Failed to install Ansible + ansible-lint via pip" +ansible_ready=0 +for py in python3 python3.14 python3.13 python3.12; do + command -v "$py" &>/dev/null || continue + "$py" -m venv --clear "$TEMP_ANSIBLE_DIR" >/dev/null 2>&1 || continue + "$TEMP_ANSIBLE_DIR/bin/pip" install --upgrade pip setuptools wheel >/dev/null 2>&1 + "$TEMP_ANSIBLE_DIR/bin/pip" install ansible ansible-lint >/dev/null 2>&1 || continue + if "$TEMP_ANSIBLE_DIR/bin/ansible" --version >/dev/null 2>&1; then + ansible_ready=1 + break + fi + print_warning "Ansible does not run on $("$py" --version 2>&1), trying an older Python" +done +if [[ "$ansible_ready" -ne 1 ]]; then + print_error "Failed to install a working Ansible + ansible-lint via pip" exit 1 -} +fi ANSIBLE_VERSION=$("$TEMP_ANSIBLE_DIR/bin/ansible" --version | head -1 | awk '{print $2}') ANSIBLE_LINT_VERSION=$("$TEMP_ANSIBLE_DIR/bin/ansible-lint" --version 2>/dev/null | head -1 | awk '{print $2}')