Conditional loop using hostvars

chtsalid
Wed, 13 Mar 2024 19:24:11 +0000
Get Help

Hi all,

I am encountering a problem using a conditional loop with hostvars. I am getting an error, that the conditional is not correct. Here underneath is my module:

set_fact:
hostlist: “{{ hostlist | default() + [item] }}”
loop: “{{ groups[‘ios’] }}”
when: hostvars.[‘item’].[‘failed_attempt’] == “failed”

I am using ansible 2.10.

Do you have any idea, how can I fix this?

Thanks a lot!

4 posts - 3 participants