diff --git a/tasks/databases.yml b/tasks/databases.yml index 91b1a5b8..176a8888 100644 --- a/tasks/databases.yml +++ b/tasks/databases.yml @@ -12,6 +12,7 @@ encoding: "{{postgresql_encoding}}" lc_collate: "{{postgresql_locale}}" lc_ctype: "{{postgresql_locale}}" + port: "{{postgresql_port}}" template: "template0" state: present login_user: "{{postgresql_admin_user}}" @@ -32,4 +33,14 @@ sudo_user: "{{ postgresql_service_user }}" shell: "psql {{item.name}} -c 'CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";'" with_items: postgresql_databases + register: uuid_ext_result + failed_when: uuid_ext_result.rc != 0 and ("already exists, skipping" not in uuid_ext_result.stderr) + changed_when: uuid_ext_result.rc == 0 and ("already exists, skipping" not in uuid_ext_result.stderr) when: item.uuid_ossp is defined and item.uuid_ossp + +- name: PostgreSQL | Add postgis to the databases with the requirement + sudo: yes + sudo_user: "{{postgresql_admin_user}}" + shell: "psql {{item.name}} -c 'CREATE EXTENSION IF NOT EXISTS postgis;'&&psql {{item.name}} -c 'CREATE EXTENSION IF NOT EXISTS postgis_topology;'" + with_items: postgresql_databases + when: item.gis is defined and item.gis diff --git a/tasks/extensions/postgis.yml b/tasks/extensions/postgis.yml index a2b16eb8..38a369c2 100644 --- a/tasks/extensions/postgis.yml +++ b/tasks/extensions/postgis.yml @@ -7,5 +7,6 @@ with_items: - libgeos-c1 - "postgresql-{{postgresql_version}}-postgis-{{postgresql_ext_postgis_version}}" + - "postgresql-{{postgresql_version}}-postgis-{{postgresql_ext_postgis_version}}-scripts" notify: - restart postgresql diff --git a/tasks/install.yml b/tasks/install.yml index 92865c84..8da4b5cb 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -25,3 +25,4 @@ with_items: - "postgresql-{{postgresql_version}}" - "postgresql-client-{{postgresql_version}}" + - "postgresql-contrib" diff --git a/tasks/users.yml b/tasks/users.yml index 33696b0d..ed5ee83b 100644 --- a/tasks/users.yml +++ b/tasks/users.yml @@ -9,6 +9,7 @@ postgresql_user: name: "{{item.name}}" password: "{{item.pass | default('pass')}}" + port: "{{postgresql_port}}" state: present login_user: "{{postgresql_admin_user}}" sudo: yes @@ -20,6 +21,7 @@ postgresql_user: name: "{{item.name}}" db: "{{item.db}}" + port: "{{postgresql_port}}" priv: "{{item.priv | default('ALL')}}" state: present login_user: "{{postgresql_admin_user}}"