semaphore
semaphore copied to clipboard
Roles requirements.yml directory and repository structure
Hi there, relatively new to Semaphore and Ansible in general. My git repository contains code other than Ansible playbooks, and is structured so that all Ansible related files are in an ansible subdirectory in the root of the project:
Repository structure:
/ (root)
├── ansible/
│ ├── group_vars/
│ │ ├── ...
│ ├── playbooks/
│ │ ├── initialize.yml
│ ├── roles/
│ │ ├── requirements.yml
├── module2/
│ ├── ...
├── module3/
│ ├── ...
So in Semaphore I create Task Templates pointing to my playbook files like this: ansible/playbooks/initialize.yml
My playbook has role requirements listed in ansible/roles/requirements.yml. Problem is Semaphore assumes the roles folder is in the root of the project. Is there a way to change this behavior? What is the recommended approach for installing roles if your project does not conform to normal convention? It would be nice if Semaphore looked "one directory up" from your playbook file location for the roles directory (which would not break existing convention), or if you could specify a subdirectory in your repo where Ansible-related files are located.
I am running Semaphore via Docker (latest version: 2.9.4).
For now I've just symlinked /ansible/roles/ to /roles/ and it seems to be working. Would still be nice to have a cleaner approach to this.
Me too. In my environment semaphore is expecting the roles folder in "
add a "ansible.cfg" in the root of your repository and add these lines
[defaults]
roles_path = roles:/tmp/semaphore/.ansible/roles:/usr/share/ansible/roles
collections_paths = collections:/tmp/semaphore/.ansible/collections:/usr/share/ansible/collections
I am also quite new to this, but I read the docu and came up with a template for a new ansible repository, so that i don't have to think about every time: https://github.com/betadots/ansible-control-repo-template
roles_path is where ansible should look for installed roles. What I'm trying to do is tell Semaphore where my requirements.yml file is so it can install them. Normally you need to call ansible-galaxy before running a playbook but Semaphore does this for you.
when i do it like this, it searches also for requirements.yml there and installs any role from it.
You have roles/requirements.yml in your project root, my initial question was how do you tell Semaphore to see it when it's not?
hmm okay, i see your point. i thought this is more a ansible then a semaphore thing. and by telling ansible where my roles are, it should find the yaml. but I didn't test it.
@jeffreznik Did you find another solution besides symlinking /ansible/roles/ to /roles/? I have the exact same project setup and I am facing the exact same issue.
No, unfortunately this is still the only solution that worked for me.
On Wed, Feb 7, 2024, 2:22 a.m. Volker Thiel @.***> wrote:
@jeffreznik https://github.com/jeffreznik Did you find another solution besides symlinking /ansible/roles/ to /roles/? I have the exact same project setup and I am facing the exact same issue.
— Reply to this email directly, view it on GitHub https://github.com/ansible-semaphore/semaphore/issues/1609#issuecomment-1931509179, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAVCQGIQX5MG65H6QCULYT3YSM2VHAVCNFSM6AAAAAA65UVRQGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMZRGUYDSMJXHE . You are receiving this because you were mentioned.Message ID: @.***>
I think there is an open pull request which sets the role path relative to the playbook.
can anyone point me to why i have collections/requirements.yml and roles/requirements.yml in the ROOT of my repo and still sephamore wont detect it at all? has anyone got an example of what the file should look like?