Hi all,
I have a rather simple usecase for which I don't seem to find an answer.
How can I ping a AWS/ec2 instance from another instance in a different play? I'm using the dynamic inventory.
The scenario is like this:
I create two ec2 instance in a play like this:
ec2:
group: "{{ security_group }}"
instance_type: "{{ instance_type }}"
image: "{{ image }}"
region: "{{ region }}"
key_name: "{{ keypair }}"
instance_tags:
Name: Destination
ec2:
group: "{{ security_group }}"
instance_type: "{{ instance_type }}"
image: "{{ image }}"
region: "{{ region }}"
key_name: "{{ keypair }}"
instance_tags:
Name: Source
This works well, the nodes are started and I can see them when running ./ec2.py
Then, in another play (ping.yml) I want to do this
- name: pinging host
hosts: tag_Name_Source
remote_user: ubuntu
tasks:
- shell: ping {{ tag_Name_Destination }}
I run it with
ansible-playbook -i ec2.py ping.yml
but it gives me "One or more undefined variables: 'tag_Name_Destination' is undefined"
What is the right way to get the IP of the target machine?
I'm running Ansible 1.8.2 on Ubuntu.
Thanks for any hints.
/Sven