diff --git a/defaults/main.yml b/defaults/main.yml index c30c169..71065c2 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -326,3 +326,19 @@ magento_force_reindex_on_deploy: False # and more # and more # and more + +# allows to run deletion of old clones folders asynchronously, +# this allows pipeline to finish faster due to "parallel" execution of tasks +# when clones are cleaned up asynchronously, role is not checking successful execution +magento_allow_async_cleanup_old_clones: false + +# timeout for async old clones cleanup, seconds +magento_async_cleanup_old_clones_timeout: 600 + +# allows to run magento reindexing asynchronously, +# this allows pipeline to finish faster due to "parallel" execution of tasks +# when reindexing is done asynchronously, role is not checking successful execution +magento_allow_async_reindex: false + +# timeout for async reindex execution, seconds +magento_async_reindex_timeout: 600 diff --git a/tasks/cleanup-old-clones.yml b/tasks/cleanup-old-clones.yml index 0b7ead3..6d4886e 100644 --- a/tasks/cleanup-old-clones.yml +++ b/tasks/cleanup-old-clones.yml @@ -7,9 +7,18 @@ age_stamp: "ctime" register: magento_clones_for_cleanup -- name: "Remove old clones/releases" +- name: "Remove old clones/releases asynchronously" file: path: "{{ item.path }}" state: absent - when: magento_cleanup_old_clones == True + when: magento_cleanup_old_clones and magento_allow_async_cleanup_old_clones + with_items: "{{ (magento_clones_for_cleanup.files | sort(attribute='ctime', reverse=True))[magento_clones_to_keep:] | list }}" + async: "{{ magento_async_cleanup_old_clones_timeout }}" + poll: 0 + +- name: "Remove old clones/releases synchronously" + file: + path: "{{ item.path }}" + state: absent + when: magento_cleanup_old_clones and (not magento_allow_async_cleanup_old_clones) with_items: "{{ (magento_clones_for_cleanup.files | sort(attribute='ctime', reverse=True))[magento_clones_to_keep:] | list }}" diff --git a/tasks/installation.yml b/tasks/installation.yml index 3a83e50..a0266b6 100644 --- a/tasks/installation.yml +++ b/tasks/installation.yml @@ -216,11 +216,19 @@ become_user: "{{ magento_user }}" command: "/usr/bin/php {{ magento_app_root }}/bin/magento cache:flush" -- name: "Let Magento indexer run" +- name: "Let Magento indexer run asynchronously" become: "yes" become_user: "{{ magento_user }}" command: "/usr/bin/php {{ magento_app_root }}/bin/magento indexer:reindex" - when: magento_db_status.stdout_lines|length == 0 or magento_force_reindex_on_deploy == True + when: (magento_db_status.stdout_lines|length == 0 or magento_force_reindex_on_deploy == True) and magento_allow_async_reindex + async: "{{ magento_async_reindex_timeout }}" + poll: 0 + +- name: "Let Magento indexer run synchronously" + become: "yes" + become_user: "{{ magento_user }}" + command: "/usr/bin/php {{ magento_app_root }}/bin/magento indexer:reindex" + when: (magento_db_status.stdout_lines|length == 0 or magento_force_reindex_on_deploy == True) and (not magento_allow_async_reindex) - name: "Disable maintenance mode" file: