diff --git a/src/ansiblelint/config.py b/src/ansiblelint/config.py index acfdbb6511..304d73cfd2 100644 --- a/src/ansiblelint/config.py +++ b/src/ansiblelint/config.py @@ -13,9 +13,8 @@ DEFAULT_KINDS = [ # Do not sort this list, order matters. - {"requirements": "requirements.yml"}, # v2 and v1 {"requirements": "**/meta/requirements.yml"}, # v1 only - {"reno": "releasenotes/*/*.{yaml,yml}"}, # reno release notes + {"reno": "**/releasenotes/*/*.{yaml,yml}"}, # reno release notes {"playbook": "**/playbooks/*.{yml,yaml}"}, {"playbook": "**/*playbook*.{yml,yaml}"}, {"role": "**/roles/*/"}, @@ -28,6 +27,7 @@ "requirements": "**/molecule/*/{collections,requirements}.{yaml,yml}" }, # molecule old collection requirements (v1), ansible 2.8 only {"yaml": "**/molecule/*/{base,molecule}.{yaml,yml}"}, # molecule config + {"requirements": "**/requirements.yml"}, # v2 and v1 {"playbook": "**/molecule/*/*.{yaml,yml}"}, # molecule playbooks {"yaml": "**/*.{yaml,yml}"}, {"yaml": "**/.*.{yaml,yml}"}, diff --git a/src/ansiblelint/file_utils.py b/src/ansiblelint/file_utils.py index 8edde0d193..8026e09249 100644 --- a/src/ansiblelint/file_utils.py +++ b/src/ansiblelint/file_utils.py @@ -71,7 +71,7 @@ def kind_from_path(path: Path) -> str: """Determine the file kind based on its name.""" # pathlib.Path.match patterns are very limited, they do not support *a*.yml # glob.glob supports **/foo.yml but not multiple extensions - pathex = wcmatch.pathlib.PurePath(path) + pathex = wcmatch.pathlib.PurePath(path.absolute().resolve()) for entry in options.kinds: for k, v in entry.items(): if pathex.globmatch( diff --git a/test/TestUtils.py b/test/TestUtils.py index 620c54383d..5eaed2f3a0 100644 --- a/test/TestUtils.py +++ b/test/TestUtils.py @@ -360,6 +360,10 @@ def test_is_playbook(): ("examples/playbooks/vars/other.yml", "vars"), ("examples/playbooks/vars/subfolder/settings.yml", "vars"), # deep vars ("molecule/scenario/collections.yml", "requirements"), # deprecated 2.8 format + ( + "../roles/geerlingguy.mysql/tasks/configure.yml", + "tasks", + ), # relative path involved ), ) def test_default_kinds(monkeypatch, path: str, kind: FileType) -> None: