Skip to content
Snippets Groups Projects
Commit 622c5059 authored by jurgenhaas's avatar jurgenhaas
Browse files

customer/bitegra/mobimo/drupal#22 Implement feature to download db dump

parent 137c8c6e
No related branches found
No related tags found
No related merge requests found
---
# file: roles/drupal/tasks/collect_db_dump/dump.yml
- block:
- set_fact:
drushAlias='@{{ drupal.id }}.{{ drupal_domain.shortname|default("default") }}'
drushAliasValidate="'@{{ drupal.id }}.{{ drupal_domain.shortname|default('default') }}':"
- set_fact:
drushAlias='@{{ inventory_hostname }}{{ drushSubkey }}.{{ drupal_domain.shortname|default("default") }}'
drushAliasValidate='@{{ inventory_hostname }}{{ drushSubkey }}.{{ drupal_domain.shortname|default("default") }}'
when: drush_version_main|default('8') == '8'
- name: "Check Drush Status"
shell: drush -y {{ drushAlias }} status
args:
chdir: '{{ webRoot }}'
register: drush_status
changed_when: false
when: drushAliasValidate in drush_aliases.stdout_lines
- name: "Dump DB"
shell: drush -y {{ drushAlias }} sql-dump --result-file=/tmp/drupal-db-dump/{{ drushAlias }}.sql
args:
chdir: '{{ webRoot }}'
when: "drush_status is defined and ('Successful' in drush_status.stdout|default('') or 'Erfolgreich' in drush_status.stdout|default(''))"
- name: "Fetch Dump File"
fetch:
src: '/tmp/drupal-db-dump/{{ drushAlias }}.sql'
dest: '{{ dump_file }}'
flat: yes
when: "drush_status is defined and ('Successful' in drush_status.stdout|default('') or 'Erfolgreich' in drush_status.stdout|default(''))"
tags: 'collect_db_dump'
---
# file: roles/drupal/tasks/collect_db_dump/main.yml
- block:
- set_fact:
webRoot='/var/www{{ drupal.webRoot|default("") }}'
cronUser='root'
apacheUser='www-data'
apacheLogDir='/var/log/apache2'
drushSubkey='{{ drupal.drush_subkey|default("") }}'
when: drupal.jail is not defined
- set_fact:
webRoot='{{ jailroot }}/{{ drupal.jail.name }}/var/www{{ drupal.webRoot|default("") }}'
cronUser='{{ drupal.jail.name }}'
apacheUser='{{ drupal.jail.name }}'
apacheLogDir='{{ jailroot }}/{{ drupal.jail.name }}/var/log/apache2'
drushSubkey='.{{ drupal.jail.name }}'
when: drupal.jail is defined
- set_fact:
installSource={{ drupal.src|default([]) }}
relativeRoot='{{ drupal.relativeRoot|default(drupal_links_relative_root) }}'
drupalRoot='{{ webRoot }}{{ drupal.root|default("") }}'
docRoot='{{ webRoot }}{{ drupal.docroot|default(drupal.root|default("")) }}'
- name: "Check available Drush Aliases"
shell: drush sa
args:
chdir: '{{ webRoot }}'
register: drush_aliases
changed_when: false
- name: "Post Deploy Tasks"
include_tasks: dump.yml
with_items: '{{ drupal.domains }}'
loop_control:
loop_var: drupal_domain
tags: 'collect_db_dump'
......@@ -47,3 +47,23 @@
tags: 'deploy'
when: '"drupal" not in excluded_roles and drupal_install_drupal and collect_config is defined and collect_config'
- block:
- name: "Prepare dump directory"
file:
path: '/tmp/drupal-db-dump'
state: '{{ item }}'
with_items:
- 'absent'
- 'directory'
- name: "Download DB Dump"
include_tasks: collect_db_dump/main.yml
with_items: '{{ drupal_settings|default([]) }}'
loop_control:
loop_var: drupal
when: limit_site is not defined or drupal.id is not defined or limit_site == drupal.id
when: '"drupal" not in excluded_roles and drupal_install_drupal and collect_db_dump is defined and collect_db_dump'
tags: 'collect_db_dump'
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment