Files
homelab/ansible/roles/semaphore/tasks/collections.yml
Hermes Agent service account 644128cd3f fix(semaphore/collections): mount to /opt/ansible-collections, set ANSIBLE_COLLECTIONS_PATHS
/home/semaphore/.ansible/ is owned by root after Podman creates the
bind-mount dir, so ansible-galaxy can't create sibling tmp dirs.
Mount to a neutral /opt/ansible-collections path and point Ansible
at it via ANSIBLE_COLLECTIONS_PATHS env var instead.
2026-06-07 16:47:15 -05:00

39 lines
1.5 KiB
YAML

---
# ============================================================================
# Install Ansible collections into a host-side directory that is
# bind-mounted into the Semaphore container at the Ansible collections
# path (/home/semaphore/.ansible/collections).
#
# This persists collections across container restarts/rebuilds without
# baking them into the image. Add new collections to
# semaphore_ansible_collections in defaults/main.yml.
# ============================================================================
- name: Ensure Ansible collections directory exists on host
ansible.builtin.file:
path: "{{ semaphore_collections_dir }}"
state: directory
owner: root
group: root
mode: "0755"
- name: Find ansible-galaxy binary inside Semaphore container
ansible.builtin.shell:
cmd: "podman exec {{ semaphore_container_name }} find /opt/semaphore/apps/ansible -name ansible-galaxy -type f | sort -V | tail -1"
register: ansible_galaxy_bin
changed_when: false
failed_when: ansible_galaxy_bin.stdout == ""
- name: Install Ansible collections into host collections directory
ansible.builtin.shell:
cmd: >
podman exec {{ semaphore_container_name }}
{{ ansible_galaxy_bin.stdout }} collection install
{{ item.name }}{% if item.version is defined %}:{{ item.version }}{% endif %}
-p /opt/ansible-collections
--force
loop: "{{ semaphore_ansible_collections }}"
loop_control:
label: "{{ item.name }}"
changed_when: true