question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Roles in playbook-local collections in not working in Molecule 3.0.6 with ansible 2.10

See original GitHub issue

Issue Type

  • Bug report

Molecule and Ansible details

$ molecule --version
molecule 3.0.6
   ansible==2.10.0a3 python==3.7

Molecule installation method (one of):

  • pip

Ansible installation method (one of):

  • pip

Detail any linters or test runners used:

Entire configuration is here: https://github.com/geerlingguy/ansible-content-testing

  1. Git clone that repo
  2. Install Ansible 2.10 distribution: pip3 install --pre ansible>=2.10
  3. Run molecule test (uses Docker to bring up a kind instance)

Desired Behavior

Roles that are in collections local to a playbook should be picked up and usable by Ansible.

See the example.one and example.two collections in the repository: https://github.com/geerlingguy/ansible-content-testing

Actual Behaviour

    TASK [Include a 'test' role from 'example.one' collection.] ********************
ERROR! the role 'example.one.test' was not found in community.kubernetes:ansible.legacy:/Users/jgeerling/Development/GitHub/ansible-content-testing/molecule/default/../../roles:/Users/jgeerling/.cache/molecule/ansible-content-testing/default/roles:/Users/jgeerling/Development/GitHub:/Users/jgeerling/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/Users/jgeerling/Development/GitHub/ansible-content-testing/molecule/default/../..

The error appears to be in '/Users/jgeerling/Development/GitHub/ansible-content-testing/tasks/same-name-roles.yml': line 4, column 11, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

  include_role:
    name: example.one.test
          ^ here

This started happening once 3.0.6 was released, and I believe the change in https://github.com/ansible-community/molecule/pull/2745 was what triggered the problem.

The molecule configuration is in the molecule subdirectory inside the ansible-content-testing repo.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
geerlingguycommented, Jul 20, 2020

Weird, with Ansible 2.9.10 installed I’m now getting:

--> Action: 'dependency'
ERROR! Unexpected Exception, this is probably a bug: cannot import name 'AnsibleCollectionLoader' from 'ansible.utils.collection_loader' (/usr/local/lib/python3.7/site-packages/ansible/utils/collection_loader/__init__.py)
    the full traceback was:
    
    Traceback (most recent call last):
      File "/usr/local/bin/ansible-galaxy", line 92, in <module>
        mycli = getattr(__import__("ansible.cli.%s" % sub, fromlist=[myclass]), myclass)
      File "/usr/local/lib/python3.7/site-packages/ansible/cli/__init__.py", line 22, in <module>
        from ansible.inventory.manager import InventoryManager
      File "/usr/local/lib/python3.7/site-packages/ansible/inventory/manager.py", line 38, in <module>
        from ansible.plugins.loader import inventory_loader
      File "/usr/local/lib/python3.7/site-packages/ansible/plugins/loader.py", line 26, in <module>
        from ansible.utils.collection_loader import AnsibleCollectionLoader, AnsibleFlatMapLoader, AnsibleCollectionRef
    ImportError: cannot import name 'AnsibleCollectionLoader' from 'ansible.utils.collection_loader' (/usr/local/lib/python3.7/site-packages/ansible/utils/collection_loader/__init__.py)

See here for fix: https://github.com/ansible-collections/community.kubernetes/issues/135#issuecomment-661189940

0reactions
ssbarneacommented, Aug 22, 2020

I think this was fixed with the latest versions as I was able to reproduce it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Ansible collections
Collections are a distribution format for Ansible content that can include playbooks, roles, modules, and plugins. You can install and use collections through...
Read more >
How to add integration tests to an Ansible collection with ...
Currently, Molecule doesn't know much about collections, so you should not use the molecule init command to create a collection (that only ...
Read more >
Episode 13 - Ansible Collections and a Test Plugin - YouTube
Jeff Geerling (geerlingguy) introduces Ansible Content Collections ; their history, what they can do, and how they can be used.
Read more >
About Ansible Molecule — Molecule Documentation
Molecule project is designed to aid in the development and testing of Ansible roles. Molecule provides support for testing with multiple instances, ...
Read more >
How to set up and use Python virtual environments for Ansible
Python's venv module gives you freedom to test new Ansible features ... You can also install Ansible roles and collections into a Python ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found