Skip to content

Commit

Permalink
Avoid false positive import_playbook errors
Browse files Browse the repository at this point in the history
Fixes: #4024
  • Loading branch information
ssbarnea committed May 7, 2024
1 parent 2f3cb30 commit d82cebc
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions examples/.test_collection/.ansible-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
6 changes: 6 additions & 0 deletions examples/.test_collection/playbooks/bar.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- name: Sample playbook
hosts: localhost
tasks:
- name: Sample task
ansible.builtin.debug:
msg: "Hello world!"
2 changes: 2 additions & 0 deletions examples/.test_collection/playbooks/foo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- name: Fixture for bug 4024
import_playbook: examples.test_collection.bar.yml
5 changes: 4 additions & 1 deletion src/ansiblelint/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,10 @@ def find_children(self, lintable: Lintable) -> list[Lintable]:
child.path = Path(path)
child.name = child.path.name

results.append(child)
# If filename looks like a FQCN, we do not add it because we
# cannot load it directly. namespace.collection_name.filename.yml
if child.filename.count(".") != 3 or child.path.exists():
results.append(child)
return results

def play_children(
Expand Down

0 comments on commit d82cebc

Please sign in to comment.