On 26.05.2018 04:32, David Villasmil wrote:
> Hellos guys,
>
> I have a result from ec2_instance_facts, and i can get the ip addresses
> like:
> - name: Get IP addresses from results
> set_fact:
> inject_ips: “{{ facts_output | json_query(‘instances[].
> public_ip_address’) }}”
<snip />
> I can also get the name with:
>
> - name: Get IP addresses from results
> set_fact:
> inject_ips: “{{ facts_output |
> json_query(‘instances[].tags[].Name’)
> }}”
>
> But i don't know how to concatenate them, i tried:
>
> - name: Get IP addresses from results
> set_fact:
> inject_ips: “{{ facts_output | json_query(‘instances[].
> public_ip_address’) }},{{ facts_output |
> json_query(‘instances[].tags[].Name
> ’) }}”
<snip />
> The point is to then use it like:
>
>
> - name: execute to add the ips
> command: “exec item[ip] item[name]”
> run_once: true
> with_items:
> - “{{ inject_ips }}”
>
> Right now I'm splitting them by comma ","
>
> Any suggestion is welcomed!
Why split them up, why not just use facts_output directly.
- name: execute to add the ips
command: “exec item.public_ip_address
item.tags.Name”
run_once: true
with_items:
- “{{ facts_output.instances }}”
--
Kai Stian Olstad