diff --git a/docs/roles/_init.md b/docs/roles/_init.md index edf1f5d3..8118c9ea 100644 --- a/docs/roles/_init.md +++ b/docs/roles/_init.md @@ -34,9 +34,17 @@ drupal: cron: - minute: "*/{{ 10 | random(start=1) }}" job: cron + feature_branch: false # whether or not this build is a feature branch that should sync assets from another environment + # For syncing database and files on a feature branch initial build + mysql_sync: # see sync/database_sync for docs + databases: [] + files_sync: # see sync/files_sync for docs + cleanup: true + directories: [] mautic: image_path: "media/images" force_install: false +# Used for custom build time tools like cachetool bin_directory: "/home/{{ deploy_user }}/.bin" # Number of dumps/db to look up for cleanup. cleanup_history_depth: 50 diff --git a/docs/roles/sync/database_sync/database_sync-mysql.md b/docs/roles/sync/database_sync/database_sync-mysql.md index d70d770e..c0c2954b 100644 --- a/docs/roles/sync/database_sync/database_sync-mysql.md +++ b/docs/roles/sync/database_sync/database_sync-mysql.md @@ -7,7 +7,7 @@ Sync MySQL databases between environments. mysql_sync: mysqldump_params: "{{ _mysqldump_params }}" # set in _init but you can override here. cleanup: true # if false leaves tmp database dump on deploy server for debugging purposes. - archival_method: "bzip2" # oprions are "bzip2" or "gzip". + archival_method: "gzip" # oprions are "bzip2" or "gzip". databases: - source: # Name of the database to take a dump from. diff --git a/roles/_init/README.md b/roles/_init/README.md index edf1f5d3..8118c9ea 100644 --- a/roles/_init/README.md +++ b/roles/_init/README.md @@ -34,9 +34,17 @@ drupal: cron: - minute: "*/{{ 10 | random(start=1) }}" job: cron + feature_branch: false # whether or not this build is a feature branch that should sync assets from another environment + # For syncing database and files on a feature branch initial build + mysql_sync: # see sync/database_sync for docs + databases: [] + files_sync: # see sync/files_sync for docs + cleanup: true + directories: [] mautic: image_path: "media/images" force_install: false +# Used for custom build time tools like cachetool bin_directory: "/home/{{ deploy_user }}/.bin" # Number of dumps/db to look up for cleanup. cleanup_history_depth: 50 diff --git a/roles/_init/defaults/main.yml b/roles/_init/defaults/main.yml index 57ee7e44..2fad2e47 100644 --- a/roles/_init/defaults/main.yml +++ b/roles/_init/defaults/main.yml @@ -25,9 +25,17 @@ drupal: cron: - minute: "*/{{ 10 | random(start=1) }}" job: cron + feature_branch: false # whether or not this build is a feature branch that should sync assets from another environment + # For syncing database and files on a feature branch initial build + mysql_sync: # see sync/database_sync for docs + databases: [] + files_sync: # see sync/files_sync for docs + cleanup: true + directories: [] mautic: image_path: "media/images" force_install: false +# Used for custom build time tools like cachetool bin_directory: "/home/{{ deploy_user }}/.bin" # Number of dumps/db to look up for cleanup. cleanup_history_depth: 50 diff --git a/roles/database_apply/database_apply-drupal8/tasks/main.yml b/roles/database_apply/database_apply-drupal8/tasks/main.yml index c423fad9..7faf684f 100644 --- a/roles/database_apply/database_apply-drupal8/tasks/main.yml +++ b/roles/database_apply/database_apply-drupal8/tasks/main.yml @@ -25,6 +25,32 @@ when: (previous_build_number == 0) or (site.force_install is defined and site.force_install) register: _drush_output +- name: Sync database. + ansible.builtin.import_role: + name: sync/database_sync + vars: + mysql_sync: "{{ site.mysql_sync }}" + with_items: "{{ drupal.sites }}" + loop_control: + loop_var: site + when: + - (previous_build_number == 0) or (site.force_install is defined and site.force_install) + - site.feature_branch | default(false) + - site.mysql_sync | length > 0 + +- name: Sync files. + ansible.builtin.import_role: + name: sync/files_sync + vars: + files_sync: "{{ site.files_sync }}" + with_items: "{{ drupal.sites }}" + loop_control: + loop_var: site + when: + - (previous_build_number == 0) or (site.force_install is defined and site.force_install) + - site.feature_branch | default(false) + - site.files_sync | length > 0 + - name: Show drush output. ansible.builtin.debug: msg: "{{ _drush_output }}" diff --git a/roles/sync/database_sync/database_sync-mysql/README.md b/roles/sync/database_sync/database_sync-mysql/README.md index d70d770e..c0c2954b 100644 --- a/roles/sync/database_sync/database_sync-mysql/README.md +++ b/roles/sync/database_sync/database_sync-mysql/README.md @@ -7,7 +7,7 @@ Sync MySQL databases between environments. mysql_sync: mysqldump_params: "{{ _mysqldump_params }}" # set in _init but you can override here. cleanup: true # if false leaves tmp database dump on deploy server for debugging purposes. - archival_method: "bzip2" # oprions are "bzip2" or "gzip". + archival_method: "gzip" # oprions are "bzip2" or "gzip". databases: - source: # Name of the database to take a dump from.