Skip to content

Problem: Ansible host_vars not loaded from correct branch in Semaphore #2991

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Thanoonazad opened this issue May 2, 2025 · 2 comments
Open
Assignees
Labels
Milestone

Comments

@Thanoonazad
Copy link

Issue

Bug Description

When running a playbook in Semaphore using a non-main branch (e.g. fixing issue XX), the host_vars are not read from the checked-out branch, but instead from the main branch.

Environment

Semaphore version:

Tested on v2.13.13 and v2.14.7 (latest)

Ansible: Default bundled version

SEMAPHORE_TMP_PATH: /tmp/semaphore/

Observed Behavior

When using branch fixing issue XX, Semaphore creates:

/tmp/semaphore/project_1/repository_1_template_16_inventory_1 → points to branch main

/tmp/semaphore/project_1/repository_3_template_16 → points to branch fixing issue XX

The inventory is loaded from the main branch, not from the working branch where updated host_vars live.

Problem

Even though I have modified host_vars/sync01.yaml in fixing issue XX, Semaphore still uses the outdated version from main.

Expected Behavior

The host_vars (and group_vars) should be read from the currently selected Git branch for the playbook, not defaulted from main.

Steps to Reproduce

Create a new branch fixing issue XX from main

Modify a host_vars/.yaml file

Push the branch and configure a template to use it

Run the template

Workaround Tried

Manually verified the correct file exists in repository_3_template_16

Confirmed that inventory path points to another directory tied to main

Upgraded to latest Semaphore v2.14.7 — issue persists

📎 Additional Notes
This breaks playbook behavior that depends on up-to-date variables.

Makes it difficult to test features in Git branches without merging into main.

Impact

Ansible (task execution)

Installation method

Docker

Database

Postgres

Browser

Chrome

Semaphore Version

v2.14.7

Ansible Version

ansible [core 2.17.9]

Logs & errors

VARIABLE IS NOT DEFINED

Manual installation - system information

No response

Configuration

No response

Additional information

No response

@fiftin fiftin self-assigned this May 2, 2025
@fiftin fiftin added the git label May 2, 2025
@fiftin fiftin added this to the 2.15 milestone May 2, 2025
@fiftin
Copy link
Collaborator

fiftin commented May 2, 2025

Yes, we need to add field "branch" to inventory too.

@fiftin
Copy link
Collaborator

fiftin commented May 2, 2025

@Thanoonazad you don't need to provide inventory repository if it the same like in template.

Template repository will be used by default if you don't provide repo for inventory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants