open-contracting / deploy

Deployment configuration and scripts
https://ocdsdeploy.readthedocs.io/en/latest/
Apache License 2.0
2 stars 3 forks source link

Generic Site File Backups #500

Closed RobHooper closed 1 month ago

RobHooper commented 1 month ago

In configuring backups for Coalition ( #425 ) I found that the existing site file backup code had been explicitly configured for "redmine". This PR moves the Salt code into a macro so that it can be shared between services.

I chose a macro over a separate backup.sls file for a few reasons, firstly, we can re-use the userdir variable from the service code. It also makes it easier to match the pillar data to salt, for instance, there is a redmine value in both but wordpress is used by coalition in the salt directory. I am on the fence if this is the ideal solution, happy to change approach if there is a good reason for an alternative structure.

RobHooper commented 1 month ago

Additional task when deploying:

jpmckinney commented 1 month ago

I moved the macro back out to a state file, and promoted the backup Pillar keys to top-level.

RobHooper commented 1 month ago

Regarding top.sls, salt expects matches to contain a delimiter flagging an error and ignoring the match if it is missing. I have worked around this by updating top.sls to match any content I@backup:*. https://github.com/saltstack/salt/blob/29b6843268e9877c28bd283b0aa9d77e4bae948d/salt/matchers/pillar_match.py#L20-L21