ansible/molecule

Molecule 5.0.1 playbook keyerror

watsonb opened this issue · 0 comments

Issue Type

  • Bug report

Molecule and Ansible details

ansible --version && molecule --version

ansible [core 2.14.4]
  config file = None
  configured module search path = ['/home/ben/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/ben/venv3_ansible-7.4.0/lib/python3.10/site-packages/ansible
  ansible collection location = /home/ben/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/ben/venv3_ansible-7.4.0/bin/ansible
  python version = 3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0] (/home/ben/venv3_ansible-7.4.0/bin/python)
  jinja version = 3.1.2
  libyaml = True
molecule 5.0.1 using python 3.10 
    ansible:2.14.4
    azure:23.4.1 from molecule_plugins
    containers:23.4.1 from molecule_plugins requiring collections: ansible.posix>=1.3.0 community.docker>=1.9.1 containers.podman>=1.8.1
    delegated:5.0.1 from molecule
    docker:23.4.1 from molecule_plugins requiring collections: community.docker>=3.0.2 ansible.posix>=1.4.0
    ec2:23.4.1 from molecule_plugins
    gce:23.4.1 from molecule_plugins requiring collections: google.cloud>=1.0.2 community.crypto>=1.8.0
    podman:23.4.1 from molecule_plugins requiring collections: containers.podman>=1.7.0 ansible.posix>=1.3.0
    vagrant:23.4.1 from molecule_plugins

Molecule installation method (one of):

  • pip

Ansible installation method (one of):

  • pip

Detail any linters or test runners used:

Desired Behavior

Molecule should run without throwing any errors.

Actual Behaviour

When running various molecule sub-commands, I'm seeing these funny "KeyError" errors thrown:

INFO     Running default > prepare
ERROR    'prepare'
Traceback (most recent call last):
  File "/home/ben/venv3_ansible-7.4.0/lib/python3.10/site-packages/molecule/provisioner/ansible_playbooks.py", line 87, in _get_playbook
    playbook = driver_dict
KeyError: 'prepare'
ERROR    'prepare'
Traceback (most recent call last):
  File "/home/ben/venv3_ansible-7.4.0/lib/python3.10/site-packages/molecule/provisioner/ansible_playbooks.py", line 87, in _get_playbook
    playbook = driver_dict
KeyError: 'prepare'
ERROR    'converge'
Traceback (most recent call last):
  File "/home/ben/venv3_ansible-7.4.0/lib/python3.10/site-packages/molecule/provisioner/ansible_playbooks.py", line 87, in _get_playbook
    playbook = driver_dict
KeyError: 'converge'

I have a "base" molecule configuration file (base_config.yml) that has this section defined:

provisioner:
  name: ansible
  playbooks:
    delegated:
      create: ../resources/playbooks/create.yml
      destroy: ../resources/playbooks/destroy.yml

I also have a scenario-specific molecule.yml configuration file with the following section:

provisioner:
  name: ansible
  playbooks:
    prepare: ../shared/prepare.yml
    converge: ../shared/playbook.yml
    playbook: ../shared/playbook.yml
    verify: ../shared/verify.yml

And I run molecule as: molecule -c molecule/base_config.yml test

I see the KeyError output on stdout and where it is being thrown in the molecule code. But I don't know why the error is being thrown. My understanding is this provisioner section should be merged based on both config files (that's the way it has worked historically anyway). While the error is being thrown, the converge and verify playbooks appear that they're being found correctly as I'm seeing their outputs as well.