mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 10:59:59 +00:00
Two probes that describe a host were re-running per application. Measured in CI run wp-swarm-tor2: 42 invocations of the pip probe and 44 of the NFS assert. sys-pip-install guarded only its dependency include. Everything expensive sat below that guard in main.yml, unguarded: resolving the interpreter, probing pip for --break-system-packages, checking for `packaging` and bootstrapping it. All four ran on every one of the 21 include sites. They move into 00_core.yml, where the existing `when: run_once_sys_pip_install is not defined` covers them, and main.yml keeps the guarded include and the pip task itself. The role recap reads sys-pip-install ---- 87.35s. The two facts this freezes per host are run constants: ansible_python_interpreter is pinned once in group_vars/all/00_general.yml and no call site overrides it, and all 21 sites pass global_install: true. main.yml now defends the probe fact with `| default(false)` the way 00_core.yml already did, because the probe sits behind `when: global_install | bool` and a first invocation with false would otherwise leave it undefined for every later one. The NFS assert emulated a per-host check with run_once plus delegate_to over groups['svc-swarm-node'], and the include it lives in happens per application. It becomes a plain per-host task in sys-svc-compose/00_core.yml, which main.yml already gates once per host per play: 44 instances and 132 remote commands become 4 and 4. Dropping run_once also removes a real fragility — at log line 35355 only wrk-01 and wrk-02 reach the include because mgr-01's flag is already set, so run_once there designates a host that skipped. It reaches the same hosts as the loop it replaces, measured rather than assumed: sys-svc-compose/00_core fires only on mgr-01, wrk-01 and wrk-02, the backup play never runs it, and nfs-server and bkp-01 never execute it. The two conditions that do not travel are a per-application volume count, meaningless for a per-host check, and an exemption for manager-placed roles — mgr-01 answered the assert ok 14 times out of 14, so the exemption was hiding nothing. The assert is appended to 00_core.yml rather than prepended: utils/once/flag.yml must stay that file's first task for test_service_core_first_task_run_once. Worth 128.6s: 84.6s from the pip probe and 44.0s from the assert. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
28 lines
955 B
YAML
28 lines
955 B
YAML
---
|
|
# run_once_sys_pip_install: disabled
|
|
|
|
- include_tasks: 00_core.yml
|
|
when: run_once_sys_pip_install is not defined
|
|
|
|
- name: 📦 Install or upgrade {{ package_name }} system-wide via pip
|
|
ansible.builtin.pip:
|
|
name: "{{ package_name }}"
|
|
state: "{{ package_state }}"
|
|
extra_args: "{{ '--break-system-packages' if (global_install | bool and sys_pip_install_supports_break_system_packages | default(false) | bool) else omit }}"
|
|
virtualenv: "{{ omit if global_install | bool else (sys_pip_install_python_executable | dirname | dirname) }}"
|
|
environment: >-
|
|
{{
|
|
(
|
|
{'PIP_BREAK_SYSTEM_PACKAGES': '1'}
|
|
if sys_pip_install_supports_break_system_packages | default(false) | bool
|
|
else {}
|
|
)
|
|
if global_install | bool
|
|
else omit
|
|
}}
|
|
become: "{{ true if global_install | bool else false }}"
|
|
register: sys_pip_install_result
|
|
retries: 5
|
|
delay: 15
|
|
until: sys_pip_install_result is succeeded
|