-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathload-db-dump.yml
36 lines (27 loc) · 1.2 KB
/
load-db-dump.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
---
# Copy an existing database to etherpad server and imports it to the database.
# The database needs to be compressed with bzip2.
# The following extra variables needs to be passed in:
# - hosts : the
# - db_dump_url : the URL to the database dump that is compressed using bzip2
# And you need to put db_name, db_user and db_password in vars/credentials.yml
- hosts: $host
user: $user
sudo: yes
tasks:
- name: stop etherpad-lite
service: name=etherpad-lite state=stopped
- name: dump database
mysql_db: name=$db_name login_user=$db_user login_password=$db_password state=dump target=/tmp/mysql-$db_name.sql
- name: copy existing database to remote server
get_url: url=$db_dump_url dest=/tmp/etherpad.sql.bz2
- name: uncompress database dump
command: /bin/bunzip2 /tmp/etherpad.sql.bz2 creates=/tmp/etherpad.sql
- name: import database
mysql_db: name=$db_name login_user=$db_user login_password=$db_password state=import target=/tmp/etherpad.sql
- name: start etherpad-lite
service: name=etherpad-lite state=started
- name: remove database dump
file: path=/tmp/etherpad.sql state=absent
- name: remove database backup
file: path=/tmp/mysql-$db_name.sql state=absent