You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- name: "A dictionary is represented in a simple key: value form (the colon must be followed by a space). This allows us to point values as itemname.key. For example look how this text generated:"
13
+
debug:
14
+
msg: "We want to {{ swap_file.status }} file to {{ swap_file.location }}. File should be called {{ swap_file.filename }} and use {{ swap_file.size }} MB of disk space."
15
+
16
+
- name: Dictionary is a key:value(hash table), not a list. It is bad idea to use with_items here. with_items will loop through keys value names in this example.
17
+
debug:
18
+
msg: "{{ item }}"
19
+
with_items: "{{ swap_file }}"
20
+
21
+
- name: Dictionary is a key:value(hash table), not a list. We will get "VARIABLE IS NOT DEFINED!" if we try to get var like this.
22
+
debug:
23
+
var: "{{ item }}"
24
+
with_items: "{{ swap_file }}"
25
+
26
+
- name: Usage of with_dict helps here.
27
+
debug:
28
+
msg: "Current key is {{ item.key }}. Current key value is {{ item.value }}."
29
+
with_dict: "{{ swap_file }}"
30
+
31
+
- name: We will get variable type in this syntax, but not variable content. See next example.
32
+
debug:
33
+
var: "{{ swap_file }}"
34
+
35
+
- name: We will get complete dictionary if we request it as bare variable name. You should exclude bare variable names usage from you roles and playbooks, as it is deprecated and will be removed soon (except debug).
- name: "A dictionary is represented in a simple key: value form (the colon must be followed by a space). This allows us to point values as itemname.key. For example look how this text generated:"
9
+
debug:
10
+
msg: "We want to {{ swap_file.status }} file to {{ swap_file.location }}. File should be called {{ swap_file.filename }} and use {{ swap_file.size }} MB of disk space."
11
+
12
+
- name: Dictionary is a key:value(hash table), not a list. It is bad idea to use with_items here. with_items will loop through keys value names in this example.
13
+
debug:
14
+
msg: "{{ item }}"
15
+
with_items: "{{ swap_file }}"
16
+
17
+
- name: Dictionary is a key:value(hash table), not a list. We will get "VARIABLE IS NOT DEFINED!" if we try to get var like this.
18
+
debug:
19
+
var: "{{ item }}"
20
+
with_items: "{{ swap_file }}"
21
+
22
+
- name: Usage of with_dict helps here.
23
+
debug:
24
+
msg: "Current key is {{ item.key }}. Current key value is {{ item.value }}."
25
+
with_dict: "{{ swap_file }}"
26
+
27
+
- name: We will get variable type in this syntax, but not variable content. See next example.
28
+
debug:
29
+
var: "{{ swap_file }}"
30
+
31
+
- name: We will get complete dictionary if we request it as bare variable name. You should exclude bare variable names usage from you roles and playbooks, as it is deprecated and will be removed soon (except debug).
0 commit comments