Hi, Could someone please help how to sort the below using ansible
"msg": [
{
"Desc": "jkl - txt to search-\n",
"SCTASK": "SCTASK000001"
},
{
"Desc": "xyz - txt to search-\n",
"SCTASK": "SCTASK000002"
},
{
"Desc": "def - txt to search-\n",
"SCTASK": "SCTASK000003"
},
{
"Desc": "def - txt to search-\n",
"SCTASK": "SCTASK000004"
},
{
"Desc": "abc- txt to search-\n",
"SCTASK": "SCTASK000005"
}
]
I need to get both sctask and description where 'abc' word present in 'Desc'. I tried to use where condition in my code block but it's not filtering.
- set_fact:
SCT: "{{ jsoncontent.json | json_query(query)}}"
vars:
query: "result[*].{Desc: description, SCTASK: number}"
- name: debug
debug: msg="{{ item }}"
loop: "{{SCT}}"
when: SCT is search("abc")
Thanks!