# trying to use mysql\_db same task for a mysql server and Amazon RDS

**URL:** <https://forum.ansible.com/t/trying-to-use-mysql-db-same-task-for-a-mysql-server-and-amazon-rds/13764>\
**Category:** Ansible Project\
**Created:** [October 24, 2013, 11:51am UTC](https://forum.ansible.com/t/trying-to-use-mysql-db-same-task-for-a-mysql-server-and-amazon-rds/13764 "2013-10-24T11:51:48Z")\
**Posts on this page:** 4\
**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:** [October 24, 2013, 11:51am UTC](https://forum.ansible.com/t/trying-to-use-mysql-db-same-task-for-a-mysql-server-and-amazon-rds/13764/1 "2013-10-24T11:51:48Z")

</div>

Hi,

I have the bellow task that I’m trying to modify in order to work with a MySQL server AND Amazon RDS :

“”"

- hosts: mydb  
connection: local  
user: root  
gather\_facts: false

vars\_files:

- myvars.yml

- name: import database  
mysql\_db: login\_host={{ DB\_ADDRESS }} login\_user={{ DB\_MASTER\_USERNAME }} login\_password={{ DB\_MASTER\_PASSWORD }} name=mydb state=import target=roles/dbserver/templates/mydb.sql.j2

“”"

In case of Amazon RDS this works with no problem as it’s importing the database directly from the system where I’m running Ansible (roles/dbserver/templates/mydb.sql.j2) using the “connection:local” but the problem is if I want to use the exact same task on a remote mysql server which is not RDS I can’t use the connection local. I will have first to copy the mydb.sql.j2 template to the remote system (which is not possible in case of an RDS) in order for the import to work .

Is it possible to make the import works for both cases in a single task ?

Regards,  
Nicolas.

---

<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 25, 2013, 1:10pm UTC](https://forum.ansible.com/t/trying-to-use-mysql-db-same-task-for-a-mysql-server-and-amazon-rds/13764/2 "2013-10-25T13:10:08Z")

</div>

“I will have first to copy the mydb.sql.j2 template to the remote system (which is not possible in case of an RDS) in order for the import to work .”

Yep, you’d just have to add the template step.

---

<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 25, 2013, 2:20pm UTC](https://forum.ansible.com/t/trying-to-use-mysql-db-same-task-for-a-mysql-server-and-amazon-rds/13764/3 "2013-10-25T14:20:57Z")

</div>

But if I do it will fail in case of an RDS .

---

<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 25, 2013, 11:43pm UTC](https://forum.ansible.com/t/trying-to-use-mysql-db-same-task-for-a-mysql-server-and-amazon-rds/13764/4 "2013-10-25T23:43:11Z")

</div>

Sounds like you need a when statement to decide if it’s an RDS or not and skip that step maybe?
