Skip to content

Instantly share code, notes, and snippets.

@Inderpreet90
Last active October 1, 2021 11:08
Show Gist options
  • Save Inderpreet90/a79f40af7cce42d53ae27760a43ac40d to your computer and use it in GitHub Desktop.
Save Inderpreet90/a79f40af7cce42d53ae27760a43ac40d to your computer and use it in GitHub Desktop.
- name: Import MySQL database
hosts: dbhost
tasks:
- name: Start database import
## Assuming we already have a cnf file created with DB credentials.
shell: "mysql {{ MYSQL_DATABASE }} < /backups/database_dump.sql"
async: 2100
poll: 0
register: import_db
## Some other tasks which are irrelevant to the database import
- name: TASK1
...
...
- name: TASK2
...
...
- name: TASK3
...
...
- name: Check if database import is complete
async_status:
jid: "{{ import_db.ansible_job_id }}"
register: job_result
until: job_result.finished
delay: 10
retries: 300
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment