Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove item from Ansible list?

I need remove some item from list

"my_list_one": [
    "item1",
    "item2",
    "item3"
] }

I need remove item which includes string "2". As result, I need list as

"my_list_one": [
    "item1",
    "item3"
] }

How could I realize it?

like image 845
Neil Avatar asked Dec 11 '22 13:12

Neil


1 Answers

A nicer variation of @techraf's answer:

{{ my_list_one | reject('search','2') | list }}
like image 134
Konstantin Suvorov Avatar answered Jan 09 '23 01:01

Konstantin Suvorov