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 e377671..0fd5592 100644 --- a/tasks/installation.yml +++ b/tasks/installation.yml @@ -211,6 +211,12 @@ 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" + when: magento_db_status.stdout_lines|length == 0 or magento_force_reindex_on_deploy == True + - name: "Disable maintenance mode" file: path: "{{ magento_release_folder }}/{{ magento_release_version }}/var/.maintenance.flag"