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

AttributeError: 'Runtime' object has no attribute 'plugins' #3567

Closed
gpatsiaouras opened this issue Jun 15, 2023 · 1 comment
Closed

AttributeError: 'Runtime' object has no attribute 'plugins' #3567

gpatsiaouras opened this issue Jun 15, 2023 · 1 comment
Assignees
Labels

Comments

@gpatsiaouras
Copy link

Summary

Hello, we've been using ansible-lint for quite some time now, but suddenly we started receiving an error that seems to be irrelevant to our code. We are using ansible-lint inside an alpine docker image and this is where the problem appears. In an ubuntu 22.04 installation it works as it should. So we suspect that, the problem is alpine os related. I already tried to install ansible-lint from sources inside alpine to get the latest version, but it proved to be impossible due to missing dependencies and various errors.

Issue Type
  • Bug Report
OS / ENVIRONMENT

We use ansible-lint in Gitlab CI a docker image we are creating based on python:alpine3.18. In this image ansible-lint is installed using the command

apk add ansible-lint
Ansible lint version
ansible-lint --version


ansible-lint 6.17.0 using ansible-core:2.14.5 ruamel-yaml:0.17.31 ruamel-yaml-clib:0.2.7
  • ansible installation method: alpine apk
  • ansible-lint installation method: alpine apk
STEPS TO REPRODUCE

Create a Dockerfile file and add the following

FROM python:alpine3.18

RUN apk add ansible-lint

Start a container:

docker build -t testing-ansible-lint:latest .
docker run --rm -it testing-ansible-lint:latest sh

Then in any directory execute:

ansible-lint
Desired Behavior

The error should not be thrown since it seems to not be relevant to our ansible code, but internal to ansible-lint itself.

Actual Behavior

Receiving the following error:

[DEPRECATION WARNING]: [defaults]callback_whitelist option, normalizing names 
to new standard, use callbacks_enabled instead. This feature will be removed 
from ansible-core in version 2.15. Deprecation warnings can be disabled by 
setting deprecation_warnings=False in ansible.cfg.
WARNING  Retrying execution failure 5 of: ansible-galaxy collection list --format=json
Traceback (most recent call last):
  File "/usr/bin/ansible-lint", line 8, in <module>
    sys.exit(_run_cli_entrypoint())
             ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/ansiblelint/__main__.py", line 310, in _run_cli_entrypoint
    sys.exit(main(sys.argv))
             ^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/ansiblelint/__main__.py", line 247, in main
    rules = RulesCollection(options.rulesdirs, profile_name=options.profile)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/ansiblelint/rules/__init__.py", line 398, in __init__
    for rule in load_plugins(rulesdirs_str):
  File "/usr/lib/python3.11/site-packages/ansiblelint/rules/__init__.py", line 346, in load_plugins
    import_module(f"{f.stem}")
  File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/usr/lib/python3.11/site-packages/ansiblelint/rules/schema.py", line 53, in <module>
    "become_method": get_app().runtime.plugins.become.keys(),  # pylint: disable=no-member
                     ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Runtime' object has no attribute 'plugins'
@gpatsiaouras gpatsiaouras added bug new Triage required labels Jun 15, 2023
@ssbarnea ssbarnea self-assigned this Jun 15, 2023
@ssbarnea
Copy link
Member

I am almost sure this is caused by bad downstream packaging, mainly version of ansible-compat is not the correct one (4.1.2).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants