Debian Codegraph @

examples/roles/var_naming_no_role_prefix/tasks/main.yml

raw
1 ---
2 # Test cases for var-naming[no-role-prefix] rules
3 # - "global" variables (set_fact, register) should require role prefix
4 # - task-scoped variables (vars) should not require role prefix
5 # (except include_role and import_role tasks)
6
7 # register
8 - name: Test register without role prefix (should fail)
9 ansible.builtin.command: echo "test"
10 register: bad_register_var
11 changed_when: false
12
13 - name: Test register with role prefix (should pass)
14 ansible.builtin.command: echo "test"
15 register: var_naming_no_role_prefix_good_var
16 changed_when: false
17
18 # set_fact
19 - name: Test set_fact without role prefix (should fail)
20 ansible.builtin.set_fact:
21 bad_set_fact_var: "test"
22
23 - name: Test set_fact with role prefix (should pass)
24 ansible.builtin.set_fact:
25 var_naming_no_role_prefix_good_var: "test"
26
27 # vars
28 - name: Test vars without role prefix (should pass)
29 ansible.builtin.debug:
30 msg: "{{ bad_vars_var }}"
31 vars:
32 bad_vars_var: "test"
33
34 - name: Test vars with role prefix (should pass)
35 ansible.builtin.debug:
36 msg: "{{ var_naming_no_role_prefix_good_var }}"
37 vars:
38 var_naming_no_role_prefix_good_var: "test"
39
40 # vars include_role
41 - name: Test include_role vars without included role prefix (should fail)
42 ansible.builtin.include_role:
43 name: var_naming_pattern
44 vars:
45 bad_included_var: "test"
46
47 - name: Test include_role vars with included role prefix (should pass)
48 ansible.builtin.include_role:
49 name: var_naming_pattern
50 vars:
51 var_naming_pattern_included_var: "test"
52
53 # vars import_role
54 - name: Test import_role vars without imported role prefix (should fail)
55 ansible.builtin.import_role:
56 name: var_naming_pattern
57 vars:
58 bad_imported_var: "test"
59
60 - name: Test import_role vars with imported role prefix (should pass)
61 ansible.builtin.import_role:
62 name: var_naming_pattern
63 vars:
64 var_naming_pattern_imported_var: "test"