Skip to content

Conversation

@PrakharJain1509
Copy link

PR Description

  • NetBox v4.4 replaces the legacy housekeeping script with NetBox-managed scheduled jobs. This PR ensures we don’t create a stale cron entry on v4.4+ and allows operators to disable the cron explicitly.

  • Changes:

    • Add netbox_housekeeping_cron_enabled (default: true) to control whether the legacy housekeeping cron is managed.
    • Only create the cron for stable installs when netbox_stable_version >= 3.0.0 and < 4.4.0; for git installs, rely on the existing commit presence check.
    • Add cleanup task to remove the cron when not applicable (disabled or v4.4+), preventing leftovers during upgrades.
  • Files edited:

    • tasks/deploy_netbox.yml: Add version-aware guard, toggle, and cleanup task for the housekeeping cron.
    • defaults/main.yml: Introduce netbox_housekeeping_cron_enabled variable.
  • Backwards compatibility:

    • No breaking changes. Existing behavior is preserved for NetBox < 4.4 unless the new toggle is set to false.
  • Upgrade notes:

    • Upgrading to NetBox v4.4+ will automatically remove the legacy housekeeping cron entry.
    • Operators can explicitly disable cron creation by setting:
      • netbox_housekeeping_cron_enabled: false
  • Testing:

    • Lint clean.
    • Verified behavior across scenarios:
      • Stable < 4.4: cron is created when enabled.
      • Stable >= 4.4: cron is not created and is removed if present.
      • Git: cron managed when the housekeeping commit exists and toggle is enabled.
      • Toggle off: cron is absent across all versions.
  • Example override:

@PrakharJain1509
Copy link
Author

@tyler-8 Please have a look into this and let me know if you need anything else

Copy link
Owner

@lae lae left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking over this, a separate task should not be used.

Also, the same treatment should apply to git deployments that contain the upstream change. Specifically, netbox-community/netbox#19815. See install_via_git.yml for examples.

In fact, if my understanding after looking through that PR is correct, we don't exactly need a role variable to managing the cronjob? It should just exist or not exist depending on what NetBox version is installed, so the version comparison would be enough...though probably in the state attribute instead.

@tyler-8
Copy link
Collaborator

tyler-8 commented Oct 30, 2025

Looking over this, a separate task should not be used.

Also, the same treatment should apply to git deployments that contain the upstream change. Specifically, netbox-community/netbox#19815. See install_via_git.yml for examples.

In fact, if my understanding after looking through that PR is correct, we don't exactly need a role variable to managing the cronjob? It should just exist or not exist depending on what NetBox version is installed, so the version comparison would be enough...though probably in the state attribute instead.

It looks like the new task is only for users currently using this playbook and upgrading to v4.4 - it cleans up the previously installed cron file. Otherwise, as I've tested myself, the housekeeping cron file will persist unless you manually delete it, so I think that's a reasonable addition.

However, I do agree that a new configurable variable isn't necessary. We should do a version comparison or look for the presence of the relevant commit ID and register the variable to determine if action is needed just like already happens here:

failed_when: "_netbox_git_contains_housekeeping.rc not in [0, 1]"

Copy link
Collaborator

@tyler-8 tyler-8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of introducing netbox_housekeeping_cron_enabled, we should instead extend the already existing task that sets _netbox_git_contains_housekeeping to include checking for the commit ID that now removes the houskeeping feature.

However, the cleanup task is a good idea I think.

@lae
Copy link
Owner

lae commented Oct 30, 2025

It looks like the new task is only for users currently using this playbook and upgrading to v4.4 - it cleans up the previously installed cron file.

Right, but I'm suggesting that cleanup doesn't need a new task. Setting the state attribute on the existing task to a conditional should be enough to clean it up. Unless I'm severely misunderstanding something...

@tyler-8
Copy link
Collaborator

tyler-8 commented Oct 30, 2025

It looks like the new task is only for users currently using this playbook and upgrading to v4.4 - it cleans up the previously installed cron file.

Right, but I'm suggesting that cleanup doesn't need a new task. Setting the state attribute on the existing task to a conditional should be enough to clean it up. Unless I'm severely misunderstanding something...

I see what you mean now and agreed - dynamically adjusting the state attribute should be sufficient in the existing task.

@lae
Copy link
Owner

lae commented Nov 1, 2025

@PrakharJain1509 can we get an update on this?

@lae
Copy link
Owner

lae commented Nov 2, 2025

shell: 'set -o pipefail; git log --format=%H "{{ netbox_git_version }}" | grep ^f3a8b9c1d2e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0'

netbox-community/netbox@f3a8b9c

>commit doesn't exist

🤔

@PrakharJain1509
Copy link
Author

PrakharJain1509 commented Nov 2, 2025

@lae @tyler-8 Did some changes..

@lae
Copy link
Owner

lae commented Nov 3, 2025

I don't know if GitHub intends to fix this, but I will just mention that my previous comment/review is a response to Jain and is the most recent comment and the timestamp for Jain's was moved an hour ahead for some reason. (note the commit and comment/gha notification timestamps are basically an hour apart, give a minute for writing the comment)

image

which means it's time for our annual mention of https://www.youtube.com/watch?v=-5wpm-gesOY

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants