Skip to content
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

No collections requirements file found #1144

Open
kirolous opened this issue Jan 12, 2023 · 14 comments
Open

No collections requirements file found #1144

kirolous opened this issue Jan 12, 2023 · 14 comments

Comments

@kirolous
Copy link

image

File exists, however semaphore cant seem to find it

@kirolous
Copy link
Author

on version 2.8.77
image

@jpylypiw
Copy link

jpylypiw commented Feb 1, 2023

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.

@nlvw
Copy link

nlvw commented Apr 20, 2023

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'.

@nlvw
Copy link

nlvw commented Apr 20, 2023

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.

@Ye-Min-Tun
Copy link

Any workaround? I also faced the same issues.

@Ye-Min-Tun
Copy link

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.

This still doesn't work for me.

andreas-marschke added a commit to andreas-marschke/semaphore that referenced this issue May 15, 2023
This changeset provides support to find `ansible-galaxy` collection
`requirements.yml` relative to repo path, in the `collections/` directory.
This supports inventory organisations where only one requirements.yml is
set up for the entire repo.

This partially resolves issues reported here: semaphoreui#1144
@andreas-marschke
Copy link
Collaborator

andreas-marschke commented May 25, 2023

@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
#1240

@Ye-Min-Tun
Copy link

@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.

@pydlv
Copy link

pydlv commented May 26, 2023

big issue causing me much pain please fix

@Ye-Min-Tun
Copy link

@pydlv You just need to add requirements.yml file (with the collections you need to install) under the collections directory of your workspace.

@guard43ru
Copy link

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

@alexbarton
Copy link

Fully agree!

But probably reverse the order, and use the first one found ("most specific one")?

@rwaffen
Copy link

rwaffen commented Sep 14, 2023

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

@RusticPotatoes
Copy link

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.

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

No branches or pull requests

10 participants