molecule: CRITICAL 'molecule/default/molecule.yml' glob failed. Exiting - Unable to run molecule

Prerequisites

  • This was not already reported in the past (duplicate check)
  • It does reproduce it with code from main branch (latest unreleased version)
  • I include a minimal example for reproducing the bug
  • The bug is not trivial, as for those a direct pull-request is preferred
  • Running pip check does not report any conflicts
  • I was able to reproduce the issue on a different machine
  • The issue is not specific to any driver other than ‘default’ one

Environment

$ ansible --version
ansible [core 2.16.2]
  config file = /home/iamgini/.ansible.cfg
  configured module search path = ['/home/iamgini/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.12/site-packages/ansible
  ansible collection location = /home/iamgini/collections:/home/iamgini/.ansible/collections/ansible_collections:/usr/share/ansible/collections/ansible_collections:/home/iamgini/ansible/ansible-real-life/ansible-molecule-demo/collections/ansible_collections
  executable location = /usr/bin/ansible
  python version = 3.12.1 (main, Dec 18 2023, 00:00:00) [GCC 13.2.1 20231205 (Red Hat 13.2.1-6)] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True

What happened

I have a collection with molecule configured and its working perfectly in one folder. Now I am trying to copy the molecule setup for another collection but facing the below error.

$ molecule create
CRITICAL 'molecule/default/molecule.yml' glob failed.  Exiting.

$ molecule test
CRITICAL 'molecule/default/molecule.yml' glob failed.  Exiting.

$ molecule reset
CRITICAL 'molecule/default/molecule.yml' glob failed.  Exiting.

$ molecule destroy
CRITICAL 'molecule/default/molecule.yml' glob failed.  Exiting.

I tried:

  1. re-copy the working extensions folder from another working collection dir but getting same result!
  2. Freshly done molecule init scenario

Any idea?

Reference code: https://github.com/iamgini/ansible-real-life/tree/main/ansible-molecule-demo

Reproducing example

No response

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 2
  • Comments: 18 (4 by maintainers)

Most upvoted comments

As was mentioned by @Ic0n4, Molecule fails to find the glob if the molecule files are under a folder in .gitignore:

I have the same issue. But I found out what was causing it—for me at least. When I run any molecule command and the molecule/default/molecule.yml file is listed in my .gitignore file, I get the error. After I remove the line in the .gitignore file, all commands work just fine. It is only the molecule.yml file. Every other Molecule file can be listed in the .gitignore file, and it works.

Is there any reason for this? I have a use case where I want my molecule files to not be checked into version control. This behavior seems unintentional to me.

I have the same issue. But I found out what was causing it—for me at least. When I run any molecule command and the molecule/default/molecule.yml file is listed in my .gitignore file, I get the error. After I remove the line in the .gitignore file, all commands work just fine. It is only the molecule.yml file. Every other Molecule file can be listed in the .gitignore file, and it works.

I am using Molecule inside a dev container. Let me know if you need the config for it.

Confirming that removing molecule/default/molecule.yml from .gitignore worked for me as well. I’m using molecule from venv but it’s a linux on bare metal. Any idea to why is it causing the issue?

I think the error message means that no directory named molecule/default/molecule.yml exists. Sometimes this happens to me when I am running molecule while in the wrong current working directory.

Looking at your reference code, I see that there is no molecule/default/molecule.yml, but extensions/molecule/default/molecule.yml

(assuming that the collection in question is in ansible-real-life/ansible-molecule-demo/ansible-devspaces-demo-brandor5/collections/ansible_collections/sample_namespace/sample_collection)

@iamgini thanks for the info. I’ve just created your example asi is shown below (quick approach) but instead of giving the inside folder of molecule the default value i changed it to my_rol_of_iamgini (execute the molecule init scenario my_rol_of_iamgini) .

myuser@ubuntu-dev:/tmp$ tree ansible_collections/
ansible_collections/
└── iamgini
    └── meetupdemo
        ├── docs
        ├── extensions
        │   └── molecule
        │       └── my_rol_of_iamgini
        │           ├── backup
        │           │   └── prepare.yml
        │           ├── converge.yml
        │           ├── create.yml
        │           ├── destroy.yml
        │           ├── molecule.yml
        │           ├── requirements.yml
        │           ├── tasks
        │           │   └── create-fail.yml
        │           └── verify.yml
        ├── galaxy.yml
        ├── meta
        │   └── runtime.yml
        ├── playbooks
        │   └── install_web.yml
        ├── plugins
        │   └── README.md
        └── roles
            └── web
                ├── defaults
                │   └── main.yml
                ├── files
                ├── handlers
                │   └── main.yml
                ├── meta
                │   └── main.yml
                ├── README.md
                ├── tasks
                │   └── main.yml
                ├── templates
                ├── tests
                │   ├── inventory
                │   └── test.yml
                └── vars
                    └── main.yml

20 directories, 21 files

Then i move to route below and exexute the following

myuser@ubuntu-dev:/tmp/ansible_collections/iamgini/meetupdemo/extensions$ ls
molecule
myuser@ubuntu-dev:/tmp/ansible_collections/iamgini/meetupdemo/extensions$ molecule converge -s my_rol_of_iamgini
INFO     my_rol_of_iamgini scenario test matrix: dependency, create, prepare, converge
INFO     Performing prerun with role_name_check=0...
INFO     Running my_rol_of_iamgini > dependency

Hope it helps you