# how to get ip address of an RDS instance using the RDS module ?

**URL:** <https://forum.ansible.com/t/how-to-get-ip-address-of-an-rds-instance-using-the-rds-module/13551>\
**Category:** Ansible Project\
**Created:** [September 25, 2013, 2:06pm UTC](https://forum.ansible.com/t/how-to-get-ip-address-of-an-rds-instance-using-the-rds-module/13551 "2013-09-25T14:06:11Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nicolas\_G](https://avatars.discourse-cdn.com/v4/letter/n/a183cd/32.png) [@Nicolas\_G](https://forum.ansible.com/u/Nicolas_G)\
**Post date:** [September 25, 2013, 2:06pm UTC](https://forum.ansible.com/t/how-to-get-ip-address-of-an-rds-instance-using-the-rds-module/13551/1 "2013-09-25T14:06:11Z")

</div>

Hi All,

How can I get the public IP of an RDS instance the same way we do with the ec2 module (register: ec2/with\_items: ec2.instances / {{ item.public\_ip }} ) ?

I see in the RDS documentation ([http://www.ansibleworks.com/docs/modules.html#rds](http://www.ansibleworks.com/docs/modules.html#rds)) the register: new\_database\_facts  
but I don’t know what item types can be queried.

Regards,  
N.

---

<div class="post-metadata">

**Author:** ![James\_Cammarata1](https://avatars.discourse-cdn.com/v4/letter/j/d26b3c/32.png) [@James\_Cammarata1](https://forum.ansible.com/u/James_Cammarata1)\
**Post date:** [September 25, 2013, 3:37pm UTC](https://forum.ansible.com/t/how-to-get-ip-address-of-an-rds-instance-using-the-rds-module/13551/2 "2013-09-25T15:37:39Z")

</div>

You might also want to look at the ec2\_facts module, which should work with an RDS instance I think. Also, the ec2 inventory script should return this information and it would be in the host variables.

---

<div class="post-metadata">

**Author:** ![Nicolas\_G](https://avatars.discourse-cdn.com/v4/letter/n/a183cd/32.png) [@Nicolas\_G](https://forum.ansible.com/u/Nicolas_G)\
**Post date:** [September 25, 2013, 3:46pm UTC](https://forum.ansible.com/t/how-to-get-ip-address-of-an-rds-instance-using-the-rds-module/13551/3 "2013-09-25T15:46:35Z")

</div>

Thanks James but I believe in my case will be more efficient and faster to get the ip right after the RDS creation from register: new\_database\_facts if available.

---

<div class="post-metadata">

**Author:** ![Nicolas\_G](https://avatars.discourse-cdn.com/v4/letter/n/a183cd/32.png) [@Nicolas\_G](https://forum.ansible.com/u/Nicolas_G)\
**Post date:** [October 10, 2013, 2:49pm UTC](https://forum.ansible.com/t/how-to-get-ip-address-of-an-rds-instance-using-the-rds-module/13551/4 "2013-10-10T14:49:23Z")

</div>

any ideas on this ?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [October 11, 2013, 12:09am UTC](https://forum.ansible.com/t/how-to-get-ip-address-of-an-rds-instance-using-the-rds-module/13551/5 "2013-10-11T00:09:02Z")

</div>

On what in particular?

---

<div class="post-metadata">

**Author:** ![Nicolas\_G](https://avatars.discourse-cdn.com/v4/letter/n/a183cd/32.png) [@Nicolas\_G](https://forum.ansible.com/u/Nicolas_G)\
**Post date:** [October 14, 2013, 10:03am UTC](https://forum.ansible.com/t/how-to-get-ip-address-of-an-rds-instance-using-the-rds-module/13551/6 "2013-10-14T10:03:29Z")

</div>

on how can I get an RDS instance public IP

---

<div class="post-metadata">

**Author:** ![Chris\_Shenton](https://avatars.discourse-cdn.com/v4/letter/c/f9ae1b/32.png) [@Chris\_Shenton](https://forum.ansible.com/u/Chris_Shenton)\
**Post date:** [October 18, 2013, 3:36pm UTC](https://forum.ansible.com/t/how-to-get-ip-address-of-an-rds-instance-using-the-rds-module/13551/7 "2013-10-18T15:36:15Z")

</div>

I’m interested in determining the IP (and other facts) of a created RDS instance as well. When I create an RDS instance, I use the “wait: no” option because creating the instance takes a LONG time:

- name: Create RDS Oracle  
local\_action:  
module: rds  
command: create  
region: ${region}  
instance\_type: db.m1.small

instance\_name: ${rds.name}

…  
wait: no

But I’d like to get the IP so I can create a Route53 entry, then use that later when I install software on the instance using this RDS.

Is there a way to retrieve this info? If not in this run – where “wait: no” would likely provide no means for the play to ask AWS for the RDS IP – then in a subsequent play?

Thanks.

---

<div class="post-metadata">

**Author:** ![Peter\_Sankauskas](https://avatars.discourse-cdn.com/v4/letter/p/ea666f/32.png) [@Peter\_Sankauskas](https://forum.ansible.com/u/Peter_Sankauskas)\
**Post date:** [October 18, 2013, 4:57pm UTC](https://forum.ansible.com/t/how-to-get-ip-address-of-an-rds-instance-using-the-rds-module/13551/8 "2013-10-18T16:57:41Z")

</div>

You should never know or use the IP address for RDS. RDS has an endpoint and that is the only way you should be accessing it.

If you happen to be running a multi-az RDS deployment, the IP address with change whenever it feels like it.

Think of it the same as using an ELB, and only use the endpoint.

---

<div class="post-metadata">

**Author:** ![Chris\_Shenton](https://avatars.discourse-cdn.com/v4/letter/c/f9ae1b/32.png) [@Chris\_Shenton](https://forum.ansible.com/u/Chris_Shenton)\
**Post date:** [October 18, 2013, 7:34pm UTC](https://forum.ansible.com/t/how-to-get-ip-address-of-an-rds-instance-using-the-rds-module/13551/9 "2013-10-18T19:34:58Z")

</div>

Understood, fair 'nuff.

Then let me rephrase the question: how can I get the endpoint name after creation, so I can use it to configure parameters on my app server with subsequent ansible plays?

Thanks.

---

<div class="post-metadata">

**Author:** ![Peter\_Sankauskas](https://avatars.discourse-cdn.com/v4/letter/p/ea666f/32.png) [@Peter\_Sankauskas](https://forum.ansible.com/u/Peter_Sankauskas)\
**Post date:** [October 18, 2013, 9:30pm UTC](https://forum.ansible.com/t/how-to-get-ip-address-of-an-rds-instance-using-the-rds-module/13551/10 "2013-10-18T21:30:51Z")

</div>

Well, based on this:

> [https://github.com/ansible/ansible/blob/devel/library/cloud/rds#L520](https://github.com/ansible/ansible/blob/devel/library/cloud/rds#L520)

It would see the endpoint is accessible by “your\_registered\_var.endpoint”, but if you specify “wait: no”, then you don’t get that information because the endpoint is only available once RDS is available, not directly after the first API call.

Patience is a virtue 🙂

---

<div class="post-metadata">

**Author:** ![Nicolas\_G](https://avatars.discourse-cdn.com/v4/letter/n/a183cd/32.png) [@Nicolas\_G](https://forum.ansible.com/u/Nicolas_G)\
**Post date:** [October 23, 2013, 3:47pm UTC](https://forum.ansible.com/t/how-to-get-ip-address-of-an-rds-instance-using-the-rds-module/13551/11 "2013-10-23T15:47:12Z")

</div>

After successfuly creating a new RDS instance I’m still not able to get the endpoint address in the playbook :

“”"

- name: get RDS instance facts  
local\_action: rds command=facts instance\_name={{ instance\_name }} region={{ region }}  
register: rds

# RDS creation can take a long time for the status to be ready casuing problems for the

- name: RDS endpoint is → {{ rds.endpoint }}  
debug: msg=" RDS endpoint is → {{ rds.endpoint }}"  
“”"

-vvv ouput  
“”"

TASK: [get RDS instance facts] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
\<127.0.0.1\> EXEC [‘/bin/sh’, ‘-c’, ‘mkdir -p $HOME/.ansible/tmp/ansible-1382542803.71-32171941018328 && chmod a+rx $HOME/.ansible/tmp/ansible-1382542803.71-32171941018328 && echo $HOME/.ansible/tmp/ansible-1382542803.71-32171941018328’]  
\<127.0.0.1\> REMOTE\_MODULE rds command=facts instance\_name=mydb region=us-east-1  
\<127.0.0.1\> PUT /tmp/tmp6fQTde TO /home/nicolasg/.ansible/tmp/ansible-1382542803.71-32171941018328/rds  
\<127.0.0.1\> EXEC [‘/bin/sh’, ‘-c’, ‘/usr/bin/python /home/nicolasg/.ansible/tmp/ansible-1382542803.71-32171941018328/rds; rm -rf /home/nicolasg/.ansible/tmp/ansible-1382542803.71-32171941018328/ \>/dev/null 2\>&1’]  
changed: [localhost] =\> {“changed”: true, “instance”: {“availability\_zone”: “us-east-1b”, “backup\_retention”: “1”, “backup\_window”: “06:58-07:28”, “create\_time”: “2013-10-23T15:36:15.863Z”, “endpoint”: “[mydb.cf6uoyzbegkp.us-east-1.rds.amazonaws.com](http://mydb.cf6uoyzbegkp.us-east-1.rds.amazonaws.com)”, “id”: “mydb”, “instance\_type”: “db.m1.small”, “iops”: null, “maintenance\_window”: “thu:04:51-thu:05:21”, “multi\_zone”: false, “port”: 3306, “replication\_source”: null, “status”: “available”, “username”: “root”}}

TASK: [RDS endpoint is → {{rds.endpoint}}] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost] =\> {“msg”: " RDS endpoint is → {{rds.endpoint}}"}

“”"

---

<div class="post-metadata">

**Author:** ![MB1](https://avatars.discourse-cdn.com/v4/letter/m/74df32/32.png) [@MB1](https://forum.ansible.com/u/MB1)\
**Post date:** [October 9, 2014, 6:24pm UTC](https://forum.ansible.com/t/how-to-get-ip-address-of-an-rds-instance-using-the-rds-module/13551/12 "2014-10-09T18:24:17Z")

</div>

Since it also kept me stuck for a few moments: the solution is to query rds. **instance**.endpoint instead of rds.endpoint.
