Skip to content
Snippets Groups Projects
Commit 1335ff4c authored by jurgenhaas's avatar jurgenhaas
Browse files

New script to download Drupal asset archive

parent 49ed670a
No related branches found
No related tags found
No related merge requests found
---
# file: roles/drupal/tasks/collect_db_dump/dump.yml
# file: roles/drupal/tasks/collect_download/collect.yml
- block:
......@@ -21,18 +21,41 @@
changed_when: no
when: drushAliasValidate in drush_aliases.stdout_lines
- name: Set collect filename for db-dump
set_fact:
collectFilename: '{{ drushAlias }}.sql'
when: collectTask == 'db'
- name: Dump DB
shell: drush -y {{ drushAlias }} sql-dump --result-file=/tmp/drupal-db-dump/{{ drushAlias }}.sql
shell: drush -y {{ drushAlias }} sql-dump --result-file={{ collectPath }}/{{ collectFilename }}
args:
chdir: '{{ webRoot }}'
when: drush_status is defined and ('Successful' in drush_status.stdout|default('') or 'Erfolgreich' in drush_status.stdout|default(''))
when: collectTask == 'db' and drush_status is defined and ('Successful' in drush_status.stdout|default('') or 'Erfolgreich' in drush_status.stdout|default(''))
- name: Set collect filename for asset-archive
set_fact:
collectFilename: '{{ drushAlias }}.zip'
when: collectTask == 'assets'
- name: Copy files
shell: drush -y rsync {{ drushAlias }}:%files {{ collectPath }}/ --exclude-paths=config:css:js:languages:media-icons:php:styles:translations
args:
chdir: '{{ webRoot }}'
when: collectTask == 'assets' and drush_status is defined and ('Successful' in drush_status.stdout|default('') or 'Erfolgreich' in drush_status.stdout|default(''))
- name: Copy files
shell: zip -r {{ collectPath }}/{{ collectFilename }} ./*
args:
chdir: '{{ collectPath }}'
when: collectTask == 'assets' and drush_status is defined and ('Successful' in drush_status.stdout|default('') or 'Erfolgreich' in drush_status.stdout|default(''))
- name: Fetch Dump File
- name: Fetch File
fetch:
src: /tmp/drupal-db-dump/{{ drushAlias }}.sql
dest: '{{ dump_file }}'
src: '{{ collectPath }}/{{ collectFilename }}'
dest: '{{ download_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
- collect_asset_archive
---
# file: roles/drupal/tasks/collect_db_dump/main.yml
# file: roles/drupal/tasks/collect_download/main.yml
- block:
......@@ -25,6 +25,7 @@
relativeRoot: '{{ drupal.relativeRoot|default(drupal_links_relative_root) }}'
drupalRoot: '{{ webRoot }}{{ drupal.root|default("") }}'
docRoot: '{{ webRoot }}{{ drupal.docroot|default(drupal.root|default("")) }}'
collectPath: '/tmp/drupal-collect/{{ drupal.id }}/{{ collectTask }}'
- name: Check available Drush Aliases
shell: drush sa
......@@ -33,11 +34,20 @@
register: drush_aliases
changed_when: no
- name: Post Deploy Tasks
include_tasks: dump.yml
- name: Prepare directory
file:
path: '{{ collectPath }}'
state: '{{ item }}'
with_items:
- absent
- directory
- name: Collect
include_tasks: 'collect.yml'
with_items: '{{ drupal.domains }}'
loop_control:
loop_var: drupal_domain
tags:
- collect_db_dump
- collect_asset_archive
......@@ -54,21 +54,24 @@
- 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
- name: Set collect task for db-dump
set_fact:
collectTask: 'db'
tags:
- collect_db_dump
- name: Set collect task for asset-archive
set_fact:
collectTask: 'assets'
tags:
- collect_asset_archive
- name: Collect and Download
include_tasks: collect_download/main.yml
with_items: '{{ drupal_settings|default([]) }}'
loop_control:
loop_var: drupal
when: limit_site is not defined or limit_site == 'no' or drupal.id is not defined or limit_site == drupal.id
tags:
- collect_db_dump
- collect_asset_archive
when: (not excluded_roles or "drupal" not in excluded_roles) and drupal_install_drupal and collect_db_dump is defined and collect_db_dump
tags:
- collect_db_dump
when: (not excluded_roles or "drupal" not in excluded_roles) and drupal_install_drupal and collect_download is defined and collect_download
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