# Import sql script to rds database

**URL:** <https://forum.ansible.com/t/import-sql-script-to-rds-database/31693>\
**Category:** Ansible Developer\
**Tags:** aws\
**Created:** [November 20, 2019, 2:06pm UTC](https://forum.ansible.com/t/import-sql-script-to-rds-database/31693 "2019-11-20T14:06:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Biraj\_Sahu](https://avatars.discourse-cdn.com/v4/letter/b/b9e5f3/32.png) [@Biraj\_Sahu](https://forum.ansible.com/u/Biraj_Sahu)\
**Post date:** [November 20, 2019, 2:06pm UTC](https://forum.ansible.com/t/import-sql-script-to-rds-database/31693/1 "2019-11-20T14:06:24Z")

</div>

Hello Friends,  
I am in need of some help in ansible.

I am pretty new to ansible and I want to achieve the following as part of my work:

- As part of regular deployment of our application, we would have a sql script(which would alert tables, add tables etc) which needs to be run on say 3 schema in a region and 5 schema in another. The application is in aws and the database is arora db(RDS). My problem is I am not sure how do I parametrize to make it run on each schema, first one after the other and then can upgrade that to run in parallel.

I did the following in a playbook:

- hosts: localhost

vars:  
script\_file: “{{ path }}”  
tasks:

- name: rds\_manage\_user - run .sql script to alert and create new tables  
shell: “mysql -h {{ item.host }} -u {{ item.user }} -p{{ item.password }} \< {{ script\_file }} \>\> /usr/local/testscript.log”  
with\_items:
- { host: [testhost1.com](http://testhost1.com), user: testuser1, password: “testpass1” }
- { host: [testhost2.com](http://testhost2.com), user: testuser2, password: “testpass2” }

This works and I get the desired output. But how do I pass these hostname, user and password from an external file and it can run through the file and get the script executed in all schemas.

Any help/suggestions would be greatly appreciated. Thanks in advance
