I'm getting different output using the same method in debug vs set_fact.
- name: Get EC2 instances
ec2_instance_facts:
filters:
"tag:Name": "{{ item }}"
loop:
- value
- value
register: servers
- debug:
msg: "{{ item.instances | map(attribute='private_ip_address') | list }}"
loop: "{{ servers.results }}"
- name: Set the private IPs list
set_fact:
private_ips: "{{ item.instances | map(attribute='private_ip_address') | list }}"
loop: "{{ servers.results }}"
- debug:
var: private_ips
In the initial ec2_instance_facts loop, 6 instances are output. During the debug loop to get the private IPs, all 6 IPs are output, albeit in 2 separate blocks (I'm guessing from the initial loop - 2 are output in the first block, then the remaining 4).
However, when using set_fact, I only ever get the first 2 IPs. I'm guessing I'm making this more difficult than it needs to be, and it's got to do w/using that first loop correctly, but I'm stuck.