From cb0270b313ad64bc308ce9a0f2737e638f59c345 Mon Sep 17 00:00:00 2001 From: Tyler Bigler <17618971+tyler-8@users.noreply.github.com> Date: Mon, 24 Jun 2024 21:15:13 -0600 Subject: [PATCH] add reindex command for 3.4.5+ --- tasks/deploy_netbox.yml | 9 +++++++++ tasks/install_via_git.yml | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/tasks/deploy_netbox.yml b/tasks/deploy_netbox.yml index cf4baa2..7652e5b 100644 --- a/tasks/deploy_netbox.yml +++ b/tasks/deploy_netbox.yml @@ -242,5 +242,14 @@ or netbox_git and ( _netbox_git_contains_add_clearcache.rc == 0 and _netbox_git_contains_remove_clearcache.rc != 0 ) + - name: Rebuild the search cache (lazily) + django_manage: + command: "reindex --lazy" + app_path: "{{ netbox_current_path }}/netbox" + virtualenv: "{{ netbox_virtualenv_path }}" + when: + - netbox_stable and netbox_stable_version is version('3.4.5', '>') + or netbox_git and _netbox_git_contains_reindex_lazy.rc == 0 + become: true become_user: "{{ netbox_user }}" diff --git a/tasks/install_via_git.yml b/tasks/install_via_git.yml index a1a0615..80bcaa5 100644 --- a/tasks/install_via_git.yml +++ b/tasks/install_via_git.yml @@ -98,6 +98,15 @@ changed_when: False failed_when: "_netbox_git_contains_remove_clearcache.rc not in [0, 1]" + - name: Check existence of commit 5a4d8a7, adding the reindex lazy command + shell: 'set -o pipefail; git log --format=%H "{{ netbox_git_version }}" | grep ^5a4d8a71075a4529be8d5ef22d76d69861240f45' + args: + chdir: "{{ netbox_git_repo_path }}" + executable: /bin/bash + register: _netbox_git_contains_reindex_lazy + changed_when: False + failed_when: "_netbox_git_contains_reindex_lazy.rc not in [0, 1]" + become: true become_user: "{{ netbox_user }}"