From e7fc3f1bef4e916f0fa93998cdc87fcd7e1f15b0 Mon Sep 17 00:00:00 2001 From: "Zeno F. Pensky" Date: Tue, 14 Jan 2020 15:09:30 +0100 Subject: [PATCH] AdHoc (change) Use relative pathes for the shared folders It was discovered that deployment was failing while the server was under load. The reason was, that magento was recreating the shared folders between the deletion and the symlinking. We move this step now to be done before the symlink is moved to the new magento deployed folder. This is also saving some downtime in the deployment. *##################### *## Breaking Change ## *##################### This includes a backwards incompatible change. As the targets for the shared folders needs now to be defined relative to the application root folder. Absolute pathes are not possible anymore. --- defaults/main.yml | 3 ++- tasks/installation.yml | 47 +++++++++++++++++++++--------------------- templates/logrotate.j2 | 1 + 3 files changed, 26 insertions(+), 25 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 6a6da0f..f35ba22 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -88,7 +88,8 @@ magento_cron_tasks: ## A list of folders that contain content that should persist through releases. magento_shared_folders: [] ## Directories are defined in key -> value pairs, where the "src" is the directory that contains the content, and -## "dest" is where it should exist in Magento. If the source directories do not exist, they are created. +## "dest" is where it should exist in Magento. The dest is relative to to the release folder of magento. +## If the source directories do not exist, they are created. # - src: # dest: ## State can be any of the ansible file states, but defaults to directory diff --git a/tasks/installation.yml b/tasks/installation.yml index 75b500c..a0cc06d 100644 --- a/tasks/installation.yml +++ b/tasks/installation.yml @@ -98,27 +98,6 @@ group: "{{ magento_group }}" mode: "u=rw,g=,o=" -- name: "Enable maintenance mode" - file: - path: "{{ magento_release_folder }}/{{ magento_release_version }}/var/.maintenance.flag" - owner: "{{ magento_user }}" - group: "{{ magento_group }}" - state: "touch" - when: - - magento_skip_release == False - -- name: "Release the application" - file: - src: "{{ magento_release_folder }}/{{ magento_release_version }}" - force: "yes" - path: "{{ magento_app_root }}" - owner: "{{ magento_user }}" - group: "{{ magento_group }}" - state: "link" - register: "magento_release_updated" - when: - - magento_skip_release == False - - name: "Ensure the source content exists" file: path: "{{ item.src }}" @@ -136,7 +115,7 @@ # where "sitewards/path/to" does not exist. - name: "Ensure the destination container directories exist" file: - path: "{{ item.dest | dirname }}" + path: "{{ magento_release_folder }}/{{ magento_release_version }}/{{ item.dest | dirname }}" state: "directory" owner: "{{ magento_user }}" group: "{{ magento_group }}" @@ -147,19 +126,39 @@ - name: "Delete the destinations if they exist" file: - path: "{{ item.dest }}" + path: "{{ magento_release_folder }}/{{ magento_release_version }}/{{ item.dest }}" state: "absent" with_items: "{{ magento_shared_folders }}" - name: "Ensure the symlinks for the shared content exist" file: src: "{{ item.src }}" - path: "{{ item.dest }}" + path: "{{ magento_release_folder }}/{{ magento_release_version }}/{{ item.dest }}" owner: "{{ magento_user }}" group: "{{ magento_group }}" state: "{{ item.state | default('link') }}" with_items: "{{ magento_shared_folders }}" +- name: "Enable maintenance mode" + file: + path: "{{ magento_release_folder }}/{{ magento_release_version }}/var/.maintenance.flag" + owner: "{{ magento_user }}" + group: "{{ magento_group }}" + state: "touch" + when: + - magento_skip_release == False + +- name: "Release the application" + file: + src: "{{ magento_release_folder }}/{{ magento_release_version }}" + force: "yes" + path: "{{ magento_app_root }}" + owner: "{{ magento_user }}" + group: "{{ magento_group }}" + state: "link" + register: "magento_release_updated" + when: + - magento_skip_release == False - name: "Reload the PHP runtime" service: name: "{{ magento_php_service }}" diff --git a/templates/logrotate.j2 b/templates/logrotate.j2 index 2ef7d03..c030097 100644 --- a/templates/logrotate.j2 +++ b/templates/logrotate.j2 @@ -1,3 +1,4 @@ +#/var/www/html/var/log/*log { {{ magento_app_root }}/var/log/*log { weekly rotate 12