Skip to content

Commit

Permalink
Merge pull request #6 from sitewards/ADHOC-add-old-clone-cleanup
Browse files Browse the repository at this point in the history
ADHOC feat (cleaup): auto-cleanup
  • Loading branch information
aboritskiy authored Aug 22, 2019
2 parents c29200f + 5a09b7d commit b9e6368
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
7 changes: 7 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -290,3 +290,10 @@ magento_upgrade_commands:
magento_run_message_queue_consumers_separately: false

magento_queue_consumers_cron_template: "/usr/bin/php {{ magento_app_root }}/bin/magento queue:consumers:start {{ item.name }}"

## Deletes all installed deployable magento packages except the
## %magento_clones_to_keep% amount of latest ones + all that are newer than
## %magento_clones_cleanup_min_age%
magento_cleanup_old_clones: True
magento_clones_to_keep: 5
magento_clones_cleanup_min_age: "1d"
15 changes: 15 additions & 0 deletions tasks/cleanup-old-clones.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
- name: "Discover old clone/release directories which need to be cleaned"
find:
paths: "{{ magento_release_folder }}"
age: "{{ magento_clones_cleanup_min_age }}"
file_type: directory
age_stamp: "ctime"
register: magento_clones_for_cleanup

- name: "Remove old clones/releases"
file:
path: "{{ item.path }}"
state: absent
when: magento_cleanup_old_clones == True
with_items: "{{ (magento_clones_for_cleanup.files | sort(attribute='ctime', reverse=True))[magento_clones_to_keep:] | list }}"
1 change: 1 addition & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
- include: "setup.yml"
- include: "installation.yml"
- include: "message-queue-consumers.yml"
- include: "cleanup-old-clones.yml"
- include: "admin.yml"

0 comments on commit b9e6368

Please sign in to comment.