Skip to content

Problem: Concurrent Task Template runs in Semaphore cause ansible-galaxy collection install to fail with Directory not empty #3236

@DFE-mdv

Description

@DFE-mdv

Issue

When running the same playbooks in different task templates at the same time in , both jobs attempt to install required collections into the same temporary project path. If two ansible-galaxy collection install processes run concurrently, the second one fails with a filesystem error because the target directories are being modified simultaneously.

9:40:03 PM
Downloading https://galaxy.ansible.com/api/v3/plugin/ansible/content/published/collections/artifacts/community-general-11.2.1.tar.gz to /tmp/semaphore/project_3/.ansible/tmp/ansible-local-427519yw38rq/tmp33q3feio/community-general-11.2.1-siqqs8fz
9:40:06 PM
Installing 'community.general:11.2.1' to '/tmp/semaphore/project_3/.ansible/collections/ansible_collections/community/general'
9:40:06 PM
ERROR! Unexpected Exception, this is probably a bug: [Errno 39] Directory not empty: '/tmp/semaphore/project_3/.ansible/collections/ansible_collections/community/general/plugins/modules'

Steps to reproduce:
1. Configure a Semaphore project that installs community.general.
2. Trigger two playbooks in the same project at the same time.
3. Observe that one of them fails with the error above.

Expected behavior:
Ansible in SemaphoreUI should handle concurrent collection installs safely (e.g. by using a shared preinstalled path, a lock, or isolating installs per job). Concurrent runs should not fail because of race conditions in ansible-galaxy collection install.

Actual behavior:
One job succeeds, while the other fails with [Errno 39] Directory not empty.

Impact

Ansible (task execution)

Installation method

Docker

Database

Postgres

Browser

Chrome

Semaphore Version

v2.16.17

Ansible Version

ansible [core 2.18.8]

Logs & errors

No response

Manual installation - system information

No response

Configuration

No response

Additional information

No response

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions