From 035434811ecd38ebb15f3565b3b72087685bdc44 Mon Sep 17 00:00:00 2001 From: Anton Boritskiy Date: Thu, 22 Aug 2019 21:34:10 +0100 Subject: [PATCH 1/2] AHOC feat (installation): let indexer run it is important to run magento indexer upon installation, cause it fills index tables with initial data, it also fills elasticsearch on the first run. Without running indexer magento is not fully operational after first deploy. --- tasks/installation.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tasks/installation.yml b/tasks/installation.yml index e377671..69ece52 100644 --- a/tasks/installation.yml +++ b/tasks/installation.yml @@ -211,6 +211,11 @@ become_user: "{{ magento_user }}" command: "/usr/bin/php {{ magento_app_root }}/bin/magento cache:flush" +- name: "Let Magento indexer run" + become: "yes" + become_user: "{{ magento_user }}" + command: "/usr/bin/php {{ magento_app_root }}/bin/magento indexer:reindex" + - name: "Disable maintenance mode" file: path: "{{ magento_release_folder }}/{{ magento_release_version }}/var/.maintenance.flag" From 0a9fc7f3eedd537d5bade2fc606297b662a76491 Mon Sep 17 00:00:00 2001 From: Anton Boritskiy Date: Thu, 29 Aug 2019 19:18:58 +0100 Subject: [PATCH 2/2] AHOC feat (installation): let indexer run making indexer run optional and allowing user to control it, cause on big and mature installations indexer might take substantial time to run and that might seriously increase deployment time and also cause some other issues, like sudden high server load and eventual degradation of service for users. --- defaults/main.yml | 5 +++++ tasks/installation.yml | 1 + 2 files changed, 6 insertions(+) diff --git a/defaults/main.yml b/defaults/main.yml index e333fe5..d6a873d 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -297,3 +297,8 @@ magento_queue_consumers_cron_template: "/usr/bin/php {{ magento_app_root }}/bin/ magento_cleanup_old_clones: True magento_clones_to_keep: 5 magento_clones_cleanup_min_age: "1d" + +## Enforces indexer run on every deploy +## by default indexer will run only in case database was created from scratch. +## In case you need to refresh indexes on deploy (e.g. to fill search index) - set this to true. +magento_force_reindex_on_deploy: False diff --git a/tasks/installation.yml b/tasks/installation.yml index 69ece52..0fd5592 100644 --- a/tasks/installation.yml +++ b/tasks/installation.yml @@ -215,6 +215,7 @@ 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 - name: "Disable maintenance mode" file: