File tree Expand file tree Collapse file tree 4 files changed +36
-5
lines changed
database_sync/database_sync-mysql Expand file tree Collapse file tree 4 files changed +36
-5
lines changed Original file line number Diff line number Diff line change 1
1
---
2
2
mysql_sync :
3
3
mysqldump_params : " {{ _mysqldump_params }}" # set in _init but you can override here
4
+ cleanup : true # if false leaves tmp database dump on deploy server for debugging purposes
4
5
databases :
5
6
- source :
6
7
# Name of the database to take a dump from.
Original file line number Diff line number Diff line change 104
104
delegate_to : localhost
105
105
when : database.target.type == 'rolling'
106
106
107
- - name : Register target database name.
107
+ - name : Register target rolling database name.
108
108
ansible.builtin.set_fact :
109
109
mysql_sync_target_database : " {{ database.target.database }}_{{ mysql_sync_target_build_number.stdout }}"
110
110
when : database.target.type == 'rolling'
111
111
112
- - name : Register target database name.
112
+ - name : Register target static database name.
113
113
ansible.builtin.set_fact :
114
114
mysql_sync_target_database : " {{ database.target.database }}"
115
115
when : not database.target.type == 'rolling'
139
139
args :
140
140
executable : /bin/bash
141
141
142
- - name : Remove tmp dump file.
142
+ - name : Delete temporary dump file on target .
143
143
ansible.builtin.file :
144
144
path : " {{ mysql_sync_target_dump_path }}"
145
145
state : absent
146
146
147
+ - name : Delete temporary dump file on source.
148
+ ansible.builtin.file :
149
+ path : " {{ mysql_sync_source_dump_path }}"
150
+ state : absent
151
+ delegate_to : " {{ database.source.host }}"
152
+
153
+ - name : Delete temporary dump file on deploy server.
154
+ ansible.builtin.file :
155
+ path : " {{ _ce_deploy_build_tmp_dir }}/{{ database.target.database }}.sql.bz2"
156
+ state : absent
157
+ delegate_to : localhost
158
+ when :
159
+ - mysql_sync.cleanup
160
+
147
161
- name : Enable all autoscale processes on source ASG.
148
162
ansible.builtin.command : >
149
163
aws autoscaling resume-processes --auto-scaling-group-name {{ database.source.asg }} --region {{ mysql_sync_source_database_host_info.ansible_facts.ansible_ec2_instance_identity_document_region }}
Original file line number Diff line number Diff line change 1
1
---
2
2
files_sync :
3
+ unique_workspace : false # set to true to grab a complete full set of files every sync
4
+ # Generally speaking you will *not* want to clean up after file syncs, as leaving the files there makes the next rsync far quicker.
5
+ cleanup : false # set to true to delete the synced files after a sync
3
6
directories :
4
7
- source :
5
8
# Location of the files to sync from. DO NOT INCLUDE TRAILING SLASH!
Original file line number Diff line number Diff line change 1
1
---
2
2
- name : Register file sync location.
3
+ ansible.builtin.set_fact :
4
+ file_sync_path : " {{ files.source.temp_dir }}/{{ files.source.build_id }}"
5
+
6
+ - name : Register unique file sync location.
3
7
ansible.builtin.set_fact :
4
8
file_sync_path : " {{ files.source.temp_dir }}/{{ files.source.build_id }}_{{ build_number }}"
9
+ when : files_sync.unique_workspace
5
10
6
11
- name : Create a temporary directory for source files on localhost.
7
12
ansible.builtin.file :
15
20
- name : Copy the source files onto the deploy server.
16
21
ansible.builtin.command :
17
22
cmd : " rsync -e 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' -aHPv {{ files.source.host }}:{{ files.source.files_dir }}/ {{ file_sync_path }}/"
18
- delegate_to : " localhost"
23
+ delegate_to : localhost
19
24
run_once : true
20
25
21
26
- name : Copy the source files from the deploy server onto the destination server.
22
27
ansible.builtin.command :
23
28
cmd : " rsync -e 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' -aHPv {{ file_sync_path }}/ {{ ansible_play_hosts[0] }}:{{ files.target.files_dir }}/"
24
- delegate_to : " localhost"
29
+ delegate_to : localhost
25
30
run_once : true
31
+
32
+ - name : Delete synced files on deploy server.
33
+ ansible.builtin.file :
34
+ path : " {{ file_sync_path }}"
35
+ state : absent
36
+ delegate_to : localhost
37
+ when :
38
+ - files_sync.cleanup
You can’t perform that action at this time.
0 commit comments