-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtest-list.yml
31 lines (26 loc) · 870 Bytes
/
test-list.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
# ansible-playbook test-list.yml
- name: Create sub-list
hosts: localhost
connection: local
become: false
gather_facts: false
vars:
input: "{{ lookup('file','list.json') | from_json }}"
interfacelist: []
tasks:
- name: Create interfaces Dictionary
ansible.builtin.set_fact:
interfaces: "{{ input }}"
- name: Print out interfaces
ansible.builtin.debug:
var: item
when: not item.enabled and 'Gig' in item.name
with_items: "{{ interfaces }}"
- name: Create list with items in variable interfaces which enable is false
ansible.builtin.set_fact:
interfacelist: "{{ interfacelist + [item.name] }}"
when: not item.enabled and 'Gig' in item.name
with_items: "{{ interfaces }}"
- name: Print out interfaces variable
ansible.builtin.debug:
var: interfacelist