From abd0bb9d0edc096c7f45aa14029fdd75ef4d7b1a Mon Sep 17 00:00:00 2001 From: jurgenhaas <juergen@paragon-es.de> Date: Sat, 23 Jan 2021 14:14:53 +0100 Subject: [PATCH] gitlab-ci-cd/drupal#2 Add new deploy mode artefact --- tasks/deploy/artefact.yml | 25 +++++++++++++++++ tasks/finalize/artefact.yml | 16 +++++++++++ .../finalize_d6.yml => finalize/d6.yml} | 2 +- .../finalize_d7.yml => finalize/d7.yml} | 2 +- .../finalize_d8.yml => finalize/d8.yml} | 2 +- tasks/install.yml | 27 +++++++++++++------ tasks/install/artefact.yml | 6 +++++ tasks/users/artefact.yml | 6 +++++ 8 files changed, 75 insertions(+), 11 deletions(-) create mode 100644 tasks/deploy/artefact.yml create mode 100644 tasks/finalize/artefact.yml rename tasks/{deploy/finalize_d6.yml => finalize/d6.yml} (50%) rename tasks/{deploy/finalize_d7.yml => finalize/d7.yml} (50%) rename tasks/{deploy/finalize_d8.yml => finalize/d8.yml} (97%) create mode 100644 tasks/install/artefact.yml create mode 100644 tasks/users/artefact.yml diff --git a/tasks/deploy/artefact.yml b/tasks/deploy/artefact.yml new file mode 100644 index 0000000..002f2ad --- /dev/null +++ b/tasks/deploy/artefact.yml @@ -0,0 +1,25 @@ +--- +# file: roles/drupal/tasks/deploy/artefact.yml + +- block: + + - name: Ensure Repository Directory + file: + path: '{{ tempDeployRoot }}' + state: directory + owner: root + group: root + mode: u+rwX,g+rwX,o+rX + recurse: yes + follow: no + + - name: Create .env file + template: + src: env.jinja2 + dest: '{{ tempDeployRoot }}/.env' + owner: root + group: root + when: drupal.env is defined + + tags: + - deploy diff --git a/tasks/finalize/artefact.yml b/tasks/finalize/artefact.yml new file mode 100644 index 0000000..acb8c85 --- /dev/null +++ b/tasks/finalize/artefact.yml @@ -0,0 +1,16 @@ +--- +# file: roles/drupal/tasks/finalize/artefact.yml + +- name: Move directories + command: mv /path/to/foo /path/to/bar + with_items: + - src: '{{ webRoot }}/files' + dest: '{{ tempDeployRoot }}' + - src: '{{ webRoot }}/settings' + dest: '{{ tempDeployRoot }}' + - src: '{{ webRoot }}/web/sites/default' + dest: '{{ tempDeployRoot }}/web/sites' + - src: '{{ webRoot }}' + dest: '{{ webRoot }}-old' + - src: '{{ tempDeployRoot }}' + dest: '{{ webRoot }}' diff --git a/tasks/deploy/finalize_d6.yml b/tasks/finalize/d6.yml similarity index 50% rename from tasks/deploy/finalize_d6.yml rename to tasks/finalize/d6.yml index 364296f..9758474 100644 --- a/tasks/deploy/finalize_d6.yml +++ b/tasks/finalize/d6.yml @@ -1,5 +1,5 @@ --- -# file: roles/drupal/tasks/deploy/finalize_d6.yml +# file: roles/drupal/tasks/finalize/d6.yml - name: Set facts set_fact: diff --git a/tasks/deploy/finalize_d7.yml b/tasks/finalize/d7.yml similarity index 50% rename from tasks/deploy/finalize_d7.yml rename to tasks/finalize/d7.yml index bb46fa8..c257f23 100644 --- a/tasks/deploy/finalize_d7.yml +++ b/tasks/finalize/d7.yml @@ -1,5 +1,5 @@ --- -# file: roles/drupal/tasks/deploy/finalize_d7.yml +# file: roles/drupal/tasks/finalize/d7.yml - name: Set facts set_fact: diff --git a/tasks/deploy/finalize_d8.yml b/tasks/finalize/d8.yml similarity index 97% rename from tasks/deploy/finalize_d8.yml rename to tasks/finalize/d8.yml index 8568270..5cf6bad 100644 --- a/tasks/deploy/finalize_d8.yml +++ b/tasks/finalize/d8.yml @@ -1,5 +1,5 @@ --- -# file: roles/drupal/tasks/deploy/finalize_d8.yml +# file: roles/drupal/tasks/finalize/d8.yml - block: diff --git a/tasks/install.yml b/tasks/install.yml index 5da935b..96d8002 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -37,6 +37,10 @@ filesRoot: '{{ drupalRoot }}/sites' settingsRoot: '{{ drupalRoot }}/sites' when: not drupal.files_outside_root|default(true) + - name: Set facts for artefact mode + set_fact: + tempDeployRoot: '{{ webRoot }}-{{ lookup("pipe","date +%Y-%m-%d-%H-%M-%S") }}' + when: installSource.mode|default("none") == 'artefact' tags: - always @@ -58,6 +62,7 @@ follow: no tags: - deploy + when: installSource.mode|default("none") == 'artefact' - name: Check Installation Requirement shell: ls {{ drupalRoot }}/index.php @@ -95,6 +100,14 @@ tags: - deploy +- name: Copy Artefacts + copy: + src: '{{ DRUPAL_ARTEFACT_SRC }}/' + dest: '{{ (installSource.mode|default("none") == "artefact")|ternary(tempDeployRoot,webRoot) }}/' + when: DRUPAL_ARTEFACT_SRC is defined + tags: + - deploy + - name: Ensure links file: src: '{{ webRoot }}{{ item.src }}' @@ -254,17 +267,15 @@ - deploy when: drush_version_main|default('8') == '9' -- name: Include deploy finalize version - include_tasks: deploy/finalize_{{ drupal.version|default("d7") }}.yml - when: drupal_install_drupal +- name: Include finalize mode + include_tasks: finalize/{{ installSource.mode|default("none") }}.yml + when: drupal_install_drupal and installSource.mode|default("none") == 'artefact' tags: - deploy -- name: Copy Artefacts - copy: - src: '{{ DRUPAL_ARTEFACT_SRC }}/' - dest: '{{ webRoot }}/' - when: DRUPAL_ARTEFACT_SRC is defined +- name: Include finalize version + include_tasks: finalize/{{ drupal.version|default("d7") }}.yml + when: drupal_install_drupal tags: - deploy diff --git a/tasks/install/artefact.yml b/tasks/install/artefact.yml new file mode 100644 index 0000000..64bafab --- /dev/null +++ b/tasks/install/artefact.yml @@ -0,0 +1,6 @@ +--- +# file: roles/drupal/tasks/install/artefact.yml + +- name: Set facts + set_fact: + dummy: yes diff --git a/tasks/users/artefact.yml b/tasks/users/artefact.yml new file mode 100644 index 0000000..28f4e9f --- /dev/null +++ b/tasks/users/artefact.yml @@ -0,0 +1,6 @@ +--- +# file: roles/drupal/tasks/users/artefact.yml + +- name: Set facts + set_fact: + dummy: yes -- GitLab