ansible/molecule

wrong documentation for collections dependencies?

trickert76 opened this issue · 3 comments

Issue Type

  • Bug report

Molecule and Ansible details

ansible --version && molecule --version
ansible [core 2.14.1]
  config file = /Users/trw/.ansible.cfg
  configured module search path = ['/Users/trw/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/trw/Library/Python/3.9/lib/python/site-packages/ansible
  ansible collection location = /Users/trw/.ansible/collections:/usr/share/ansible/collections
  executable location = /Users/trw/Library/Python/3.9/bin/ansible
  python version = 3.9.6 (default, Oct 18 2022, 12:41:40) [Clang 14.0.0 (clang-1400.0.29.202)] (/Library/Developer/CommandLineTools/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True
molecule 4.0.4 using python 3.9 
    ansible:2.14.1
    delegated:4.0.4 from molecule
    docker:2.1.0 from molecule_docker requiring collections: community.docker>=3.0.2 ansible.posix>=1.4.0

Molecule installation method (one of):

  • pip

Ansible installation method (one of):

  • pip

Detail any linters or test runners used:

Desired Behavior

Molecule documentation should mention, that the collections.yml is parsed during dependency management.
And the output of galaxy dependency should change to

INFO     Running default > dependency
WARNING  Skipping, missing the requirements file.
WARNING  Skipping, missing the collections file.

Actual Behaviour

I'd like add a collection to my molecule test, because there are filters in the collection, I need to use. See https://stackoverflow.com/questions/75765614/ansible-molecule-ignores-collection-requirements/75775152#75775152 for description. The role has no other dependencies then this collection.

I've added the collection as described here - https://molecule.readthedocs.io/en/latest/configuration/#dependency
According to that, I cannot use requirements.yml, because it must contains role only.

# molecule.yml
---
dependency:
  name: galaxy
  options:
    requirements-file: collections.yml
...
# collections.yml
---
collections:
  - name: https://github.com/acoby/ansible-collection.git
    type: git
    version: main

But when I run molecule test, I'm getting twice the warning and the test failed because of the missing filters from the collection.

INFO     Running default > dependency
WARNING  Skipping, missing the requirements file.
WARNING  Skipping, missing the requirements file.

I didnt really understand why this happens. Then I removed the options key again

dependency:
  name: galaxy
...

and then it works.

INFO     Running default > dependency
WARNING  Skipping, missing the requirements file.
Cloning into '/homedir/.ansible/tmp/ansible-local-83810gxw1uelq/tmpkm0riwyv/ansible-collectionczw7j2r4'...
...

So, there is something wrong and not documented.

@trickert76

Would you help verify whether it is addressed in #3916?

yepp, thats fine für role-file. But I'm not sure, if its okay with collections.yml in requirements-file. This isnt mentioned in #3916. What is the default search path für requirements-file? Thats not clear. Because I've set requirements-file: collections.yml which is under /molecule/default/collections.yml.

Hi @trickert76

Thanks for your reply. I have an update on #3916.

I am not a native English speaker, there may be some unclear expressions.

Could you help review it again?