Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid reporting loading errors with vaulted files #1443

Merged
merged 1 commit into from
Mar 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions examples/playbooks/vars/not_decryptable.yml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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