Molecule: Make molecule work with ansible-base

Created on 20 Jul 2020  路  10Comments  路  Source: ansible-community/molecule

Issue Type

  • Feature request

Molecule and Ansible details

molecule 3.0.4
   ansible==2.10.0b1 python==3.7

Molecule installation method (one of):

  • pip

Ansible installation method (one of):

  • pip

Desired Behavior

I have been doing some testing with both ansible-base and ansible, and noticed that Molecule fails to work at all (at least with the default Docker driver) under ansible-base, since it calls the docker_container module directly鈥攚hich is not part of the base distribution anymore.

It would be nice if Molecule were updated to install the community.general collection and use the community.general.docker_container module if it detects it is not available... somehow.

This is probably a bit of a niche use case, though, but it would be helpful for me so I could test whether a bug affects ansible-base _and_ ansible (2.10 and later), or just ansible-base or ansible (2.10 and later).

Right now I basically can't use molecule if I'm testing with ansible-base locally.

enhancement

Most helpful comment

Thanks for the details @tadeboro. For me, adding this tests/molecule/default/collections.yml file fixed the problem (using ansible-base 2.10 and molecule 3.2.3:

collections:
  - name: community.docker
    version: ">=1.2.0,<2"
  - name: community.general
    version: ">=2,<3"

All 10 comments

There are serious issues with ansible wheels with 2.10 especially related to upgrading from 2.9.x but they have nothing to do with molecule itself.

We cannot start using FQCN until we drop support for 2.8, which would be after 2.10 is GA.

At this moment we cannot really make molecule depend on ansible-base as we have modules that need full ACD. Still, once we move them out of core and we also move minimal version to 2.10, we could switch to requiring ansible-base. In case it was not obvious this cannot be sooner than one year from now.

Acknowledged; it's going to be a bit of a mess trying to debug playbook-level issues that arise between ansible, ansible-base, and ansible 2.9 and lower in the meanwhile :-/

Yep, but we will be able to add dependency on ansible-base only when we drop support for 2.9, which will happen when 2.11 is released.

Since 3.1.3 this is already true, molecule no longer needs ansible.

How did you get this to work? Does molecule support ansible 2.10? I figured out that I have to pip install molecule[docker] and ansible-galaxy collection install community.docker to get the docker functionality, but molecule still fails:
ERROR! couldn't resolve module/action 'docker_container'. This often indicates a misspelling, missing collection, or incorrect module path.

because molecule_docker/playbooks/destroy.yml uses docker_container: instead of community.docker.docker_container:? Or is there some way to get the ansible docker modules in a "legacy" format?

We must keep the short names for backwards compatibility but please add a PR to add the "collections:" bit which is ignored on older ansible versions.

@richm Things are a bit complicated at the moment because the docker Ansible content is in transition between the community.general and the community.docker collections. If you want to use molecule, these are your options right now:

  1. molecule + ansible 2.9 -> just works, nothing to do
  2. molecule + ansible < 3.0.0 -> just works, nothing to do
  3. molecule + ansible >= 3.0.0 -> just works, nothing to do
  4. molecule + ansible-base 2.10 -> install community.general < 2.0.0 collection

Once community.general 2.0.0 is out, there will be one more valid combination:

  1. molecule + ansible-base 2.10 -> install community.general >= 2.0.0 and community.docker collections

Once molecule drops support for Ansible 2.8, we can start using FQCNs. The situation will then change into this:

  1. molecule + ansible 2.9 -> install community.docker
  2. molecule + ansible < 3.0.0 -> install community.docker
  3. molecule + ansible >= 3.0.0 -> just works
  4. molecule + ansible-base 2.10 -> install community.docker

I hope this helps.

Thanks for the details @tadeboro. For me, adding this tests/molecule/default/collections.yml file fixed the problem (using ansible-base 2.10 and molecule 3.2.3:

collections:
  - name: community.docker
    version: ">=1.2.0,<2"
  - name: community.general
    version: ">=2,<3"

FYI these aren't an issue with either Ansible 3.0 or 3.1 which include the necessary versions. Only a problem if you have an older version installed in your collections.

Ansible 3.0

$ ansible-galaxy collection list |grep -e docker -e general
community.docker              1.2.2
community.general             2.0.1

Ansible 3.1

$ ansible-galaxy collection list |grep -e docker -e general
community.docker              1.3.0
community.general             2.2.0
Was this page helpful?
0 / 5 - 0 ratings

Related issues

dfinninger picture dfinninger  路  5Comments

dj-wasabi picture dj-wasabi  路  3Comments

ssbarnea picture ssbarnea  路  4Comments

r0ckyte picture r0ckyte  路  5Comments

asg1612 picture asg1612  路  4Comments