From 886afa0f9a261c239eaad0744878f63db7ee2d68 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Tue, 4 Jun 2024 03:14:22 +0200 Subject: Install PostgreSQL and PostGIS. --- tasks/webmap.yml | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'tasks/webmap.yml') 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 -- cgit v1.2.3