Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

molecule broken with latest version of ansible-compat #3903

Closed
mcdonnnj opened this issue May 1, 2023 · 14 comments · Fixed by #3904
Closed

molecule broken with latest version of ansible-compat #3903

mcdonnnj opened this issue May 1, 2023 · 14 comments · Fixed by #3904
Labels

Comments

@mcdonnnj
Copy link

mcdonnnj commented May 1, 2023

Issue Type

  • Bug report

Molecule and Ansible details

$ ansible --version && molecule --version
ansible [core 2.13.9]
  config file = None
  configured module search path = ['/home/mcdonnnj/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/mcdonnnj/.pyenv/versions/3.11.3/envs/ansible-role-docker/lib/python3.11/site-packages/ansible
  ansible collection location = /home/mcdonnnj/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/mcdonnnj/.pyenv/versions/ansible-role-docker/bin/ansible
  python version = 3.11.3 (main, Apr 10 2023, 14:31:58) [GCC 12.2.0]
  jinja version = 3.1.2
  libyaml = True
molecule 5.0.0 using python 3.11
    ansible:2.13.9
    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.0 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 test should successfully perform testing.

Actual Behaviour

Traceback (most recent call last):
  File "/home/mcdonnnj/.pyenv/versions/ansible-role-docker/bin/molecule", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/mcdonnnj/.pyenv/versions/3.11.3/envs/ansible-role-docker/lib/python3.11/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mcdonnnj/.pyenv/versions/3.11.3/envs/ansible-role-docker/lib/python3.11/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home/mcdonnnj/.pyenv/versions/3.11.3/envs/ansible-role-docker/lib/python3.11/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mcdonnnj/.pyenv/versions/3.11.3/envs/ansible-role-docker/lib/python3.11/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mcdonnnj/.pyenv/versions/3.11.3/envs/ansible-role-docker/lib/python3.11/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mcdonnnj/.pyenv/versions/3.11.3/envs/ansible-role-docker/lib/python3.11/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mcdonnnj/.pyenv/versions/3.11.3/envs/ansible-role-docker/lib/python3.11/site-packages/molecule/command/test.py", line 113, in test
    base.execute_cmdline_scenarios(scenario_name, args, command_args, ansible_args)
  File "/home/mcdonnnj/.pyenv/versions/3.11.3/envs/ansible-role-docker/lib/python3.11/site-packages/molecule/command/base.py", line 119, in execute_cmdline_scenarios
    execute_scenario(scenario)
  File "/home/mcdonnnj/.pyenv/versions/3.11.3/envs/ansible-role-docker/lib/python3.11/site-packages/molecule/command/base.py", line 162, in execute_scenario
    execute_subcommand(scenario.config, action)
  File "/home/mcdonnnj/.pyenv/versions/3.11.3/envs/ansible-role-docker/lib/python3.11/site-packages/molecule/command/base.py", line 152, in execute_subcommand
    return command(config).execute(args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mcdonnnj/.pyenv/versions/3.11.3/envs/ansible-role-docker/lib/python3.11/site-packages/molecule/logger.py", line 189, in wrapper
    rt = func(*args, **kwargs)
         ^^^^^^^^^^^^^^^^^^^^^
  File "/home/mcdonnnj/.pyenv/versions/3.11.3/envs/ansible-role-docker/lib/python3.11/site-packages/molecule/command/dependency.py", line 40, in execute
    self._config.dependency.execute()
  File "/home/mcdonnnj/.pyenv/versions/3.11.3/envs/ansible-role-docker/lib/python3.11/site-packages/molecule/dependency/ansible_galaxy/__init__.py", line 75, in execute
    invoker.execute()
  File "/home/mcdonnnj/.pyenv/versions/3.11.3/envs/ansible-role-docker/lib/python3.11/site-packages/molecule/dependency/ansible_galaxy/base.py", line 129, in execute
    self.execute_with_retries()
  File "/home/mcdonnnj/.pyenv/versions/3.11.3/envs/ansible-role-docker/lib/python3.11/site-packages/molecule/dependency/base.py", line 55, in execute_with_retries
    util.run_command(self._sh_command, debug=self._config.debug, check=True)
  File "/home/mcdonnnj/.pyenv/versions/3.11.3/envs/ansible-role-docker/lib/python3.11/site-packages/molecule/util.py", line 149, in run_command
    result = app.runtime.exec(
             ^^^^^^^^^^^^^^^^
AttributeError: 'Runtime' object has no attribute 'exec'

This is likely caused by https://github.com/ansible-community/molecule/blob/0d874bd9ccacda8df5e110020454764a6b9b908d/src/molecule/util.py#L149 not being updated for ansible/ansible-compat#256 which was included in ansible-compat v4.0.1.

@mcdonnnj mcdonnnj added the bug label May 1, 2023
asmacdo added a commit to asmacdo/molecule that referenced this issue May 1, 2023
relrod added a commit to relrod/awx-operator that referenced this issue May 2, 2023
evgeni added a commit to theforeman/foreman-operations-collection that referenced this issue May 2, 2023
evgeni added a commit to evgeni/foreman-operations-collection that referenced this issue May 2, 2023
evgeni added a commit to evgeni/foreman-operations-collection that referenced this issue May 2, 2023
@danielpodwysocki
Copy link

+1 , just ran into it.

@danielpodwysocki
Copy link

Btw. do the dependencies work as expected for us here?

https://github.com/ansible-community/molecule/tree/main/.config

Looks like we should be locked to 3.0.2 ?

@zenzedoon
Copy link

i have the same issue : i have molecule v 5.0.0 with poython v 3.10 , absible core 2.14.5 , when i try to create new ansible role i got this error:
molecule init role acme.testrole
INFO     Initializing new role testrole...
Traceback (most recent call last):
  File "/home/zenzedoon/.local/bin/molecule", line 8, in
    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 1053, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 1659, 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 754, 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/zenzedoon/.local/lib/python3.10/site-packages/molecule/command/init/role.py", line 174, in role
    r.execute()
  File "/home/zenzedoon/.local/lib/python3.10/site-packages/molecule/command/init/role.py", line 84, in execute
    result = util.run_command(cmd)
  File "/home/zenzedoon/.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'

MrFreezeex added a commit to MrFreezeex/kubespray that referenced this issue May 2, 2023
Molecule doesn't support latest version of ansible-compat so we need to
pin it (ref: ansible/molecule#3903).

Signed-off-by: Arthur Outhenin-Chalandre <[email protected]>
relrod added a commit to ansible/awx-operator that referenced this issue May 2, 2023
MrFreezeex added a commit to MrFreezeex/kubespray that referenced this issue May 2, 2023
Molecule doesn't support latest version of ansible-compat so we need to
pin it (ref: ansible/molecule#3903).

Signed-off-by: Arthur Outhenin-Chalandre <[email protected]>
rjeffman added a commit to rjeffman/ansible-freeipa that referenced this issue May 2, 2023
Due to an issue introduced on newer ansible-compat and molecule
(see ansible/molecule#3903),
ansible-compat needs to be pinned to an older version.
rjeffman added a commit to rjeffman/ansible-freeipa that referenced this issue May 2, 2023
Due to an issue introduced on newer ansible-compat and molecule
(see ansible/molecule#3903),
ansible-compat needs to be pinned to an older version.
jsf9k added a commit to cisagov/skeleton-ansible-role that referenced this issue May 2, 2023
This is necessary because version 4 of this package contains a
breaking change that causes Molecule to fail right out of the box.
See ansible/molecule/issues/3903 for more details.
cjeanner added a commit to openstack-k8s-operators/ci-framework that referenced this issue May 2, 2023
As described in
ansible/molecule#3903 the latest
updates in ansible-compat are breaking molecule.

While waiting for the proper fix, let's just pin things up.
@isuftin
Copy link

isuftin commented May 2, 2023

Reverting from ansible-compat 4.0.1 to 3.0.2 fixed the issue for me.

ehelms pushed a commit to theforeman/foreman-operations-collection that referenced this issue May 2, 2023
relrod added a commit to ansible/awx-operator that referenced this issue May 23, 2023
aroberts87 added a commit to sysdiglabs/agent-ansible-collection that referenced this issue May 24, 2023
Upstream bug caused Molecule to not be able to run in our CI flows.
ansible/molecule#3903
aroberts87 added a commit to sysdiglabs/agent-ansible-collection that referenced this issue May 25, 2023
Upstream bug caused Molecule to not be able to run in our CI flows.
ansible/molecule#3903
aroberts87 added a commit to sysdiglabs/agent-ansible-collection that referenced this issue May 25, 2023
Upstream bug caused Molecule to not be able to run in our CI flows.
ansible/molecule#3903
aroberts87 added a commit to sysdiglabs/agent-ansible-collection that referenced this issue May 25, 2023
Upstream bug caused Molecule to not be able to run in our CI flows.
ansible/molecule#3903
bodsch added a commit to bodsch/ansible-container that referenced this issue Jun 1, 2023
samdbmg added a commit to samdbmg/ansible-schedule-duplicity that referenced this issue Jun 3, 2023
Explicitly installs a molecule version with fix for
ansible/molecule#3903 to run tests.
samdbmg added a commit to samdbmg/ansible-traefik-auth-proxy that referenced this issue Jun 3, 2023
Install a version of molecule with a fix for ansible/molecule#3903
@lkiesow
Copy link

lkiesow commented Jun 6, 2023

The problem popped up again and many people will likely get hit by this due to the latest version of ansible-lint requiring a new version of ansible-compat. Installing molecule and ansible-lint both is very common and right now, ansible-lint's dependencies will win and pip will automatically install molecule==5.0.0:

❯ pip install ansible-lint molecule
❯ pip freeze                       
…
molecule==5.0.0
…
❯ pip install -U molecule
…
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
ansible-lint 6.17.0 requires ansible-compat>=4.0.5, but you have ansible-compat 3.0.2 which is incompatible.

This means that even with Molecule 5.0.1 released, many people will run into this issue, and you need manual intervention to fix this.

lkiesow added a commit to elan-ev/simple_nginx_reverse_proxy that referenced this issue Jun 6, 2023
Molecule and ansible-lint require ansible-compat in different versions
and installing both currently breaks molecule (again).

This patchremoves ansible-lint from the Molecule workflow since we don't
need it in there anyway. We have a separate workflow for that.

More details:
ansible/molecule#3903 (comment)
lkiesow added a commit to elan-ev/simple_nginx_reverse_proxy that referenced this issue Jun 6, 2023
Molecule and ansible-lint require ansible-compat in different versions
and installing both currently breaks molecule (again).

This patchremoves ansible-lint from the Molecule workflow since we don't
need it in there anyway. We have a separate workflow for that.

More details:
ansible/molecule#3903 (comment)
AaronJackson added a commit to hic-infra/shared-services-ansible-roles that referenced this issue Jun 6, 2023
@ziegenberg
Copy link
Contributor

#3904 will fix it finally for good.

zhan9san pushed a commit that referenced this issue Jun 7, 2023
* Use run, not exec, for ansible-compat 4.0.2

4.0.2 dropped the use of `exec`, needs to be replaced with `run`

Fixes #3903

ansible/ansible-compat#256

* bump ansible-compat 4.1.2

ansible-compat 4.0.1 included a breaking change. If we want to use
latest, minimum version must be at least 4.0.1.

ansible-compat < 4.1.2 has an issue that causes an unhandled exception
for certain log levels. ansible/ansible-lint#3522
Since this issue caused CI trouble, we go ahead and bump to 4.1.2.

* fixup

* [DATALAD RUNCMD] recompile requirements.lock.txt

=== Do not change lines below ===
{
 "chain": [],
 "cmd": "pip-compile --no-annotate --output-file=.config/requirements-lock.txt --resolver=backtracking --strip-extras --unsafe-package=ruamel-yaml-clib pyproject.toml",
 "exit": 0,
 "extra_inputs": [],
 "inputs": [],
 "outputs": [],
 "pwd": "."
}
^^^ Do not change lines above ^^^

* fix tests for command init role and init scenario

Currently the tests fail for `test_command_init_role` and
`test_command_init_scneario`. The tests execute `ansible-lint` on the
newly-created roles and the linter recently got more restrictive, so we
now have to adapt.

* [DATALAD RUNCMD] recompile requirements.txt

=== Do not change lines below ===
{
 "chain": [],
 "cmd": "pip-compile --extra=docs --extra=test --no-annotate --output-file=.config/requirements.txt --resolver=backtracking --strip-extras pyproject.toml",
 "exit": 0,
 "extra_inputs": [],
 "inputs": [],
 "outputs": [],
 "pwd": "."
}
^^^ Do not change lines above ^^^

* Fake 3.9 for autogenerated files

I used 3.10, but CI will run this on 3.9, and fail if there is a diff.
This means it is safe to change this by hand, since it will be checked.

---------

Co-authored-by: Daniel Ziegenberg <[email protected]>
@coaxial
Copy link

coaxial commented Jun 8, 2023

Is there any fix in the meantime?

@lkiesow
Copy link

lkiesow commented Jun 8, 2023

You can just install Molecule 5.0.1 specifically. Pip will then resole the modules and install an older version of ansible-lint:

❯ pip install ansible-lint molecule==5.0.1

kayiwa added a commit to pulibrary/princeton_ansible that referenced this issue Jun 17, 2023
ansible/molecule#3903

- this removes the ability to use

`molecule lint` command
kayiwa added a commit to pulibrary/princeton_ansible that referenced this issue Jun 17, 2023
molecule is failing with this error

ansible/molecule#3903

the ability to run `molecule lint` is no longer possible
maxkadel pushed a commit to pulibrary/princeton_ansible that referenced this issue Jun 19, 2023
* remove the failing AGENT tools directory.

the variable is not used

* updating to new molecule version

molecule is failing with this error

ansible/molecule#3903

the ability to run `molecule lint` is no longer possible
ryarnyah added a commit to StephenSorriaux/ansible-kafka-admin that referenced this issue Oct 2, 2023
* Use set when have many acls to speedup checks

* Downgrade ansible-compat test lib see ansible/molecule#3903
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.