diff --git a/README.md b/README.md index 83cc184..c44303c 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,13 @@ This is a fork of Will Thames [ansible-review](https://github.com/willthames/ansible-review) so credits goes to him for his work on ansible-review and ansible-lint. -ansible-later is an acronym for **L**ovely **A**utomation **TE**sting f**R**mework. +`ansible-later` is a best pratice scanner and linting tool. In most cases, if you write ansibel roles in a team, +it helps to have a coding or best practice guideline in place. This will make ansible roles more readeble for all +maintainers and can reduce the troubleshooting time. + +`ansible-later` does _**not**_ ensure that your role will work as expected. + +`ansible-later` is an acronym for **L**ovely **A**utomation **TE**sting f**R**mework. ## Table of Content @@ -147,6 +153,7 @@ comes with a couple of built-in checks explained in the following table. | check_command_has_changes | ANSIBLE0011 | Commands should be idempotent and only used with some checks. | | | check_empty_string_compare | ANSIBLE0012 | Don't compare to "" - use `when: var` or `when: not var` | | | check_compare_to_literal_bool | ANSIBLE0013 | Don't compare to True/False - use `when: var` or `when: not var` | | +| check_literal_bool_format | ANSIBLE0014 | Literal bools should be written as `True/False` or `yes/no` | forbidden values are `true|false|TRUE|FALSE|Yes|No|YES|NO` | ### Build your own diff --git a/ansiblelater/examples/standards.py b/ansiblelater/examples/standards.py index bfca01e..a4023d0 100644 --- a/ansiblelater/examples/standards.py +++ b/ansiblelater/examples/standards.py @@ -21,7 +21,7 @@ from ansiblelater.rules.ansiblefiles import check_shell_instead_command from ansiblelater.rules.ansiblefiles import check_command_has_changes from ansiblelater.rules.ansiblefiles import check_empty_string_compare from ansiblelater.rules.ansiblefiles import check_compare_to_literal_bool -from ansiblelater.rules.ansiblefiles import check_uppercase_literal_bool +from ansiblelater.rules.ansiblefiles import check_literal_bool_format tasks_should_be_separated = Standard(dict( @@ -127,6 +127,14 @@ dont_compare_to_literal_bool = Standard(dict( types=["playbook", "task", "handler", "template"] )) +literal_bool_should_be_formatted = Standard(dict( + id="ANSIBLE0014", + name="Literal bools should start with a capital letter", + check=check_literal_bool_format, + version="0.1", + types=["playbook", "task", "handler"] +)) + files_should_not_contain_unnecessarily_empty_lines = Standard(dict( id="LINT0001", name="YAML should not contain unnecessarily empty lines", @@ -196,14 +204,6 @@ use_yaml_rather_than_key_value = Standard(dict( types=["playbook", "task", "handler"] )) -literal_bool_should_start_with_uppercase = Standard(dict( - id="LINT0008", - name="Literal bools should start with a capital letter", - check=check_uppercase_literal_bool, - version="0.1", - types=["playbook", "task", "handler"] -)) - ansible_min_version = '2.1' ansible_review_min_version = '0.1.0' @@ -224,7 +224,7 @@ standards = [ commands_should_be_idempotent, dont_compare_to_empty_string, dont_compare_to_literal_bool, - literal_bool_should_start_with_uppercase, + literal_bool_should_be_formatted, # Lint files_should_not_contain_unnecessarily_empty_lines, files_should_be_indented, diff --git a/ansiblelater/rules/ansiblefiles.py b/ansiblelater/rules/ansiblefiles.py index dd6f6f9..05eae54 100644 --- a/ansiblelater/rules/ansiblefiles.py +++ b/ansiblelater/rules/ansiblefiles.py @@ -205,7 +205,7 @@ def check_delegate_to_localhost(candidate, settings): return Result(candidate.path, errors) -def check_uppercase_literal_bool(candidate, settings): +def check_literal_bool_format(candidate, settings): yamllines, errors = get_normalized_yaml(candidate, settings) description = "literal bools should be written as 'True/False' or 'yes/no'"