Ansible - iterate over items and execute task if value doesn't exist Ansible - iterate over items and execute task if value doesn't exist kubernetes kubernetes

Ansible - iterate over items and execute task if value doesn't exist


If you port your condition to the debug task, you will see that it is skipped when condition is not met:

- debug:    msg: "{{ item.metadata.name }} meets the condition"  with_items: "{{ namespace_result.resources }}"  when: item.metadata.name != "fluxcd"

This will validate how your task loops and checks your condition. You can then replace the debug module with k8s and it will skip the exact same way.