summaryrefslogtreecommitdiffstats
path: root/tasks
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2024-06-04 03:14:22 +0200
committerGuilhem Moulin <guilhem@fripost.org>2024-06-12 01:10:58 +0200
commit886afa0f9a261c239eaad0744878f63db7ee2d68 (patch)
treedf68103f676365571eec0c43700541de0d50e6a3 /tasks
parentf346b05b5f62298039894a356fea3c914eb7e861 (diff)
Install PostgreSQL and PostGIS.
Diffstat (limited to 'tasks')
-rw-r--r--tasks/webmap.yml55
1 files changed, 55 insertions, 0 deletions
diff --git a/tasks/webmap.yml b/tasks/webmap.yml
index 9b60359..10a6555 100644
--- a/tasks/webmap.yml
+++ b/tasks/webmap.yml
@@ -111,3 +111,58 @@
with_items: "{{ webmap_layer_groups }}"
- meta: flush_handlers
+
+
+- name: Install PostgreSQL and PostGIS
+ apt: pkg={{ packages }}
+ vars:
+ packages:
+ - postgresql
+ - postgresql-postgis
+ - postgis
+ # for ansible
+ - python3-psycopg
+
+- name: Generate sv_SE.UTF-8 locales
+ locale_gen: name=sv_SE.UTF-8 state=present
+ # PostgreSQL needs to be restarted to see the new locale
+ notify: Restart PostgreSQL
+
+- name: Start PostgreSQL
+ service: name=postgresql@{{ postgresql.version }}-{{ postgresql.cluster }}.service state=started
+
+- meta: flush_handlers
+
+- name: Create PostgreSQL database
+ become: true
+ # XXX: this creates /var/lib/postgresql/.ansible/tmp
+ become_user: postgres
+ community.postgresql.postgresql_db:
+ name: webmap
+ comment: Backend PostGIS database for KlimatanalysNorr tooling
+ encoding: UTF-8
+ lc_collate: sv_SE.UTF-8
+ lc_ctype: sv_SE.UTF-8
+ locale_provider: icu
+ icu_locale: sv-SE-x-icu
+ template: template0
+ owner: postgres
+
+- name: Create 'postgis' PostgreSQL schema
+ become: true
+ become_user: postgres
+ community.postgresql.postgresql_schema:
+ name: postgis
+ db: webmap
+ owner: postgres
+
+- name: Install 'postgis' PostgreSQL extension to the webmap database in the postgis schema
+ become: true
+ become_user: postgres
+ community.postgresql.postgresql_ext:
+ name: postgis
+ db: webmap
+ schema: postgis
+ comment: Geographic objects support for PostgreSQL
+
+- meta: flush_handlers