# using module ec2\_instance\_info get private ip

**URL:** <https://forum.ansible.com/t/using-module-ec2-instance-info-get-private-ip/36587>\
**Category:** Ansible Project\
**Created:** [May 3, 2022, 4:52pm UTC](https://forum.ansible.com/t/using-module-ec2-instance-info-get-private-ip/36587 "2022-05-03T16:52:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Emanuel\_Gonzalez](https://avatars.discourse-cdn.com/v4/letter/e/b3f665/32.png) [@Emanuel\_Gonzalez](https://forum.ansible.com/u/Emanuel_Gonzalez)\
**Post date:** [May 3, 2022, 4:52pm UTC](https://forum.ansible.com/t/using-module-ec2-instance-info-get-private-ip/36587/1 "2022-05-03T16:52:24Z")

</div>

Hi,

I’m trying to get the private ip of an instance by filtering by the tag name but I get the following error:

`  
fatal: [localhost]: FAILED! =\> {“msg”: “The task includes an option with an undefined variable. The error was: ‘dict object’ has no attribute ‘private\_ip\_address’\n\nThe error appears to be in ‘/etc/ansible/loyalty/tasks/create\_ec2.yaml’: line 59, column 7, but may\nbe elsewhere in the file depe nding on the exact syntax problem.\n\nThe offending line appears to be:\n\n register: ec2\_metadata\n - name: Muestro la IP publica de la ins tancia creada\n ^ here\n”}

Here my yaml:

`

- name: instances info  
`ec2_instance_info:`  
region: us-west-2  
`filters:`  
“tag:Name”: myserver  
`register: ec2_metadata`
- name: show info  
`debug:`  
msg: “{{ ec2\_metadata.instances[0].private\_ip\_address }}”  
`

What am I doing wrong?

Regards,

`
