molecule: molecule fails in GitHub actions with: ansible_compat.errors.InvalidPrerequisiteError: Collection 'community.docker' not found in '['/home/runner/.ansible/collections', '/usr/share/ansible/collections']'
Issue Type
- Bug report
Molecule and Ansible details
ansible [core 2.15.3]
config file = None
configured module search path = ['/home/runner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/ansible
ansible collection location = /home/runner/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/hostedtoolcache/Python/3.11.4/x64/bin/ansible
python version = 3.11.4 (main, Jun 7 2023, 11:01:02) [GCC 11.3.0] (/opt/hostedtoolcache/Python/3.11.4/x64/bin/python)
jinja version = 3.1.2
libyaml = True
molecule 6.0.0 using python 3.11
ansible:2.15.3
azure:23.5.0 from molecule_plugins
containers:23.5.0 from molecule_plugins requiring collections: ansible.posix>=1.3.0 community.docker>=1.9.1 containers.podman>=1.8.1
default:6.0.0 from molecule
docker:23.5.0 from molecule_plugins requiring collections: community.docker>=3.0.2 ansible.posix>=1.4.0
ec2:23.5.0 from molecule_plugins
gce:23.5.0 from molecule_plugins requiring collections: google.cloud>=1.0.2 community.crypto>=1.8.0
podman:23.5.0 from molecule_plugins requiring collections: containers.podman>=1.7.0 ansible.posix>=1.3.0
vagrant:23.5.0 from molecule_plugins
Molecule installation method (one of):
- pip
Ansible installation method (one of):
- pip
Detail any linters or test runners used: I don’t understand what is meant by this. I have made a branch of my role so you can look at the molecule and GitHub action configuration here.
Desired Behavior
It should just work.
Actual Behaviour
Molecule default > dependency
INFO Running from /home/runner/work/ansible-role-systemd-timesyncd/ansible-role-systemd-timesyncd : ansible-galaxy collection install -vvv community.docker:>=3.0.2
CRITICAL Collection 'community.docker' not found in '['/home/runner/.ansible/collections', '/usr/share/ansible/collections']'
Traceback (most recent call last):
File "/opt/hostedtoolcache/Python/3.11.4/x64/bin/molecule", line 8, in <module>
sys.exit(main())
^^^^^^
File "/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/click/decorators.py", line 33, in new_func
return f(get_current_context(), *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/molecule/command/test.py", line 113, in test
base.execute_cmdline_scenarios(scenario_name, args, command_args, ansible_args)
File "/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/molecule/command/base.py", line 123, in execute_cmdline_scenarios
execute_scenario(scenario)
File "/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/molecule/command/base.py", line 166, in execute_scenario
execute_subcommand(scenario.config, action)
File "/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/molecule/command/base.py", line 156, in execute_subcommand
return command(config).execute(args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/molecule/logger.py", line 189, in wrapper
rt = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/molecule/logger.py", line 100, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/molecule/command/dependency.py", line 40, in execute
self._config.dependency.execute()
File "/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/molecule/dependency/ansible_galaxy/__init__.py", line 95, in execute
invoker.execute()
File "/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/molecule/dependency/ansible_galaxy/base.py", line 115, in execute
super().execute()
File "/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/molecule/dependency/base.py", line 91, in execute
self._config.runtime.require_collection(name, version)
File "/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/ansible_compat/runtime.py", line 721, in require_collection
self.require_collection(name=name, version=version, install=False)
File "/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/ansible_compat/runtime.py", line 725, in require_collection
raise InvalidPrerequisiteError(msg)
ansible_compat.errors.InvalidPrerequisiteError: Collection 'community.docker' not found in '['/home/runner/.ansible/collections', '/usr/share/ansible/collections']'
For the full output of the action/workflow, see here.
Notes
I’ve tried around a bit with (neither helped):
-
adding
ansible-galaxy collection install community.docker
to the action, output said it was already installed (probably viapip3 install ansible
from the action) -
adding a
requirements.yml
including the community.docker collection anddependency: name: galaxy options: requirements-file: requirements
which didn’t help because that would require molecule to start which it doesn’t
I don’t know if I’m doing something wrong here or if that’s a bug with the recent 6.x release. I’ve had this setup with a few other roles before and it worked, likely with 5.x.
About this issue
- Original URL
- State: closed
- Created 10 months ago
- Reactions: 6
- Comments: 17 (9 by maintainers)
Commits related to this issue
- Pin dependencies due to failing build. See: https://github.com/ansible/molecule/issues/4017 Workaround: https://github.com/ansible/molecule/issues/4017#issuecomment-1681392506 — committed to jason-riddle/ansible-role-tailscale by jason-riddle 10 months ago
- Fix Failing CI (#74) * Pin dependencies due to failing build. See: https://github.com/ansible/molecule/issues/4017 Workaround: https://github.com/ansible/molecule/issues/4017#issuecomment-16813... — committed to jason-riddle/ansible-role-tailscale by jason-riddle 10 months ago
- fix: pin ansible* ansible/molecule#4017 — committed to juju4/ansible-ci-settings by juju4 10 months ago
- fix: https://github.com/ansible/molecule/issues/4017 — committed to paperless-ngx/ansible by stevenengland 10 months ago
- fix: https://github.com/ansible/molecule/issues/4017 (#99) * fix: https://github.com/ansible/molecule/issues/4017 — committed to paperless-ngx/ansible by stevenengland 10 months ago
- interim fix : pin latest ansible version due to ansible/molecule#4017 — committed to Rosa-Luxemburgstiftung-Berlin/ansible-role-unbound by zerwes 10 months ago
- interim fix : pin latest ansible version due to ansible/molecule#4017 — committed to Rosa-Luxemburgstiftung-Berlin/ansible-role-unbound by zerwes 10 months ago
- interim fix: pin latest ansible version due to ansible/molecule#4017 — committed to zerwes/ansible-role-checkmkagent by zerwes 10 months ago
- fix ansible latest molecule and pylint test (#36) * interim fix : pin latest ansible version due to ansible/molecule#4017 * interim fix : pin latest ansible version due to ansible/molecule#4017 — committed to Rosa-Luxemburgstiftung-Berlin/ansible-role-unbound by zerwes 10 months ago
- interim fix: pin latest ansible version due to ansible/molecule#4017 — committed to zerwes/ansible-role-checkmkagent by zerwes 10 months ago
- interim fix : pin latest ansible version due to ansible/molecule#4017 — committed to Rosa-Luxemburgstiftung-Berlin/ansible-role-opera-dns-ui by zerwes 10 months ago
- interim fix : pin latest ansible version due to ansible/molecule#4017 — committed to Rosa-Luxemburgstiftung-Berlin/ansible-role-gns3 by zerwes 10 months ago
- interim fix : pin latest ansible version due to ansible/molecule#4017 — committed to Rosa-Luxemburgstiftung-Berlin/ansible-role-opera-dns-ui by zerwes 10 months ago
- interim fix : pin latest ansible version due to ansible/molecule#4017 — committed to Rosa-Luxemburgstiftung-Berlin/ansible-role-gns3 by zerwes 10 months ago
- Revert "interim fix: pin latest ansible version due to ansible/molecule#4017" This reverts commit 0d0f6e1b5b80989bae239ab734b277a0c15947dc. — committed to zerwes/ansible-role-checkmkagent by zerwes 10 months ago
- Revert "interim fix : pin latest ansible version due to ansible/molecule#4017" This reverts commit e9e5b40c1021dcb75adb67670b16258aac1942ef. — committed to Rosa-Luxemburgstiftung-Berlin/ansible-role-gns3 by zerwes 10 months ago
- Revert "interim fix : pin latest ansible version due to ansible/molecule#4017" This reverts commit 97788eca632b6b11b7117c42afb8b68f8e3be8a1. — committed to Rosa-Luxemburgstiftung-Berlin/ansible-role-opera-dns-ui by zerwes 10 months ago
- Update ansible-compat to v4.1.7 (#4022) Fixes: #4017 — committed to ansible/molecule by audgirka 10 months ago
It seems that
ansible-compat
4.1.7 was just released (https://github.com/ansible/ansible-compat/releases/tag/v4.1.7) which has fixed this issue for me.pin ansible version
ansible==8.2.0 ansible-core==2.15.2
is sufficient for me (so ist this really molecule related?) see zerwes/git-remembrall#5@giner Thanks for the minimal repro. There was a change in ansible-core 2.15.3 related to ansible-galaxy and it’s default behaviour related to installing collections, I think this is related (https://github.com/ansible/ansible/issues/81515)
If I switch to core 2.15.2, we can see the molecule has installed the collections in my ~/.ansible:
Still digging…