Quick question on automating the removal of old content versions

General question just to ask whether there’s a setting in Foreman to automatically remove old content view versions?
I’ve just removed about 20 historical versions from each of our CV’s, leaving the last 3 just in case. It would be great if I could automate this

I believe there’s only the option to remove by ID/name with hammer, so it would need a script of sorts to ignore the latest ID minus 3, hoping there’s an option in the GUI

Thanks

Sorry, no UI for automating this. When I had a similar requirement at customers in the past I also used hammer. If I would need it now, I would have at least a look at the Ansible module, which could also be an option for you, but I only used for creation yet

OK, thanks for confirming. Will take a look at that module as we control all of our infra using Ansible

It’s not automatic, but check out hammer content-view purge

1 Like

ooh this could work as takes a count argument for keeping last few. thanks!

1 Like

just ran a quick test as going to implement a quarterly cron that runs:
hammer content-view purge --count 5 --name “CV1” --organization-label Main

Unfortunately shows that --count (which is essential for our needs) is being depreciated. Anyone know what the correct command would be to keep 5?

“The --count option is deprecated and will be removed in the next release.”

The deprecation seems to be over two years old by now, but the “new” option seems to be --versions-to-keep : Fixes #37993 - Update cvpurge count to a better description · Katello/hammer-cli-katello@416b9a7 · GitHub

1 Like

Works perfectly, cron in place. thank you!

On the Ansible side we also have the content_view_version_cleanup role, which is similar to what hammer does.

1 Like

FYI: I created an upstream PR to document removing CV versions: PR 4869 “Delete old CV versions” in foreman-documentation.

We have merged the upstream PR; the docs are now live: Purging content view versions by using Hammer CLI