Open staticdev opened 7 months ago
@staticdev
Sorry to make you confused. I don't find any dependency in the repo you provided.
Please follow this document to set the dependency for molecule, https://ansible.readthedocs.io/projects/molecule/configuration/#dependency
And if the dependency is for the role itself, it should be in meta/main.yaml
while if the dependency is only for the molecule test, it should be in molecule.yaml
Let me know if it works for you
Thanks for your answer @zhan9san! Actually I always had the dependency for my role on meta/main.yml
, I also tried adding in addition to there, also on dependency.yml
and configure both role-file
and requirements-file
to dependency.yml
. On the logs on my GA tests with molecule 6 I had in the logs:
Molecule default > dependency
Starting galaxy role install process
- staticdev.pyenv (2.10.2) is already installed, skipping.
INFO Dependency completed successfully.
WARNING Skipping, missing the requirements file.
...
Molecule default > converge
PLAY [Converge] ****************************************************************
TASK [Gathering Facts] *********************************************************
ok: [instance]
TASK [Update apt cache.] *******************************************************
changed: [instance]
TASK [Update pyOpenSSL.] *******************************************************
changed: [instance]
TASK [Include staticdev.python_developer] **************************************
ERROR! the role 'staticdev.pyenv' was not found in ansible.legacy:/home/runner/work/ansible-role-python-developer/ansible-role-python-developer/staticdev.python_developer/molecule/default/roles:/home/runner/.cache/molecule/staticdev.python_developer/default/roles:/home/runner/work/ansible-role-python-developer/ansible-role-python-developer:/home/runner/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/home/runner/work/ansible-role-python-developer/ansible-role-python-developer:/home/runner/work/ansible-role-python-developer/ansible-role-python-developer/staticdev.python_developer/molecule/default
The error appears to be in '/home/runner/work/ansible-role-python-developer/ansible-role-python-developer/staticdev.python_developer/meta/main.yml': line 37, column 5, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
dependencies:
- name: staticdev.pyenv
^ here
I noticed on last major release of molecule it stopped installing it for some reason and I saw some changes related to dependencies such as https://github.com/ansible/molecule/pull/3956. To continue with my role, I found a solution to not have a dependency at all, but I believe there could be a bug in molecule. It can be verified checking our my previous commit to this one https://github.com/staticdev/ansible-role-python-developer/commit/65eb677846851573b736f3f220c8da02adc42d88#diff-92c74e80f0140aa012f39f58b4259dbe74401cdc9a0b84269295f480b9961809
@staticdev
There must be some misunderstand on https://github.com/ansible/molecule/pull/3956/files.
It is said the role-path
and collection-path
would be removed and they should be configured in ansible.cfg, which has no effect on role-file
and requirements-file
described in this doc, https://ansible.readthedocs.io/projects/molecule/configuration/#dependency
Here is what I tested.
$ cat molecule/default/molecule.yml
---
dependency:
name: galaxy
options:
requirements-file: requirements.yml
$ cat requirements.yml
roles:
- name: staticdev.pyenv
version: 2.10.2
@staticdev
There must be some misunderstand on https://github.com/ansible/molecule/pull/3956/files.
It is said the
role-path
andcollection-path
would be removed and they should be configured in ansible.cfg, which has no effect onrole-file
andrequirements-file
described in this doc, https://ansible.readthedocs.io/projects/molecule/configuration/#dependencyHere is what I tested.
$ cat molecule/default/molecule.yml --- dependency: name: galaxy options: requirements-file: requirements.yml
$ cat requirements.yml roles: - name: staticdev.pyenv version: 2.10.2
This is exactly what I had for a long time in this repo and it always worked until August. I did no change on it's test config except the upgrades on external packages such as molecule. I don't have a clue why it broke.
I have a repo of an ansible role tested with molecule for some years now. Without a real change, my tests started failing on August 2023 when I import my role due to its dependencies on
meta/main.yml
.I see on an early step:
For some reason I get the error:
The role exists on Ansible Galaxy with correct version. This error only happens on Github Actions, but not locally. I do not really understand why, but on my path locally molecule can find
staticdev.pyenv
and can import statically. Do I need to add anything extra to install the requirements?I tried found a change in the docs for syntax of
role-file
torequirements-file
, but both syntaxes give the same failure: