Skip to content

Commit

Permalink
AdHoc (change) Use relative pathes for the shared folders
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
toxix committed Jan 14, 2020
1 parent c7409c1 commit e7fc3f1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 25 deletions.
3 changes: 2 additions & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
47 changes: 23 additions & 24 deletions tasks/installation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand All @@ -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 }}"
Expand All @@ -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 }}"
Expand Down
1 change: 1 addition & 0 deletions templates/logrotate.j2
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#/var/www/html/var/log/*log {
{{ magento_app_root }}/var/log/*log {
weekly
rotate 12
Expand Down

0 comments on commit e7fc3f1

Please sign in to comment.