-
Notifications
You must be signed in to change notification settings - Fork 654
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix rule skipping in pre and post task include plays (#641)
- Loading branch information
Showing
5 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import os | ||
import unittest | ||
|
||
from ansiblelint import Runner, RulesCollection | ||
|
||
|
||
class TestTaskIncludes(unittest.TestCase): | ||
|
||
def setUp(self): | ||
rulesdir = os.path.join('lib', 'ansiblelint', 'rules') | ||
self.rules = RulesCollection.create_from_directory(rulesdir) | ||
|
||
def test_pre_task_include_playbook(self): | ||
filename = 'test/playbook-include/playbook_pre.yml' | ||
runner = Runner(self.rules, filename, [], [], []) | ||
results = runner.run() | ||
|
||
self.assertEqual(len(runner.playbooks), 2) | ||
self.assertEqual(len(results), 3) | ||
self.assertIn('Commands should not change things', str(results)) | ||
|
||
self.assertNotIn('502', str(results)) | ||
self.assertNotIn('All tasks should be named', str(results)) | ||
|
||
def test_post_task_include_playbook(self): | ||
filename = 'test/playbook-include/playbook_post.yml' | ||
runner = Runner(self.rules, filename, [], [], []) | ||
results = runner.run() | ||
|
||
self.assertEqual(len(runner.playbooks), 2) | ||
self.assertEqual(len(results), 3) | ||
self.assertIn('Commands should not change things', str(results)) | ||
|
||
self.assertNotIn('502', str(results)) | ||
self.assertNotIn('All tasks should be named', str(results)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
- hosts: localhost | ||
connection: local | ||
gather_facts: no | ||
tasks: | ||
- command: echo "no name" # noqa 502 | ||
- name: Another task | ||
debug: | ||
msg: debug message |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
- hosts: localhost | ||
tasks: | ||
- command: echo "no name" # noqa 502 | ||
post_tasks: | ||
- command: echo "no name" # noqa 502 | ||
- name: Including another playbook | ||
include: playbook_included.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
- hosts: localhost | ||
tasks: | ||
- command: echo "no name" # noqa 502 | ||
pre_tasks: | ||
- command: echo "no name" # noqa 502 | ||
- name: Including another playbook | ||
include: playbook_included.yml |