molecule-action icon indicating copy to clipboard operation
molecule-action copied to clipboard

Couldn't resolve module/action 'community.docker.docker_container'

Open anarion80 opened this issue 11 months ago • 5 comments

I've been running the action for a while now, and recently (couple months?) is keeps failing with the following error:

  ERROR! couldn't resolve module/action 'community.docker.docker_container'. This often indicates a misspelling, missing collection, or incorrect module path.
  
  The error appears to be in '/app/.venv/lib/python3.11/site-packages/molecule_plugins/docker/playbooks/destroy.yml': line 15, column 7, but may
  be elsewhere in the file depending on the exact syntax problem.
  
  The offending line appears to be:
  
  
      - name: Destroy molecule instance(s)
        ^ here
  CRITICAL Ansible return code was 4, command was: ansible-playbook --diff --inventory /github/home/.cache/molecule/authelia/default/inventory --skip-tags molecule-notest,notest /app/.venv/lib/python3.11/site-packages/molecule_plugins/docker/playbooks/destroy.yml
  WARNING  An error occurred during the test sequence action: 'destroy'. Cleaning up.

So it's as if Ansible within the action container can't see the module. I'm not the expert in dependency management here, but I can see ansible-core in the poetry.lock file and I can't see this community module added anywhere to this "minimalist language and runtime package" that ansible-core is.

One other github molecule action seems to be requiring the full "ansible" package: https://github.com/robertdebock/docker-github-action-molecule/blob/master/requirements.txt

So is this a bug in molecule-action? If not, how else can I add comunity.docker.docker_container to my tests, in general, not to each role?

anarion80 avatar Feb 24 '24 19:02 anarion80

Can you provide me a link to your github actions? I will try to reproduce

gofrolist avatar Feb 24 '24 21:02 gofrolist

Here is the action in question: https://github.com/anarion80/ansible-nas/blob/main/.github/workflows/integration.yml Here is the action result: https://github.com/anarion80/ansible-nas/actions/runs/8033790401/job/21944642579 And here are all my unsuccessful attempts to fix this: https://github.com/anarion80/ansible-nas/tree/fix_docker_molecule

anarion80 avatar Feb 25 '24 08:02 anarion80

These ansible collections should be installed in a prerun step using requirements.yml file but because there is a specific folder structure you're using and option molecule_working_dir: ${{ matrix.role }} action goes into matrix.role folder and can't find requirements.yml and didn't install ansible collections. I tried to specify path to this file but unfortunately it didn't work

    dependency:
      name: galaxy
      options:
        role-file: ../../requirements.yml

As a workaround you can create a symlink of requirements.yml in every roles folder I created a PR as example for you https://github.com/anarion80/ansible-nas/pull/110

gofrolist avatar Mar 04 '24 03:03 gofrolist

Thanks! It seems to be working with this workaround: https://github.com/anarion80/ansible-nas/actions/runs/8139600112 (although I need to now fix all the neglected individual tests).

So although I was hoping for your action to just include the community module(s) or full ansible inside, I can take this and you can close the issue.

anarion80 avatar Mar 04 '24 12:03 anarion80

I just ran into this problem in a CI run for one of my roles: https://github.com/dbrennand/ansible-role-autorestic/actions/runs/9362630720/job/25771742820

The issue for me was because I modified the default molecule test_sequence in https://github.com/dbrennand/ansible-role-autorestic/commit/b652325f0d099852a3e6aa07279d2611ac1a998d

It seems that the dependency stage seems to install the community.docker collection?

dbrennand avatar Jun 04 '24 07:06 dbrennand