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

--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/83d801ed11a0b1710c6e16b86d92c9c8%40olstad.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to