ansible-lint
ansible-lint copied to clipboard
Error "couldn't resolve module/action <module name>" when using playbook local module
Summary
It seems that https://github.com/ansible/ansible-lint/issues/372 is closed but this is basically that issue: After reading the documentation for ansible on local modules it clearly states...
Ansible automatically loads all executable files from certain directories adjacent to your playbook or role as modules. Standalone modules in these locations are available only to the specific playbook, playbooks, or role in the parent directory. To use a standalone module only in a selected playbook or playbooks, store the module in a subdirectory called library in the directory that contains the playbook or playbooks.
This documented behaviour does not seem to work with ansible-lint as it doesn't find the module (which ansible-playbook
has no issues finding).
Issue Type
- Bug Report
OS / ENVIRONMENT
ansible-lint 24.2.0 using ansible-core:2.16.3 ansible-compat:4.1.11 ruamel-yaml:0.18.5 ruamel-yaml-clib:0.2.8
- ansible installation method: pip
- ansible-lint installation method: pip
STEPS TO REPRODUCE
See https://github.com/ansible/ansible-lint/issues/372#issuecomment-691366654
Desired Behavior
ansible-lint finds the local module just as ansible-playbook does
Possible security bugs should be reported via email to [email protected]
Actual Behavior
ansible-lint fails to find the local module as it does not search in local folders, contrary to ansible-playbook
See https://github.com/ansible/ansible-lint/issues/372#issuecomment-691366654 for this as well
$ ansible-lint -vvvv
DEBUG Logging initialized to level 10
DEBUG Options: Namespace(colored=True, config_file=None, display_relative_path=True, exclude_paths=[], format='rich', listrules=False, listtags=False, parseable=False, parseable_severity=False, playbook=[], quiet=False, rulesdir=[], skip_list=[], tags=[], use_default_rules=False, verbosity=4, warn_list=[])
DEBUG Loading rules from /Users/xxx/yyy/.venv/lib/python3.7/site-packages/ansiblelint/rules
INFO Discovering files to lint: git ls-files *.yaml *.yml
INFO Unknown file type: roles/foo/tasks/main.yml
INFO Found roles: roles/foo
INFO Found playbooks: playbook.yml
DEBUG Examining roles/foo/tasks/main.yml of type tasks
CRITICAL Couldn't parse task at /Users/xxx/yyy/roles/foo/tasks/main.yml:1 (no action detected in task. This often indicates a misspelled module name, or incorrect module path.)
{ 'baz': { '__file__': '/Users/xxx/yyy/roles/foo/tasks/main.yml',
'__line__': 3,
'url': 'foo'},
'name': 'bar'}