Skip to content

Commit

Permalink
Improve documentation on var-naming (#3042)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea committed Feb 15, 2023
1 parent c7a1eed commit 467426a
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/ansiblelint/rules/var_naming.md
Expand Up @@ -2,10 +2,21 @@

This rule checks variable names to ensure they conform with requirements.

Variable names must contain only lowercase alphanumeric characters and the underscore `_` character.
Variable names must also start with either an alphabetic or underscore `_` character.
Variable names must contain only lowercase alphanumeric characters and the
underscore `_` character. Variable names must also start with either an
alphabetic or underscore `_` character.

For more information see the [creating valid variable names](https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_variables.html#creating-valid-variable-names) topic in Ansible documentation.
For more information see the [creating valid variable names][var-names] topic in
Ansible documentation and [Naming things (Good Practices for Ansible)][cop].

## Settings

This rule behavior can be changed by altering the below settings:

```yaml
# .ansible-lint
var_naming_pattern: "^[a-z_][a-z0-9_]*$"
```

## Problematic Code

Expand All @@ -30,3 +41,7 @@ For more information see the [creating valid variable names](https://docs.ansibl
no_caps: bar # <- Does not contains uppercase characters.
variable: baz # <- Does not contain special characters.
```

[cop]: https://redhat-cop.github.io/automation-good-practices/#_naming_things
[var-names]:
https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_variables.html#creating-valid-variable-names

0 comments on commit 467426a

Please sign in to comment.