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

fixed ImportError: cannot import name 'AnsibleLintRule' from 'ansiblelint' #26

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

dzianis-fisiuk
Copy link

fixed ImportError: cannot import name 'AnsibleLintRule' from 'ansiblelint' (/opt/toolset/lib/python3.8/site-packages/ansiblelint/init.py)

How to reproduce the issue:
Python version 3.8

  1. $ git clone https://github.com/lean-delivery/ansible-lint-rules.git ~/ansible-lint-rules
  2. $ git clone https://github.com/dzianis-fisiuk/ansible-role-myrole1.git ~/ansible-role-myrole1
  3. $ cd ~/ansible-role-myrole1
  4. check .ansible-lint file content:

exclude_paths:

  • ./.travis.yml
  • ./molecule/
    rulesdir:
  • ~/ansible-lint-rules/rules/
    use_default_rules: true
    verbosity: 1
  1. Run ansible-lint command:
    $ ansible-lint . -c .ansible-lint

Error output:
INFO Running ansible-galaxy role install --roles-path /root/.cache/ansible-lint/af766b/roles -vr requirements.yml
WARNING Computed fully qualified role name of myrole1 does not follow current galaxy requirements.
Please edit meta/main.yml and assure we can correctly determine full role name:

galaxy_info:
role_name: my_name # if absent directory name hosting role is used instead
namespace: my_galaxy_namespace # if absent, author is used instead

Namespace: https://galaxy.ansible.com/docs/contributing/namespaces.html#galaxy-namespace-limitations
Role: https://galaxy.ansible.com/docs/contributing/creating_role.html#role-names

As an alternative, you can add 'role-name' to either skip_list or warn_list.

INFO Using /root/.cache/ansible-lint/af766b/roles/myrole1 symlink to current repository in order to enable Ansible to find the role using its expected full name.
INFO Added ANSIBLE_ROLES_PATH=~/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/root/.cache/ansible-lint/af766b/roles:/root/.cache/ansible-lint/af766b/roles
Traceback (most recent call last):
File "/opt/toolset/bin/ansible-lint", line 8, in
sys.exit(_run_cli_entrypoint())
File "/opt/toolset/lib/python3.8/site-packages/ansiblelint/main.py", line 299, in _run_cli_entrypoint
sys.exit(main(sys.argv))
File "/opt/toolset/lib/python3.8/site-packages/ansiblelint/main.py", line 214, in main
rules = RulesCollection(options.rulesdirs)
File "/opt/toolset/lib/python3.8/site-packages/ansiblelint/rules/init.py", line 220, in init
for rule in load_plugins(rulesdir):
File "/opt/toolset/lib/python3.8/site-packages/ansiblelint/rules/init.py", line 193, in load_plugins
spec.loader.exec_module(module)
File "", line 848, in exec_module
File "", line 219, in _call_with_frames_removed
File "/root/ansible-lint-rules/rules/UseTrueFalseInsteadYesNo.py", line 1, in
from ansiblelint import AnsibleLintRule
ImportError: cannot import name 'AnsibleLintRule' from 'ansiblelint' (/opt/toolset/lib/python3.8/site-packages/ansiblelint/init.py)

…lint' (/opt/toolset/lib/python3.8/site-packages/ansiblelint/__init__.py)
@pavelpikta
Copy link
Member

Hi, @dzianis-fisiuk are these changes relevant for issue #25?

@dzianis-fisiuk
Copy link
Author

dzianis-fisiuk commented Aug 2, 2021

Hi, @dzianis-fisiuk are these changes relevant for issue #25?
Not sure,
The current version of ansible-lint:

ansible-lint --version

ansible-lint 5.0.12 using ansible 2.11.1

I didn't check the issue on previous ansible-lint versions

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

Successfully merging this pull request may close these issues.

2 participants