8
8
from ansiblelint .rules import RulesCollection
9
9
from ansiblelint .runner import Runner
10
10
11
- ROLE_TASKS_MAIN = """
11
+ ROLE_TASKS_MAIN = """\
12
+ ---
12
13
- name: shell instead of command
13
14
shell: echo hello world
15
+ changed_when: false
14
16
"""
15
17
16
- ROLE_TASKS_WORLD = """
17
- - command: echo this is a task without a name
18
+ ROLE_TASKS_WORLD = """\
19
+ ---
20
+ - debug: msg="this is a task without a name"
18
21
"""
19
22
20
- PLAY_IMPORT_ROLE = """
23
+ PLAY_IMPORT_ROLE = """\
24
+ ---
21
25
- hosts: all
22
26
23
27
tasks:
24
- - import_role:
28
+ - name: some import
29
+ import_role:
25
30
name: test-role
26
31
"""
27
32
28
- PLAY_IMPORT_ROLE_INLINE = """
33
+ PLAY_IMPORT_ROLE_FQCN = """\
34
+ ---
29
35
- hosts: all
30
36
31
37
tasks:
32
- - import_role: name=test-role
38
+ - name: some import
39
+ ansible.builtin.import_role:
40
+ name: test-role
41
+ """
42
+
43
+ PLAY_IMPORT_ROLE_INLINE = """\
44
+ ---
45
+ - hosts: all
46
+
47
+ tasks:
48
+ - name: some import
49
+ import_role: name=test-role
33
50
"""
34
51
35
- PLAY_INCLUDE_ROLE = """
52
+ PLAY_INCLUDE_ROLE = """\
53
+ ---
36
54
- hosts: all
37
55
38
56
tasks:
39
- - include_role:
57
+ - name: some import
58
+ include_role:
40
59
name: test-role
41
60
tasks_from: world
42
61
"""
43
62
44
- PLAY_INCLUDE_ROLE_INLINE = """
63
+ PLAY_INCLUDE_ROLE_FQCN = """\
64
+ ---
45
65
- hosts: all
46
66
47
67
tasks:
48
- - include_role: name=test-role tasks_from=world
68
+ - name: some import
69
+ ansible.builtin.include_role:
70
+ name: test-role
71
+ tasks_from: world
72
+ """
73
+
74
+ PLAY_INCLUDE_ROLE_INLINE = """\
75
+ ---
76
+ - hosts: all
77
+
78
+ tasks:
79
+ - name: some import
80
+ include_role: name=test-role tasks_from=world
49
81
"""
50
82
51
83
@@ -67,19 +99,29 @@ def fixture_playbook_path(request: SubRequest, tmp_path: Path) -> str:
67
99
(
68
100
pytest .param (
69
101
PLAY_IMPORT_ROLE ,
70
- ["only when shell functionality is required" ],
102
+ ["only when shell functionality is required" , "All tasks should be named" ],
71
103
id = "IMPORT_ROLE" ,
72
104
),
105
+ pytest .param (
106
+ PLAY_IMPORT_ROLE_FQCN ,
107
+ ["only when shell functionality is required" , "All tasks should be named" ],
108
+ id = "IMPORT_ROLE_FQCN" ,
109
+ ),
73
110
pytest .param (
74
111
PLAY_IMPORT_ROLE_INLINE ,
75
- ["only when shell functionality is require" ],
112
+ ["only when shell functionality is require" , "All tasks should be named" ],
76
113
id = "IMPORT_ROLE_INLINE" ,
77
114
),
78
115
pytest .param (
79
116
PLAY_INCLUDE_ROLE ,
80
117
["only when shell functionality is require" , "All tasks should be named" ],
81
118
id = "INCLUDE_ROLE" ,
82
119
),
120
+ pytest .param (
121
+ PLAY_INCLUDE_ROLE_FQCN ,
122
+ ["only when shell functionality is require" , "All tasks should be named" ],
123
+ id = "INCLUDE_ROLE_FQCN" ,
124
+ ),
83
125
pytest .param (
84
126
PLAY_INCLUDE_ROLE_INLINE ,
85
127
["only when shell functionality is require" , "All tasks should be named" ],
@@ -92,7 +134,11 @@ def test_import_role2(
92
134
default_rules_collection : RulesCollection , playbook_path : str , messages : List [str ]
93
135
) -> None :
94
136
"""Test that include_role digs deeper than import_role."""
95
- runner = Runner (playbook_path , rules = default_rules_collection )
137
+ runner = Runner (
138
+ playbook_path , rules = default_rules_collection , skip_list = ["fqcn-builtins" ]
139
+ )
96
140
results = runner .run ()
97
141
for message in messages :
98
142
assert message in str (results )
143
+ # Ensure no other unexpected messages are present
144
+ assert len (messages ) == len (results ), results
0 commit comments