ansible/molecule

Molecule 5 failing with Ansible 8

dgibbs64 opened this issue ยท 9 comments

Issue Type

  • Bug report

Molecule and Ansible details

ansible 8 molecule 5

Molecule installation method (one of):

  • pip

Ansible installation method (one of):

  • pip

Detail any linters or test runners used:

Desired Behavior

I would like my Molecule test using Github Actions to pass

Actual Behaviour

Since Ansible 8 has been released suddenly all my github actions are failing

Run molecule test
  molecule test
  shell: /usr/bin/bash -e {0}
  env:
    PY_COLORS: 1
    ANSIBLE_FORCE_COLOR: 1
    MOLECULE_IMAGE: centos7
WARNING  docker driver is not installed.
INFO     default scenario test matrix: dependency, cleanup, destroy, syntax, create, prepare, converge, idempotence, side_effect, verify, cleanup, destroy
INFO     Performing prerun with role_name_check=0...
INFO     Set ANSIBLE_LIBRARY=/home/runner/.cache/ansible-compat/36[2](https://github.com/dgibbs64/ansible-role-qemu_guest_agent/actions/runs/5166366259/jobs/9306453823#step:5:2)c0a/modules:/home/runner/.ansible/plugins/modules:/usr/share/ansible/plugins/modules
INFO     Set ANSIBLE_COLLECTIONS_PATH=/home/runner/.cache/ansible-compat/[3](https://github.com/dgibbs64/ansible-role-qemu_guest_agent/actions/runs/5166366259/jobs/9306453823#step:5:3)62c0a/collections:/home/runner/.ansible/collections:/usr/share/ansible/collections
INFO     Set ANSIBLE_ROLES_PATH=/home/runner/.cache/ansible-compat/362c0a/roles:/home/runner/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles
INFO     Using /home/runner/.cache/ansible-compat/362c0a/roles/dgibbs6[4](https://github.com/dgibbs64/ansible-role-qemu_guest_agent/actions/runs/5166366259/jobs/9306453823#step:5:4).qemu_guest_agent symlink to current repository in order to enable Ansible to find the role using its expected full name.
INFO     Running default > dependency
Molecule default > dependency
INFO     Running default > cleanup
Molecule default > cleanup
INFO     Running default > destroy
Molecule default > destroy
Traceback (most recent call last):
  File "/home/runner/.local/bin/molecule", line 8, in <module>
    sys.exit(main())
  File "/usr/lib/python3/dist-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 10[5](https://github.com/dgibbs64/ansible-role-qemu_guest_agent/actions/runs/5166366259/jobs/9306453823#step:5:5)3, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1[6](https://github.com/dgibbs64/ansible-role-qemu_guest_agent/actions/runs/5166366259/jobs/9306453823#step:5:6)59, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line [7](https://github.com/dgibbs64/ansible-role-qemu_guest_agent/actions/runs/5166366259/jobs/9306453823#step:5:7)54, in invoke
    return __callback(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/runner/.local/lib/python3.10/site-packages/molecule/command/test.py", line 113, in test
    base.execute_cmdline_scenarios(scenario_name, args, command_args, ansible_args)
  File "/home/runner/.local/lib/python3.10/site-packages/molecule/command/base.py", line 119, in execute_cmdline_scenarios
    execute_scenario(scenario)
  File "/home/runner/.local/lib/python3.10/site-packages/molecule/command/base.py", line 162, in execute_scenario
    execute_subcommand(scenario.config, action)
  File "/home/runner/.local/lib/python3.10/site-packages/molecule/command/base.py", line 152, in execute_subcommand
    return command(config).execute(args)
  File "/home/runner/.local/lib/python3.10/site-packages/molecule/logger.py", line 1[8](https://github.com/dgibbs64/ansible-role-qemu_guest_agent/actions/runs/5166366259/jobs/9306453823#step:5:9)[9](https://github.com/dgibbs64/ansible-role-qemu_guest_agent/actions/runs/5166366259/jobs/9306453823#step:5:10), in wrapper
    rt = func(*args, **kwargs)
  File "/home/runner/.local/lib/python3.[10](https://github.com/dgibbs64/ansible-role-qemu_guest_agent/actions/runs/5166366259/jobs/9306453823#step:5:11)/site-packages/molecule/logger.py", line 100, in wrapper
    return func(*args, **kwargs)
  File "/home/runner/.local/lib/python3.10/site-packages/molecule/command/destroy.py", line 55, in execute
    self._config.provisioner.destroy()
  File "/home/runner/.local/lib/python3.10/site-packages/molecule/provisioner/ansible.py", line 767, in destroy
    pb.execute()
  File "/home/runner/.local/lib/python3.10/site-packages/molecule/provisioner/ansible_playbook.py", line 116, in execute
    result = util.run_command(self._ansible_command, debug=self._config.debug)
  File "/home/runner/.local/lib/python3.10/site-packages/molecule/util.py", line 149, in run_command
    result = app.runtime.exec(
AttributeError: 'Runtime' object has no attribute 'exec'
Error: Process completed with exit code 1.

Please see this github action for full details of the failure
https://github.com/dgibbs64/ansible-role-qemu_guest_agent/actions/runs/5166366259/jobs/9306453823

I recently reported this issue #3883 and wonder if it might be something simular to changes to the way docker drivers are configured?

Could you plz install molecule-plugins[docker] and have a try?

Sure I will try. That seems odd as the last fix was to remove molecule[docker] and replace it with molecule-plugins.
#3883 (comment)

Can confirm https://github.com/dgibbs64/ansible-role-qemu_guest_agent/actions/runs/5175056563 re-adding molecule[docker] worked

      - name: Install test dependencies
        run: pip3 install ansible molecule-plugins molecule[docker] docker yamllint ansible-lint

Please confim if it should be molecule[docker] or molecule-plugins[docker]

edit: tested molecule-plugins[docker] it failed molecule[docker] passed

molecule[docker] is deprecated. Please consider use molecule-plugins[docker].

In short, could you use molecule-plugins[docker] and try to remove ansible-lint package in molecule workflow as you have run ansible-lint in a separated Lint job?


TLDR

I guess it's the ansible-compat's issue.

Currently, the latest version of molecule-pluginsis23.4.1, ansible-lintis6.17.0`.

molecule-plugins==23.4.1 requires molecule >= 5.0, so molecule==5.0.1 is installed

So molecule == 5.1 requires ansible-compat >= 2.2.0, < 4.0.0, but ansible-lint==6.17.0 requires ansible-compat>=4.0.5, then ansible-compat==4.1.2 is installed.

It may be fixed in #3904

My workflow has a Lint job and a Molecule job. However, it looks like I run lint again in the molecule job. I have removed the linting in the molecule job and now I do:

pip3 install ansible molecule-plugins molecule-plugins[docker] docker

this seems to work now and is a little more efficient.

For simplicity, pip3 install molecule-plugins[docker] is enough for your test. The rest are all dependencies of molecule-plugins[docker]

For the incompatibility issues of ansible-compat, I'll take a look.

This will be fixed with #3904 and it's probably a related duplicate of #3903 and #3927.

Fixed by 5.1.0 #3942