What Im trying to accomplish is to create a network load balancer target 
group from dynamically generated list of instances.

brokerInstancesList is a list of instance ids. I need to iterate over this 
list and add them as targets to this target group.


- name: "Create 9092 target group"
  elb_target_group:
    name: "tg-{{ ClusterName }}"
    protocol: tcp
    port: 9092
    vpc_id: "{{ VPCID }}"
    targets:
      - Id: "{{ item }}"
        Port: 9092
    state: present
  loop: "{{ brokerInstancesList }}"


The issue with my attempt above is that only the last entry in the 
brokerInstancesList is kept. Something like the below is what I need.


- name: "Create 9092 target group"
  elb_target_group:
    name: "tg-{{ ClusterName }}"
    protocol: tcp
    port: 9092
    vpc_id: "{{ VPCID }}"
    targets:
      {% for item in {{ brokerInstancesList }} -%}
      - Id: "{{ apple }}"
        Port: 9092
      {%- endfor %}
    state: present

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/9f81217a-50f2-49be-8b80-70f5f263242b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to