You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For every release, this role creates a new directory to deploy NetBox into, as well as a virtualenv for that particular release. This allows us to do naive downgrades (it's fine if there aren't any database migrations) to an older version when necessary, but after some time leads to a lot of old release directories:
This role should probably have a role variable to specify when to prune old releases, e.g. prune all releases except the last 5. There should be a task to check for prunable releases and remove them entirely.
The text was updated successfully, but these errors were encountered:
Not sure if this is exactly fitting the criteria, but without a bunch of regex and layered filtering, I'm not sure how else to do this. This uses path modification time:
# defaults/main.ymlnetbox_releases_to_keep: 3# tasks/main.yml
- name: Get list of release directoriesansible.builtin.find:
paths: /srv/netbox/releasesfile_type: directoryregister: release_dirs
- name: Sort and prune old releasesblock:
- name: Sort release directories by modification timeansible.builtin.set_fact:
sorted_release_dirs: "{{ release_dirs.files | sort(attribute='mtime', reverse=True) }}"
- name: Determine directories to removeansible.builtin.set_fact:
directories_to_remove: "{{ sorted_release_dirs[netbox_releases_to_keep:] | map(attribute='path') | list }}"
- name: Remove old release directoriesansible.builtin.file:
path: "{{ item }}"state: absentwith_items: "{{ directories_to_remove }}"when: release_dirs.matched > netbox_releases_to_keep
For every release, this role creates a new directory to deploy NetBox into, as well as a virtualenv for that particular release. This allows us to do naive downgrades (it's fine if there aren't any database migrations) to an older version when necessary, but after some time leads to a lot of old release directories:
This role should probably have a role variable to specify when to prune old releases, e.g. prune all releases except the last 5. There should be a task to check for prunable releases and remove them entirely.
The text was updated successfully, but these errors were encountered: