diff --git a/.flake8 b/.flake8 index ab46d02d42a..3f088377370 100644 --- a/.flake8 +++ b/.flake8 @@ -94,6 +94,7 @@ per-file-ignores = test/TestMetaTagValid.py: PT009 D100 D101 D102 test/TestMetaVideoLinks.py: PT009 D100 D101 D102 test/TestNoFormattingInWhenRule.py: PT009 D100 D101 D102 + test/TestNoLogPasswordsRule.py: PT009 D100 D101 D102 test/TestOctalPermissions.py: PT009 D100 D101 D102 test/TestPackageIsNotLatest.py: PT009 D100 D101 D102 test/TestPretaskIncludePlaybook.py: D100 D103 diff --git a/examples/playbooks/no-log-passwords-failure.yml b/examples/playbooks/no-log-passwords-failure.yml index 4e4b822497d..9cd3c3c38ac 100644 --- a/examples/playbooks/no-log-passwords-failure.yml +++ b/examples/playbooks/no-log-passwords-failure.yml @@ -1,4 +1,5 @@ -- tasks: +- hosts: localhost + tasks: - name: Fail no_log isn't used user: name: bidule diff --git a/examples/playbooks/no-log-passwords-success.yml b/examples/playbooks/no-log-passwords-success.yml index c0dcdd24911..78ee0b63520 100644 --- a/examples/playbooks/no-log-passwords-success.yml +++ b/examples/playbooks/no-log-passwords-success.yml @@ -1,4 +1,5 @@ -- tasks: +- hosts: localhost + tasks: - name: Succeed when no_log is set to yes user: name: bidule diff --git a/src/ansiblelint/rules/NoLogPasswordsRule.py b/src/ansiblelint/rules/NoLogPasswordsRule.py index 49d2c515db0..66c0935d29c 100644 --- a/src/ansiblelint/rules/NoLogPasswordsRule.py +++ b/src/ansiblelint/rules/NoLogPasswordsRule.py @@ -48,4 +48,6 @@ def matchtask( # No no_log and no_log: False behave the same way # and should return a failure (return True), so we # need to invert the boolean - return bool(has_password and not convert_to_boolean(task['action'].get('no_log', False))) + return bool( + has_password and not convert_to_boolean(task['action'].get('no_log', False)) + ) diff --git a/test/TestNoLogPasswordsRule.py b/test/TestNoLogPasswordsRule.py index 9d45336702c..b2d8ec781c9 100644 --- a/test/TestNoLogPasswordsRule.py +++ b/test/TestNoLogPasswordsRule.py @@ -1,8 +1,9 @@ +# pylint: disable=preferred-module # FIXME: remove once migrated per GH-725 import unittest from ansiblelint.rules import RulesCollection -from ansiblelint.runner import Runner from ansiblelint.rules.NoLogPasswordsRule import NoLogPasswordsRule +from ansiblelint.runner import Runner class TestNoLogPasswordsRule(unittest.TestCase): diff --git a/test/TestRulesCollection.py b/test/TestRulesCollection.py index e4142e48ed8..e73732f4533 100644 --- a/test/TestRulesCollection.py +++ b/test/TestRulesCollection.py @@ -128,4 +128,4 @@ def test_rules_id_format() -> None: assert rule_id_re.match( rule.id ), f"R rule id {rule.id} did not match our required format." - assert len(rules) == 39 + assert len(rules) == 40