Skip to content

Commit d9eea72

Browse files
committed
Lists examples
1 parent 89bb92a commit d9eea72

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

examples/lists.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
- hosts: localhost
3+
gather_facts: false
4+
vars:
5+
soft:
6+
- htop
7+
- atop
8+
- tshark
9+
- mtr
10+
tasks:
11+
- name: List is just a list. Typicaly used when you need to do something with every item in it.
12+
debug:
13+
msg: "We can install: {{ item }}"
14+
with_items: "{{ soft }}"
15+
16+
- name: List is not a key:value(hash table), list is just a keys. So we will get "VARIABLE IS NOT DEFINED!" here, because there is no variables like "htop".
17+
debug:
18+
var: "{{ item }}"
19+
with_items: "{{ soft }}"
20+
21+
- name: We will get variable type in this syntax, but not variable content. See next example.
22+
debug:
23+
var: "{{ soft }}"
24+
25+
- name: We will get all list 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).
26+
debug:
27+
var: soft

0 commit comments

Comments
 (0)