Skip to content

Commit

Permalink
search for config with the yml/yaml extension (#4416)
Browse files Browse the repository at this point in the history
  • Loading branch information
cornfeedhobo authored Dec 4, 2024
1 parent a5fbd7c commit 375c2e3
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
7 changes: 4 additions & 3 deletions docs/configuring.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ the one specified inside the configuration file.

## Using local configuration files

Specify Ansible-lint configuration in either `.ansible-lint`,
`.config/ansible-lint.yml`, or `.config/ansible-lint.yaml` in your current
working directory.
Specify Ansible-lint configuration in either
`.ansible-lint`, `.ansible-lint.yml`, `.ansible-lint.yaml`,
`.config/ansible-lint.yml`, or `.config/ansible-lint.yaml`
in your current working directory.

!!! note

Expand Down
4 changes: 3 additions & 1 deletion src/ansiblelint/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ def get_config_path(config_file: str | None = None) -> str | None:
else:
project_filenames = [
".ansible-lint",
".ansible-lint.yml",
".ansible-lint.yaml",
".config/ansible-lint.yml",
".config/ansible-lint.yaml",
]
Expand Down Expand Up @@ -445,7 +447,7 @@ def get_cli_parser() -> argparse.ArgumentParser:
"-c",
"--config-file",
dest="config_file",
help="Specify configuration file to use. By default it will look for '.ansible-lint', '.config/ansible-lint.yml', or '.config/ansible-lint.yaml'",
help="Specify configuration file to use. By default it will look for '.ansible-lint', '.ansible-lint.yml', '.ansible-lint.yaml', '.config/ansible-lint.yml', or '.config/ansible-lint.yaml'",
)
parser.add_argument(
"-i",
Expand Down
3 changes: 2 additions & 1 deletion src/ansiblelint/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
{"text": "**/templates/**/*.*"}, # templates are likely not validable
{"execution-environment": "**/execution-environment.yml"},
{"ansible-lint-config": "**/.ansible-lint"},
{"ansible-lint-config": "**/.config/ansible-lint.yml"},
{"ansible-lint-config": "**/.ansible-lint.{yaml,yml}"},
{"ansible-lint-config": "**/.config/ansible-lint.{yaml,yml}"},
{"ansible-navigator-config": "**/ansible-navigator.{yaml,yml}"},
{"inventory": "**/inventory/**.{yaml,yml}"},
{"requirements": "**/meta/requirements.{yaml,yml}"}, # v1 only
Expand Down
2 changes: 2 additions & 0 deletions src/ansiblelint/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ def main():

CONFIG_FILENAMES = [
".ansible-lint",
".ansible-lint.yml",
".ansible-lint.yaml",
".config/ansible-lint.yml",
".config/ansible-lint.yaml",
]
Expand Down
2 changes: 2 additions & 0 deletions src/ansiblelint/schemas/ansible-lint-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
"description": "https://ansible.readthedocs.io/projects/lint/configuring/",
"examples": [
".ansible-lint",
".ansible-lint.yml",
".ansible-lint.yaml",
".config/ansible-lint.yml",
".config/ansible-lint.yaml"
],
Expand Down

0 comments on commit 375c2e3

Please sign in to comment.