diff --git a/roles/ckan/tasks/deploy.yml b/roles/ckan/tasks/deploy.yml index 8c1e768..f348b10 100644 --- a/roles/ckan/tasks/deploy.yml +++ b/roles/ckan/tasks/deploy.yml @@ -107,7 +107,7 @@ become: false with_items: - ckandb_job.yaml - when: (fjelltopp_env_type != 'local') or (ckan_datapusher_enable == 'true') + when: (fjelltopp_env_type != 'local') - name: Deploy CKAN kubernetes.core.k8s: diff --git a/roles/ckan/templates/ckan/ckan_bootstrap.sh b/roles/ckan/templates/ckan/ckan_bootstrap.sh index 60f4ae8..9a3878b 100644 --- a/roles/ckan/templates/ckan/ckan_bootstrap.sh +++ b/roles/ckan/templates/ckan/ckan_bootstrap.sh @@ -1,9 +1,20 @@ #!/bin/sh CONFIG=/etc/ckan/production.ini + +{% if ckan_datapusher_enable == 'true' %} +echo "Making datastore user" +psql "${CKAN_SQLALCHEMY_URL}" -c "CREATE ROLE datastore NOSUPERUSER NOCREATEDB NOCREATEROLE LOGIN PASSWORD '{{ ckan_ds_rw_pass }}';" +echo "Making datastore_ro user" +psql "${CKAN_SQLALCHEMY_URL}" -c "CREATE ROLE datastore_ro NOSUPERUSER NOCREATEDB NOCREATEROLE LOGIN PASSWORD '{{ ckan_ds_ro_pass }}';" +echo "Making datastore db" +psql "${CKAN_SQLALCHEMY_URL}" -c "CREATE DATABASE datastore OWNER ckan ENCODING 'utf-8';" +echo "Setup datastore permissions" +ckan -c "$CONFIG" datastore set-permissions | psql "${CKAN_SQLALCHEMY_URL}" +{% endif %} + # we're making sure to run our custom entrypoint. /usr/lib/ckan/ckan-entrypoint.sh -echo "DB init:" -ckan -c "$CONFIG" db init + echo "Add admin user:" ckan -c "$CONFIG" user add admin email="admin@localhost" name="admin" fullname="Admin" password="fjelltopp" apikey="{{ ckan_admin_api_key }}" id="{{ ckan_admin_user_id }}" echo "Set apikey:" @@ -12,8 +23,6 @@ echo "Create API token:" psql "${CKAN_SQLALCHEMY_URL}" -c "INSERT INTO api_token VALUES ('{{ ckan_admin_api_token_unencoded }}', 'Default Token', '{{ ckan_admin_user_id }}', now()) ON CONFLICT DO NOTHING;" echo "make admin superuser" ckan -c "$CONFIG" sysadmin add admin -echo "Set datastore permissions" -ckan -c "$CONFIG" datastore set-permissions | psql "${CKAN_SQLALCHEMY_URL}" echo "Build search index" ckan -c "$CONFIG" search-index rebuild echo bootstrap finished