I have a list generated in ansible using values gathered by a task. In that list, there are empty strings as some of the keys don't have values assigned to them. So, what I am trying to achieve is to assign that list to a new list but without those empty values.
list1: [
"a",
"b",
"",
"7",
""
]
I have tried the following and it doesn't seem to work:
set_fact:
list2: "{{ list1 1 | rejectattr('') |list }}"
Is anyone able to point me what I am doing wrong and provide a solution to my issue?
Ansible version: 2.9.1