Closed kirolous closed 4 months ago
on version 2.8.77
I have the same problem since the update today. The reading of the Collections path has been changed. It is no longer searched globally for collections/requirements.yml, but in the folder where the playbook is located.
In my case this gives a big chaos, because I have structured my playbooks cleanly in folders and now I have to create many collections/requirements.txt files.
Example:
playbooks
├── linux
│ ├── xxx
│ │ ├── collections
│ │ │ ├── requirements.yml
│ ├── yyy
│ │ ├── collections
│ │ │ ├── requirements.yml
│ ├── zzz
│ │ ├── collections
│ │ │ ├── requirements.yml
Sure, the advantage is that you only have to install the Collections that are also needed for this Playbook. For larger projects, however, it is total chaos.
The problem is here: https://github.com/ansible-semaphore/semaphore/blob/864d8bd8aa5d55f334a9ae4f3c52aa44667a65ac/services/tasks/runner.go#L508
Whereas Roles looks like: https://github.com/ansible-semaphore/semaphore/blob/864d8bd8aa5d55f334a9ae4f3c52aa44667a65ac/services/tasks/runner.go#L537
The role implementation does this correctly and the collections implementation should be changed to look at the base of the project/repository then 'collections/requirements.yml'.
I have the same problem since the update today. The reading of the Collections path has been changed. It is no longer searched globally for collections/requirements.yml, but in the folder where the playbook is located.
In my case this gives a big chaos, because I have structured my playbooks cleanly in folders and now I have to create many collections/requirements.txt files.
Example: playbooks ├── linux │ ├── xxx │ │ ├── collections │ │ │ ├── requirements.yml │ ├── yyy │ │ ├── collections │ │ │ ├── requirements.yml │ ├── zzz │ │ ├── collections │ │ │ ├── requirements.yml
Sure, the advantage is that you only have to install the Collections that are also needed for this Playbook. For larger projects, however, it is total chaos.
Until this is fixed my current workaround is to create symlinks that point to roles/requirements.yml
. So each of my playbook directories have a 'collections' folder which contains said symlink. Even my collections/requirements.yml
file is a symlink to roles/requirements.yml
. Ansible galaxy allows you to define both roles and collections in a single file which is nice.
Any workaround? I also faced the same issues.
I have the same problem since the update today. The reading of the Collections path has been changed. It is no longer searched globally for collections/requirements.yml, but in the folder where the playbook is located. In my case this gives a big chaos, because I have structured my playbooks cleanly in folders and now I have to create many collections/requirements.txt files.
Example: playbooks ├── linux │ ├── xxx │ │ ├── collections │ │ │ ├── requirements.yml │ ├── yyy │ │ ├── collections │ │ │ ├── requirements.yml │ ├── zzz │ │ ├── collections │ │ │ ├── requirements.yml
Sure, the advantage is that you only have to install the Collections that are also needed for this Playbook. For larger projects, however, it is total chaos.
Until this is fixed my current workaround is to create symlinks that point to
roles/requirements.yml
. So each of my playbook directories have a 'collections' folder which contains said symlink. Even mycollections/requirements.yml
file is a symlink toroles/requirements.yml
. Ansible galaxy allows you to define both roles and collections in a single file which is nice.
This still doesn't work for me.
@Ye-Min-Tun FWIW I've implemented something similar in my MR to resolve this issue. Please review/test it and see if it works for you https://github.com/ansible-semaphore/semaphore/pull/1240
@andreas-marschke Sure sir. I resolved this by adding a requirement.yml file inside collection directory. Note: earlier I think yml and yaml are the same. Semaphore only look for yml, not yaml. That spent my half a day.
big issue causing me much pain please fix
@pydlv You just need to add requirements.yml file (with the collections you need to install) under the collections directory of your workspace.
At now (in 2.8.90) "right path" is
requirementsFilePath := path.Join(t.getPlaybookDir(), "collections", "requirements.yml")
In my project tree it looks as:
├── ansible.cfg
├── collections
│ └── requirements.yml (original file)
├── playbooks
│ ├── one.yml
│ ├── two.yml
│ └── collections
│ └── requirements.yml -> ../../collections/requirements.yml (hot fix symlink)
└── roles
├── one
└── two
I think was best solution search requirements.yml in all popular places:
/requirements.yml (root project dir)
/collections/requirements.yml
/[getPlaybookDir]/collections/requirements.yml
Fully agree!
But probably reverse the order, and use the first one found ("most specific one")?
just for the record: i'm working around this like this. so i can include it in all my playbooks which need some collections.
---
# playbooks/test_play.yml
- name: "ダミープラグ on localhost"
hosts: localhost
gather_facts: false
connection: local
tasks:
- name: "Install ansible collections"
ansible.builtin.include_tasks:
file: "../tasks/install_collections.yml"
---
# tasks/install_collections.yml
- name: Install collections
ansible.builtin.command: "ansible-galaxy collection install -r ../collections/requirements.yml"
register: collections_install
changed_when: collections_install.rc != 0
Any workaround? I also faced the same issues.
yea you would need to put a collections/requirements.yml folder in the same path where the playbook you are running is.
This is resolved with version v2.9.109 I think the issue can be closed.
I think was best solution search requirements.yml in all popular places:
/requirements.yml (root project dir)
Why is /requirements.yml (root project dir)
not installing?
@DeadNews, the root folder doesn't work for me either ... but I guess this is covered in #1240?
File exists, however semaphore cant seem to find it