LOOP_CONTROL with ansible

18 views
Skip to first unread message

Dhara Patel

unread,
Nov 13, 2018, 9:09:27 PM11/13/18
to Ansible Project
Hi,

When i run my playbook i run into this issue. It pops us as Warning.

[WARNING]: The loop variable 'item' is already in use. You should set the `loop_var` value in the `loop_control` option

for the task to something else to avoid variable collisions and unexpected behavior.


main.yml

- include: groups.yml


groups.yml

- include: ec2_gr.yml


ec2_gr.yml

- name: 'ec2 groups'
ec2_group:
name: '{{ item.key }}'
description: '{{ item.value.description }}'
vpc_id: '{{ vpc_net_facts.id }}'
region: '{{ region }}'
rules: '{{ item.value.rules }}'

rules_egress: '{{ default_egress_rule if item.value.rules_egress is not defined else item.value.rules_egress }}'
when: ec2groups is defined
with_dict: '{{ ec2groups | default({}) }}'
register: tag_ec2groups
- set_fact:
group: '{{ ec2groups.keys() + group }}'
when: ec2groups is defined I see a warning on above line. I have such issue with a lot of tasks. I don't understand loop_control that well. I tried to provide that variable after register: but still running into issue.


Reply all
Reply to author
Forward
0 new messages