Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make molecule work with ansible-base #2755

Closed
geerlingguy opened this issue Jul 20, 2020 · 10 comments
Closed

Make molecule work with ansible-base #2755

geerlingguy opened this issue Jul 20, 2020 · 10 comments

Comments

@geerlingguy
Copy link
Contributor

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—which 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.

@ssbarnea
Copy link
Member

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.

@geerlingguy
Copy link
Contributor Author

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 :-/

@piroux
Copy link

piroux commented Sep 23, 2020

@ssbarnea
Copy link
Member

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.

@ssbarnea
Copy link
Member

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

@richm
Copy link

richm commented Jan 20, 2021

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?

@ssbarnea
Copy link
Member

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.

@tadeboro
Copy link
Contributor

@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.

@yajo
Copy link
Contributor

yajo commented Feb 5, 2021

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"

@jorhett
Copy link

jorhett commented Mar 16, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants