File tree Expand file tree Collapse file tree 3 files changed +22
-3
lines changed
examples/roles/role_vars_prefix_detection/handlers Expand file tree Collapse file tree 3 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -93,6 +93,7 @@ switchport
9393sysvinit
9494taskshandlers
9595testinfra
96+ thefoo
9697timesyncd
9798tmpfs
9899tomlsort
Original file line number Diff line number Diff line change 1+ ---
2+ - name : Echo thefoo
3+ ansible.builtin.command : echo thefoo
4+ changed_when : true
5+ register : thefoo
6+
7+ - name : Echo thebar
8+ ansible.builtin.command : echo thebar
9+ changed_when : true
10+ register : role_vars_prefix_detection_thebar
11+
12+ - name : Test ansible.builtin.set_fact without role prefix
13+ ansible.builtin.set_fact :
14+ foo : bar
15+
16+ - name : Test set_fact with role prefix
17+ ansible.builtin.set_fact :
18+ role_vars_prefix_detection_foo : bar
Original file line number Diff line number Diff line change @@ -250,8 +250,8 @@ def matchtask(
250250 results = []
251251 task_prefix = Prefix ()
252252 role_prefix = Prefix ()
253- if file and file .parent and file . parent . kind == " role" :
254- role_prefix = Prefix (file .parent . path . name )
253+ if file and file .role :
254+ role_prefix = Prefix (file .role )
255255 ansible_module = task ["action" ]["__ansible_module__" ]
256256 # If the task uses the 'vars' section to set variables
257257 # only check role prefix for include_role and import_role tasks 'vars'
@@ -426,7 +426,7 @@ def test_var_naming_with_role_prefix(
426426 Lintable ("examples/roles/role_vars_prefix_detection" ),
427427 rules = default_rules_collection ,
428428 ).run ()
429- assert len (results ) == 2
429+ assert len (results ) == 4
430430 for result in results :
431431 assert result .tag == "var-naming[no-role-prefix]"
432432
You can’t perform that action at this time.
0 commit comments