diff --git a/tasks/deploy_netbox.yml b/tasks/deploy_netbox.yml index 3da51e0..497942c 100644 --- a/tasks/deploy_netbox.yml +++ b/tasks/deploy_netbox.yml @@ -192,16 +192,20 @@ group: "{{ netbox_group }}" loop: "{{ netbox_reports }}" -- name: Schedule daily housekeeping cronjob +- name: Manage daily housekeeping cronjob cron: name: "Netbox housekeeping" special_time: daily job: "{{ netbox_virtualenv_path }}/bin/python {{ netbox_current_path }}/netbox/manage.py housekeeping" user: "{{ netbox_user }}" cron_file: "netbox" - when: - - netbox_stable and netbox_stable_version is version('3.0.0', '>=') - or netbox_git and _netbox_git_contains_housekeeping.rc == 0 + state: >- + {{ + 'present' if ( + (netbox_stable and netbox_stable_version is version('3.0.0', '>=') and netbox_stable_version is version('4.4.0', '<')) + or (netbox_git and _netbox_git_contains_housekeeping.rc == 0 and _netbox_git_contains_housekeeping_removed.rc != 0) + ) else 'absent' + }} - block: - name: Run database migrations for NetBox diff --git a/tasks/install_via_git.yml b/tasks/install_via_git.yml index 80bcaa5..3fbfd63 100644 --- a/tasks/install_via_git.yml +++ b/tasks/install_via_git.yml @@ -71,6 +71,15 @@ changed_when: False failed_when: "_netbox_git_contains_housekeeping.rc not in [0, 1]" + - name: Check existence of commit removing housekeeping management command (PR #19815) + shell: 'set -o pipefail; git log --format=%H "{{ netbox_git_version }}" | grep ^f3a8b9c1d2e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0' + args: + chdir: "{{ netbox_git_repo_path }}" + executable: /bin/bash + register: _netbox_git_contains_housekeeping_removed + changed_when: False + failed_when: "_netbox_git_contains_housekeeping_removed.rc not in [0, 1]" + - name: Check existence of commit 028c876, removing the invalidate command shell: 'set -o pipefail; git log --format=%H "{{ netbox_git_version }}" | grep ^028c876bcafbaede2731f191512bbebe3f1b6a9e' args: