-
Notifications
You must be signed in to change notification settings - Fork 0
/
return_dict_matched_with_key.yml
39 lines (36 loc) · 1.19 KB
/
return_dict_matched_with_key.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
---
- name: Find dictionary by key match
hosts: localhost
gather_facts: false
tasks:
- name: Define the list of dictionaries
set_fact:
configuration_loggers_logger:
- "@name": "org.apache.log4j.xml"
"@level": "info"
- "@name": "org.kp.oppr"
"@level": "debug"
"@additivity": "false"
"AppenderRef":
"@ref": "rollingFile"
- "@name": "org.springframework"
"@level": "info"
"@additivity": "false"
"AppenderRef":
"@ref": "rollingFile"
- "@name": "org.springframework.context"
"@level": "info"
"@additivity": "false"
"AppenderRef":
"@ref": "rollingFile"
- "@name": "org.springframework.web"
"@level": "info"
"@additivity": "false"
"AppenderRef":
"@ref": "rollingFile"
- name: Find dictionary by key match
set_fact:
matching_dict: "{{ configuration_loggers_logger | selectattr('@name', 'equalto', 'org.apache.log4j.xml') | first }}"
- name: Display the matching dictionary
debug:
var: matching_dict