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

3,421 views
Skip to first unread message

Nicolas G

unread,
Sep 25, 2013, 10:06:11 AM9/25/13
to ansible...@googlegroups.com
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) the register: new_database_facts 
but I don't know what item types can be queried.

Regards,
N.

James Cammarata

unread,
Sep 25, 2013, 11:37:39 AM9/25/13
to ansible...@googlegroups.com
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.


--
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 ansible-proje...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--

James Cammarata <jcamm...@ansibleworks.com>
Sr. Software Engineer, AnsibleWorks, Inc.
http://www.ansibleworks.com/

Nicolas G.

unread,
Sep 25, 2013, 11:46:35 AM9/25/13
to ansible...@googlegroups.com
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.


--
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/4ikSS5s9kD8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.

Nicolas G

unread,
Oct 10, 2013, 10:49:23 AM10/10/13
to ansible...@googlegroups.com
any ideas on this ? 

Michael DeHaan

unread,
Oct 10, 2013, 8:09:02 PM10/10/13
to ansible...@googlegroups.com
On what in particular?




--
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 ansible-proje...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Michael DeHaan <mic...@ansibleworks.com>
CTO, AnsibleWorks, Inc.
http://www.ansibleworks.com/

Nicolas G.

unread,
Oct 14, 2013, 6:03:29 AM10/14/13
to ansible...@googlegroups.com
on how can I get an RDS instance public IP 


--
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/4ikSS5s9kD8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.

Chris Shenton

unread,
Oct 18, 2013, 11:36:15 AM10/18/13
to ansible...@googlegroups.com
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.

Peter Sankauskas

unread,
Oct 18, 2013, 12:57:41 PM10/18/13
to ansible...@googlegroups.com
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.

Chris Shenton

unread,
Oct 18, 2013, 3:34:58 PM10/18/13
to ansible...@googlegroups.com
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. 

Peter Sankauskas

unread,
Oct 18, 2013, 5:30:51 PM10/18/13
to ansible...@googlegroups.com
Well, based on this:


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 :-)

--
Kind regards,
Peter Sankauskas

Nicolas G.

unread,
Oct 23, 2013, 11:47:12 AM10/23/13
to ansible...@googlegroups.com
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", "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}}"}
"""




--

MB

unread,
Oct 9, 2014, 2:24:17 PM10/9/14
to ansible...@googlegroups.com
On Wednesday, October 23, 2013 5:47:12 PM UTC+2, Nicolas G wrote:
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 }}"
"""

Since it also kept me stuck for a few moments: the solution is to query rds.instance.endpoint instead of rds.endpoint.
Reply all
Reply to author
Forward
0 new messages