How to do a 'clean' deploy using Ansible

We are using the Ansible sensu.sensu_go.backend role to deploy SensuGo, along with other Ansible modules to do resource configuration. However, we have old resources hanging around that I would like to wipe clean at every new deployment. Is there a recommended way to do this?

The only options I have seen allow me to delete resources by name. However, I would like clean up everything, and especially resources whose names are not known (e.g. old junk). Also, I looked at sensuctl prune, but that only works on resources created with sensuctl.

Thanks for any recommendations or links - Alex.

I think the only way to do it is to use the individual resource apis directly and call the list and delete endpoints. You can’t wipe everything this way, you have to be careful about cluster wide resources that define administrative RBAC. But it maybe reasonable to do with namespace scoped resources as a way to fully clean the namespace prior to filling it.

This is probably functionaliy that needs to be added to the Ansible module. The ansible module should probably populate the managed by label similar to to what sensuctl does as well to help with auditing.

For the time being simple proof of concept in shell using curl and jq wouldn’t be too difficult.

Thank you for the help here as well!