Skip to content

Commit

Permalink
Avoid reporting loading errors with vaulted files (#1443)
Browse files Browse the repository at this point in the history
Fixes: #1442
  • Loading branch information
ssbarnea committed Mar 7, 2021
1 parent fcd7291 commit dd4bf59
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions examples/playbooks/vars/not_decryptable.yml
@@ -0,0 +1,10 @@
$ANSIBLE_VAULT;1.1;AES256
35366433323361393130396530643233373262666636646439303032366431303363316232313738
3738636130636431623936303932306430316635663136610a353737333966353462333532393631
36613030643762636138613734313862333165346464626461313361353732336131633137653865
3862386136386137650a303433643531613337393735633338383163353737656339653134346363
63613436333937313738633437373566333065663662643664643261313366323236356364316663
62336264666464323066336365616634626336616537646336656266343562336533343732613539
61643661303566313664313164623731316236666235656337363632393665353536303730666532
64666639306361653963363462393966623763626566613831613739333666333665343734333630
63623730623033346163393834396639383234393637653733396466316132663131
2 changes: 2 additions & 0 deletions src/ansiblelint/rules/__init__.py
Expand Up @@ -143,6 +143,8 @@ def matchyaml(self, file: Lintable) -> List[MatchError]:
# file contains a single string. YAML spec allows this but we consider
# this an fatal error.
if isinstance(yaml, str):
if yaml.startswith('$ANSIBLE_VAULT'):
return []
return [MatchError(filename=str(file.path), rule=LoadingFailureRule())]
if not yaml:
return matches
Expand Down
8 changes: 8 additions & 0 deletions test/TestExamples.py
Expand Up @@ -46,3 +46,11 @@ def test_example_custom_module(default_rules_collection):
'examples/playbooks/custom_module.yml', rules=default_rules_collection
).run()
assert len(result) == 0


def test_full_vault(default_rules_collection):
"""custom_module.yml is expected to pass."""
result = Runner(
'examples/playbooks/vars/not_decryptable.yml', rules=default_rules_collection
).run()
assert len(result) == 0

0 comments on commit dd4bf59

Please sign in to comment.