From fe8d5fb12930bb09eeb11dbfc43c771151d5aa51 Mon Sep 17 00:00:00 2001 From: prakharjain Date: Thu, 30 Oct 2025 13:10:09 +0530 Subject: [PATCH 1/2] Check-1 --- defaults/main.yml | 5 +++++ tasks/deploy_netbox.yml | 21 +++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 35013e5..3173993 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -97,3 +97,8 @@ netbox_keep_uwsgi_updated: false netbox_uwsgi_in_venv: false netbox_uwsgi_options: {} netbox_rqworker_processes: 1 + +# Whether to install the legacy housekeeping cron job. +# NetBox v4.4+ replaces the housekeeping script with NetBox-managed scheduled jobs. +# Set to false to skip creating the cron entry regardless of version. +netbox_housekeeping_cron_enabled: true diff --git a/tasks/deploy_netbox.yml b/tasks/deploy_netbox.yml index 3da51e0..11d3a6f 100644 --- a/tasks/deploy_netbox.yml +++ b/tasks/deploy_netbox.yml @@ -200,8 +200,25 @@ 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 + - netbox_housekeeping_cron_enabled | bool + - (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) + +- name: Remove housekeeping cronjob when not applicable + cron: + name: "Netbox housekeeping" + user: "{{ netbox_user }}" + cron_file: "netbox" + state: absent + when: + - not ( + (netbox_housekeeping_cron_enabled | bool) + and ( + (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) + ) + ) - block: - name: Run database migrations for NetBox From 2e3435e24d815294d0c6817ce269ee1a31bc4a3f Mon Sep 17 00:00:00 2001 From: prakharjain Date: Sun, 2 Nov 2025 13:50:27 +0530 Subject: [PATCH 2/2] Check-2 --- defaults/main.yml | 5 ----- tasks/deploy_netbox.yml | 27 +++++++-------------------- tasks/install_via_git.yml | 9 +++++++++ 3 files changed, 16 insertions(+), 25 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 3173993..35013e5 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -97,8 +97,3 @@ netbox_keep_uwsgi_updated: false netbox_uwsgi_in_venv: false netbox_uwsgi_options: {} netbox_rqworker_processes: 1 - -# Whether to install the legacy housekeeping cron job. -# NetBox v4.4+ replaces the housekeeping script with NetBox-managed scheduled jobs. -# Set to false to skip creating the cron entry regardless of version. -netbox_housekeeping_cron_enabled: true diff --git a/tasks/deploy_netbox.yml b/tasks/deploy_netbox.yml index 11d3a6f..497942c 100644 --- a/tasks/deploy_netbox.yml +++ b/tasks/deploy_netbox.yml @@ -192,33 +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_housekeeping_cron_enabled | bool - - (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) - -- name: Remove housekeeping cronjob when not applicable - cron: - name: "Netbox housekeeping" - user: "{{ netbox_user }}" - cron_file: "netbox" - state: absent - when: - - not ( - (netbox_housekeeping_cron_enabled | bool) - and ( + 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) - ) - ) + 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: