Found a solution, let me answer myself if anyone is interested
I got a list the internal IPs by creating a new group, as follow:
- name: Add instances to private ip group
local_action: add_host name={{item.private_ip}}
groupname=CassandraPrivate_{{load_name}}
with_items: ec2.instances
And using it from a different playbook as follow:
- command: echo "{{ item }}"
with_items: groups.CassandraPrivate_{{load_name}}
register: outputPrivate
changed_when: no
- set_fact: ip_list="{{
outputPrivate.results|map(attribute='stdout')|join(',') }}"
Thanks again
On Sat, Jan 31, 2015 at 5:23 PM, Tzach Livyatan <[email protected]>
wrote:
> Thanks Brain, Giovanni
> I'm confused on when to use ec2.py dynamic inventory and when creating
> group as you suggested.
> If I understand correctly, the first make sense if I want to query info
> set by others, while the second make more sense if the servers live and die
> in the scope of my playbook (my use case).
>
> I'm currently using hostvars from ec2.py to get the internal ips of
> servers:
>
> - command: echo "{{ hostvars[item].ec2_private_ip_address }}"
> with_items: groups.tag_Name_Cassandra
> register: output
> changed_when: no
>
> Can I get the internal IP without ec2.py?
> If I can not, refreshing the inventory between plays is mandatory - going
> back to my original question.
>
>
>
>
>
> On Thu, Jan 29, 2015 at 5:14 PM, Brian Coca <[email protected]> wrote:
>
>> add_host affects the 'current run', all subsequent plays will have
>> access, the distribtion of the plays in different files does not
>> matter.
>>
>> ansible reads all the files passed to it (directly or through
>> includes), compiles the plays and then runs them in order, at this
>> point the files they came from are irrelevant.
>>
>> --
>> Brian Coca
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Ansible Project" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/ansible-project/1x5hFy4dzcQ/unsubscribe
>> .
>> To unsubscribe from this group and all its topics, 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/CAJ5XC8mj7zx5tN7SwA_n3aB3EYb%3DKVk4tmYx5ZSRB_2d9ujQRw%40mail.gmail.com
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Regards
> @TzachL
>
--
Regards
@TzachL
--
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/CAGLV4Vc_3%3DQk0T7t2ZQfQJ9FDBX5QLKVVhgc8tM1ws18RZU%3D6Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.