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

molecule reset requires unused module #166

Open
konstruktoid opened this issue Apr 27, 2023 · 3 comments
Open

molecule reset requires unused module #166

konstruktoid opened this issue Apr 27, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@konstruktoid
Copy link
Contributor

Issue Type

  • Bug report

Molecule and Ansible details

molecule 5.0.0 using python 3.10 
    ansible:2.14.5
    azure:23.4.0 from molecule_plugins
    containers:23.4.0 from molecule_plugins requiring collections: ansible.posix>=1.3.0 community.docker>=1.9.1 containers.podman>=1.8.1
    delegated:5.0.0 from molecule
    docker:23.4.0 from molecule_plugins requiring collections: community.docker>=3.0.2 ansible.posix>=1.4.0
    ec2:23.4.0 from molecule_plugins
    gce:23.4.0 from molecule_plugins requiring collections: google.cloud>=1.0.2 community.crypto>=1.8.0
    podman:23.4.0 from molecule_plugins requiring collections: containers.podman>=1.7.0 ansible.posix>=1.3.0
    vagrant:23.4.0 from molecule_plugins

Molecule installation method (one of):

  • pip

Ansible installation method (one of):

  • pip

Desired Behavior

Successful moecule reset

Actual Behaviour

Repo in question: https://github.com/konstruktoid/ansible-role-docker-rootless

$ git diff
diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml
index d75c4a0..6f80b8d 100644
--- a/molecule/default/molecule.yml
+++ b/molecule/default/molecule.yml
@@ -158,9 +158,6 @@ platforms:
     memory: 1024
 verifier:
   name: ansible
-lint: |
-  set -e
-  ansible-lint
 scenario:
   name: default
   create_sequence:
@@ -187,7 +184,6 @@ scenario:
     - destroy
   test_sequence:
     - dependency
-    - lint
     - cleanup
     - destroy
     - syntax
$ molecule test
WARNING  The scenario config file ('/home/tsj/Code/Git/ansible-role-docker-rootless/molecule/default/molecule.yml') has been modified since the scenario was created. If recent changes are important, reset the scenario with 'molecule destroy' to clean up created items or 'molecule reset' to clear current configuration.
[...]
$ grep -A3 driver molecule/default/molecule.yml 
driver:
  name: vagrant
  provider:
    name: virtualbox
$ molecule reset
WARNING  The scenario config file ('/home/tsj/Code/Git/ansible-role-docker-rootless/molecule/default/molecule.yml') has been modified since the scenario was created. If recent changes are important, reset the scenario with 'molecule destroy' to clean up created items or 'molecule reset' to clear current configuration.
WARNING  vagrant driver is not installed.
INFO     default scenario test matrix: 
INFO     Performing prerun with role_name_check=0...
INFO     Running ansible-galaxy collection install -v -r requirements.yml
INFO     Set ANSIBLE_LIBRARY=/home/tsj/.cache/ansible-compat/ca6d44/modules:/home/tsj/.ansible/plugins/modules:/usr/share/ansible/plugins/modules
INFO     Set ANSIBLE_ROLES_PATH=/home/tsj/.cache/ansible-compat/ca6d44/roles:/home/tsj/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles
INFO     Using /home/tsj/.cache/ansible-compat/ca6d44/roles/konstruktoid.docker_rootless symlink to current repository in order to enable Ansible to find the role using its expected full name.
INFO     Removing /home/tsj/.cache/molecule/ansible-role-docker-rootless/default
Traceback (most recent call last):
  File "/home/tsj/Code/venvs/py310/bin/molecule", line 8, in <module>
    sys.exit(main())
  File "/home/tsj/Code/venvs/py310/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/tsj/Code/venvs/py310/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/tsj/Code/venvs/py310/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/tsj/Code/venvs/py310/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/tsj/Code/venvs/py310/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/tsj/Code/venvs/py310/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/tsj/Code/venvs/py310/lib/python3.10/site-packages/molecule/command/reset.py", line 48, in reset
    driver.reset()
  File "/home/tsj/Code/venvs/py310/lib/python3.10/site-packages/molecule_plugins/docker/driver.py", line 256, in reset
    import docker
ModuleNotFoundError: No module named 'docker'
@konstruktoid konstruktoid added the bug Something isn't working label Apr 27, 2023
@ssbarnea
Copy link
Member

That looks like a bug in molecule-plugins, it should do lazy imports as dependencies are not always installed.

Maybe we should ignore (or warn) about plugins that cannot be instantiated? Any suggestions?

@konstruktoid
Copy link
Contributor Author

Maybe just information that "No module named 'docker' is installed." since I assume it would be noticeable if the module wasn't installed but expected to be used the the molecule tests

@ssbarnea ssbarnea transferred this issue from ansible/molecule Jun 23, 2023
@theonejj
Copy link

theonejj commented Sep 27, 2023

This issue should be fixed when molecule#2540 is closed

EDIT:
you can do it manually by removing the ~/.cache/molecule/
and remove all the things created by the driver, vagrant will do that in the destroy playbook

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants