Ansible shows error: “One or more undefined variables: ‘item’ is undefined” when using ‘with_items’

with_items (and the whole family of with_ loops) is a dictionary key defined in a task, not as a parameter to the action.

Fix the indentation:

- debug:
    msg: "Instance: {{ item.instances }}"
  with_items: "{{ elb_facts.elbs }}"

Leave a Comment