diff --git a/defaults/main.yml b/defaults/main.yml index 510e83a5..efa292e2 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -29,7 +29,32 @@ postgresql_ext_install_contrib: no postgresql_ext_install_dev_headers: no postgresql_ext_install_postgis: no -postgresql_ext_postgis_version: "2.1" # be careful: check whether the postgresql/postgis versions work together +# PostGIS +postgresql_postgis_release_compatibility: + 9.3: "2.3" + 9.4: "2.4" + 9.5: "2.4" + 9.6: "2.4" + 10: "2.4" + 11: "2.5" + +postgresql_ext_postgis_version: "{{ postgresql_postgis_release_compatibility.get(postgresql_version) }}" +postgresql_ext_postgis_version_terse: "{{ postgresql_ext_postgis_version | replace('.','') }}" + +postgresql_ext_postgis_deps: + - libgeos-c1 + - "postgresql-{{ postgresql_version }}-postgis-{{ postgresql_ext_postgis_version }}" + - "postgresql-{{ postgresql_version }}-postgis-scripts" + +postgresql_ext_postgis_deps: + - libgeos-c1 + - "postgresql-{{ postgresql_version }}-postgis-{{ postgresql_ext_postgis_version }}" + - "postgresql-{{ postgresql_version }}-postgis-scripts" + +postgresql_ext_postgis_deps: + - libgeos-c1 + - "postgresql-{{ postgresql_version }}-postgis-{{ postgresql_ext_postgis_version }}" + - "postgresql-{{ postgresql_version }}-postgis-scripts" postgresql_ext_postgis_deps: - libgeos-c1 @@ -518,7 +543,6 @@ postgresql_log_temp_files: -1 postgresql_log_timezone: "UTC" - #------------------------------------------------------------------------------ # RUNTIME STATISTICS #------------------------------------------------------------------------------ diff --git a/handlers/main.yml b/handlers/main.yml index 93e0bfbc..757daf34 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -12,4 +12,3 @@ state: restarted enabled: yes when: ansible_service_mgr == 'systemd' - diff --git a/tasks/extensions/contrib.yml b/tasks/extensions/contrib.yml index 619861f7..ed2878e3 100644 --- a/tasks/extensions/contrib.yml +++ b/tasks/extensions/contrib.yml @@ -2,13 +2,13 @@ - name: PostgreSQL | Extensions | Make sure the postgres contrib extensions are installed | Debian apt: - name: "postgresql-contrib-{{postgresql_version}}" + name: "postgresql-contrib-{{ postgresql_version }}" state: present update_cache: yes cache_valid_time: "{{apt_cache_valid_time | default (3600)}}" when: ansible_os_family == "Debian" notify: - - restart postgresql + - restart postgresql with service - name: PostgreSQL | Extensions | Make sure the postgres contrib extensions are installed | RedHat yum: @@ -16,4 +16,5 @@ state: present when: ansible_os_family == "RedHat" notify: - - restart postgresql + - restart postgresql with service + - restart postgresql with systemd diff --git a/tasks/extensions/postgis.yml b/tasks/extensions/postgis.yml index ed87308a..83b257e5 100644 --- a/tasks/extensions/postgis.yml +++ b/tasks/extensions/postgis.yml @@ -1,20 +1,15 @@ # file: postgresql/tasks/extensions/postgis.yml -- include_vars: "{{ item }}" - with_first_found: - - "../vars/{{ ansible_distribution_release }}.yml" - - "../vars/empty.yml" - - name: PostgreSQL | Extensions | Make sure the postgis extensions are installed | Debian apt: - name: "{{item}}" + name: "{{ item }}" state: present update_cache: yes cache_valid_time: "{{apt_cache_valid_time | default (3600)}}" with_items: "{{ postgresql_ext_postgis_deps }}" when: ansible_os_family == "Debian" notify: - - restart postgresql + - restart postgresql with service - name: PostgreSQL | Extensions | Make sure the postgis extensions are installed | RedHat yum: @@ -24,4 +19,5 @@ with_items: "{{ postgresql_ext_postgis_deps }}" when: ansible_os_family == "RedHat" notify: - - restart postgresql + - restart postgresql with service + - restart postgresql with systemd diff --git a/tests/docker/group_vars/postgresql.yml b/tests/docker/group_vars/postgresql.yml index 78c1c1fa..69a896fa 100644 --- a/tests/docker/group_vars/postgresql.yml +++ b/tests/docker/group_vars/postgresql.yml @@ -23,11 +23,11 @@ postgresql_user_privileges: db: foobar postgresql_ext_install_contrib: true +postgresql_ext_install_postgis: true # These do not work everywhere, but should be included ASAP postgresql_ssl: false postgresql_pgtune: false -postgresql_ext_install_postgis: false postgresql_database_extensions: - db: foobar @@ -35,3 +35,4 @@ postgresql_database_extensions: - adminpack - pgcrypto - unaccent + - postgis diff --git a/tests/vars.yml b/tests/vars.yml index 1d1bd2e0..3ee803c4 100644 --- a/tests/vars.yml +++ b/tests/vars.yml @@ -13,7 +13,6 @@ postgresql_users: pass: md51a1dc91c907325c69271ddf0c944bc72 encrypted: yes - - name: zab pass: md51a1dc91c907325c69271ddf0c944bc72 encrypted: yes diff --git a/vars/Debian.yml b/vars/Debian.yml index 8ece0a0b..579d39ab 100644 --- a/vars/Debian.yml +++ b/vars/Debian.yml @@ -2,3 +2,10 @@ postgresql_service_name: "postgresql" postgresql_bin_directory: /usr/bin + +postgresql_ext_postgis_deps: + - "postgresql-contrib-{{ postgresql_version }}" + - "postgresql-{{ postgresql_version }}-postgis-{{ postgresql_ext_postgis_version }}" + - "postgresql-{{ postgresql_version }}-postgis-scripts" + - "postgresql-{{ postgresql_version }}-pgrouting" + - "postgis" diff --git a/vars/RedHat.yml b/vars/RedHat.yml index 436411b5..6f070cf7 100644 --- a/vars/RedHat.yml +++ b/vars/RedHat.yml @@ -12,3 +12,16 @@ postgresql_bin_directory: "/usr/pgsql-{{postgresql_version}}/bin" postgresql_unix_socket_directories: - "{{ postgresql_pid_directory }}" - /tmp + +postgresql_ext_postgis_deps: + - "postgis{{ postgresql_ext_postgis_version_terse }}_{{ postgresql_version_terse }}" + - "postgis{{ postgresql_ext_postgis_version_terse }}_{{ postgresql_version_terse }}-client" + - "postgis{{ postgresql_ext_postgis_version_terse }}_{{ postgresql_version_terse }}-utils" + +postgresql_postgis_release_compatibility: + 9.3: "2" + 9.4: "2.4" + 9.5: "2.4" + 9.6: "2.4" + 10: "2.4" + 11: "2.5"