opendataphilly / opendataphilly-ckan

Port of OpenDataPhilly to CKAN
3 stars 2 forks source link

Add custom script to set Datastore permissions during database provisioning #90

Closed KlaasH closed 5 years ago

KlaasH commented 5 years ago

Overview

PR #74 faced the problem of how to make database and app provisioning independent given that we had formerly been doing some of the database initialization in the ckan-odp-configuration role. Specifically, it was using a paster command to set the correct permissions on the datastore plugin's table. The solution was to check out the CKAN repository on the DB machine and use a script that came with the repo which only requires a few parameters that the Ansible role already has variables for.

Unfortunately, that script went away in CKAN 2.3, in favor of a setup that's simpler if you have a CKAN instance but problematic if you don't.

This recreates a simplified version of the script, basically using the same template file that the 'paster' command uses but getting the context variables from the command line instead of a CKAN config file.

Since I needed a post-upgrade sample database to try this on, this also includes instructions for exporting and anonymizing the database and importing it into development.

Demo

image

Notes

It's kind of a bummer to be adding such specific logic to the role, but it's not actually that complex, just a template filler. The template itself is the one from the repo, so I think this should be reasonably robust against changes, or at least fail in a fairly obvious way if it needs to change (i.e. if the upstream process adds or removes a context variable).

Testing Instructions