-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplaybook-varspractice01.yml
54 lines (45 loc) · 1.23 KB
/
playbook-varspractice01.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
- name: learning to recall var data
hosts: localhost
# these are play vars
vars:
telecom:
- ericsson
- alu
- avaya
- cisco
heroes:
marvel:
- spiderman
- ironman
- daredevil
dc:
- wonderwoman
- batman
- superman
tasks:
# 1st item in the marvel list
- name: print out spiderman
ansible.builtin.debug:
msg: "{{ heroes.marvel[0] }}"
# second item in the dc list
- name: print out batman
ansible.builtin.debug:
msg: "{{ heroes.dc[1] }}"
- name: print out ALL dc heroes
ansible.builtin.debug:
msg: "{{ heroes.dc }}"
- name: print out all dc heroes with a loop
ansible.builtin.debug:
msg: "{{ item }}"
loop: "{{ heroes.dc }}"
# fourth item in the telecom list
- name: print out cisco
ansible.builtin.debug:
msg: "{{ telecom[3] }}"
- name: Print out all dc and marvel heroes
debug:
msg: "{{ heroes }}"
- name: print out ALL dc AND marvel heroes ONLY
ansible.builtin.debug:
msg: "{{ item }} is the greatest! Go {{ item }}!!!!"
loop: "{{ heroes.marvel + heroes.dc }}"