Skip to content

Commit

Permalink
Allow config file to have .yaml extension (#3559)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Ajinkya Udgirkar <ajinkyaudgirkar@gmail.com>
Co-authored-by: Sorin Sbarnea <ssbarnea@redhat.com>
  • Loading branch information
4 people authored Jun 14, 2023
1 parent 99cadc6 commit 9fc3a61
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
5 changes: 3 additions & 2 deletions docs/configuring.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ example `exclude_paths`) and **True** is preferred for boolean values like

## Using local configuration files

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

!!! note

Expand Down
8 changes: 6 additions & 2 deletions src/ansiblelint/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ def get_config_path(config_file: str | None = None) -> str | None:
if config_file:
project_filenames = [config_file]
else:
project_filenames = [".ansible-lint", ".config/ansible-lint.yml"]
project_filenames = [
".ansible-lint",
".config/ansible-lint.yml",
".config/ansible-lint.yaml",
]
parent = tail = os.getcwd()
while tail:
for project_filename in project_filenames:
Expand Down Expand Up @@ -433,7 +437,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' or '.config/ansible-lint.yml'",
help="Specify configuration file to use. By default it will look for '.ansible-lint', '.config/ansible-lint.yml', or '.config/ansible-lint.yaml'",
)
parser.add_argument(
"-i",
Expand Down
6 changes: 5 additions & 1 deletion src/ansiblelint/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,11 @@ def main():
# https://github.com/ansible/ansible-lint-action/issues/138
GIT_CMD = ["git", "-c", f"safe.directory={Path.cwd()}"]

CONFIG_FILENAMES = [".ansible-lint", ".config/ansible-lint.yml"]
CONFIG_FILENAMES = [
".ansible-lint",
".config/ansible-lint.yml",
".config/ansible-lint.yaml",
]


class States(Enum):
Expand Down
6 changes: 5 additions & 1 deletion src/ansiblelint/schemas/ansible-lint-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
"$id": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/ansible-lint-config.json",
"$schema": "http://json-schema.org/draft-07/schema",
"additionalProperties": false,
"examples": [".ansible-lint", ".config/ansible-lint.yml"],
"examples": [
".ansible-lint",
".config/ansible-lint.yml",
".config/ansible-lint.yaml"
],
"properties": {
"display_relative_path": {
"default": true,
Expand Down

0 comments on commit 9fc3a61

Please sign in to comment.