Skip to content

Commit

Permalink
WAC-42: Improve datapusher deployment. (#11)
Browse files Browse the repository at this point in the history
* WAC-42: Improve datapusher deployment.

* Run "Unit CKAN schema" locally when datapusher is enabled.

* WAC-42 Add psycopg2 to the pipenv

* WAC-42 Improve check for DB availability

* WAC-42 Set datastore permission during db bootstrap

---------

Co-authored-by: Jonathan S Berry <[email protected]>
  • Loading branch information
Kacpersoftberry and jonathansberry authored Jun 6, 2024
1 parent fa5c7c4 commit 09b99a8
Show file tree
Hide file tree
Showing 7 changed files with 904 additions and 745 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
roles/gantsign.minikube
roles/geerlingguy.helm
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ botocore = "*"
openshift = "*"
docker = "*"
awscli = "*"
psycopg2 = "*"

[requires]
python_version = "3.8"
1,630 changes: 892 additions & 738 deletions Pipfile.lock

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions roles/ckan/tasks/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,13 @@
login_host: "{{ ckan_fqdn }}"
login_user: "{{ rds_admin_username }}"
login_password: "{{ ckan_postgres_password }}"
when: (fjelltopp_env_type == 'local') and (ckan_datapusher_enable)
when: (fjelltopp_env_type == 'local')
register: db_ping_result
retries: 10
delay: 5
until: db_ping_result.is_available
failed_when: not db_ping_result.is_available
until: db_ping_result is defined and db_ping_result.get('is_available')
failed_when: db_ping_result is not defined or not db_ping_result.is_available
# For this check to work psycopg2 must be installed for the venv python referenced from your inventory

- name: Setup database parameters
set_fact:
Expand All @@ -106,7 +107,7 @@
become: false
with_items:
- ckandb_job.yaml
when: fjelltopp_env_type != 'local'
when: (fjelltopp_env_type != 'local') or (ckan_datapusher_enable == 'true')

- name: Deploy CKAN
kubernetes.core.k8s:
Expand Down
4 changes: 2 additions & 2 deletions roles/ckan/templates/ckan/ckan_bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ echo "Create API token:"
psql "${CKAN_SQLALCHEMY_URL}" -c "INSERT INTO api_token VALUES ('{{ ckan_default_api_token }}', '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 bootstrap finished


1 change: 1 addition & 0 deletions roles/ckan/templates/ckan/ckan_production.ini
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ ckan.datapusher.url = {{ ckan_datapusher_url }}
{% if ckan_datapusher_api_token %}
ckan.datapusher.api_token = {{ ckan_datapusher_api_token }}
{% endif %}
ckan.datapusher.callback_url_base = http://ckan:5000/
ckan.datapusher.assume_task_stale_after = 3600
{% endif %}

Expand Down
2 changes: 1 addition & 1 deletion roles/requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ collections:
version: 2.10.0
- name: community.postgresql
accept_hostkey: true
version: 3.4.0
version: 3.4.1

0 comments on commit 09b99a8

Please sign in to comment.