ansible / molecule

Molecule aids in the development and testing of Ansible content: collections, playbooks and roles
https://ansible.readthedocs.io/projects/molecule/
MIT License
3.87k stars 659 forks source link

Molecule converge with specific scenario ends up with an error #4179

Closed ep4sh closed 4 months ago

ep4sh commented 4 months ago

Prerequisites

Environment

molecule 24.2.1 using python 3.12 
    ansible:2.16.6
    azure:23.5.3 from molecule_plugins
    containers:23.5.3 from molecule_plugins requiring collections: ansible.posix>=1.3.0 community.docker>=1.9.1 containers.podman>=1.8.1
    default:24.2.1 from molecule
    docker:23.5.3 from molecule_plugins requiring collections: community.docker>=3.4.11 ansible.posix>=1.4.0
    ec2:23.5.3 from molecule_plugins
    gce:23.5.3 from molecule_plugins requiring collections: google.cloud>=1.0.2 community.crypto>=1.8.0
    openstack:23.5.3 from molecule_plugins requiring collections: openstack.cloud>=2.1.0
    podman:23.5.3 from molecule_plugins requiring collections: containers.podman>=1.7.0 ansible.posix>=1.3.0
    vagrant:23.5.3 from molecule_plugins

What happened

running molecule converge -s os-repo ends with error

Expectation: no errors with different run on test suite (scenario)

Reproducing example

(venv)  ranger (main) ✗ molecule init scenario os-repo
INFO     Initializing new scenario os-repo...

PLAY [Create a new molecule scenario] ******************************************

TASK [Check if destination folder exists] **************************************
changed: [localhost]

TASK [Check if destination folder is empty] ************************************
ok: [localhost]

TASK [Fail if destination folder is not empty] *********************************
skipping: [localhost]

TASK [Expand templates] ********************************************************
changed: [localhost] => (item=molecule/os-repo/create.yml)
changed: [localhost] => (item=molecule/os-repo/molecule.yml)
changed: [localhost] => (item=molecule/os-repo/converge.yml)
changed: [localhost] => (item=molecule/os-repo/destroy.yml)

PLAY RECAP *********************************************************************
localhost                  : ok=3    changed=2    unreachable=0    failed=0    skipped=1    rescued=0    ignored=0

INFO     Initialized scenario in /home/pradchenko/wmx/tests/ranger/molecule/os-repo successfully.

Runs as expected.

Then change desired role name:

(venv)  ranger (main) ✗ cat molecule/os-repo/converge.yml 
---

- hosts: all
  become: yes
  gather_facts: true
  any_errors_fatal: true
  roles:
    - ranger

Then change desired platform:

(venv)  ranger (main) ✗ cat molecule/os-repo/molecule.yml 
---

scenario:
  name: os-repo

driver:
  name: docker

dependency:
  name: galaxy

platforms:
  - name: buster
    image:<private_docker_regsitry>/buster:systemd
    pre_build_image: true
    volumes:
      - /sys/fs/cgroup:/sys/fs/cgroup:rw
    tmpfs:
      - /run
    cgroupns_mode: host
    privileged: true
    tty: true
    command: "/sbin/init"

provisioner:
  name: ansible
  options:
    diff: True
    v: True

verifier:
  name: ansible
lint: 
  ansible-lint .
scenario:
  name: default

tree molecule path:

(venv)  ranger (main) ✗ tree molecule 
molecule
├── default
│   ├── converge.yml
│   └── molecule.yml
├── os-repo
│   ├── converge.yml
│   └── molecule.yml
├── stable
│   ├── converge.yml
│   └── molecule.yml
└── tests
    └── test_nginx_common.py

Run converge:

(venv)  ranger (main) ✗ molecule converge -s os-repo
WARNING  Driver docker does not provide a schema.
CRITICAL Scenario 'os-repo' not found.  Exiting.

thanks!

ep4sh commented 4 months ago

After scenario re-initialization and entire cache cleanup: rm -rf ~/.cache/molecule, I was able to use different scenarios.