Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PostGIS install #310

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -518,7 +543,6 @@ postgresql_log_temp_files: -1
postgresql_log_timezone: "UTC"



#------------------------------------------------------------------------------
# RUNTIME STATISTICS
#------------------------------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@
state: restarted
enabled: yes
when: ansible_service_mgr == 'systemd'

7 changes: 4 additions & 3 deletions tasks/extensions/contrib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@

- 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:
name: "postgresql{{postgresql_version_terse}}-contrib"
state: present
when: ansible_os_family == "RedHat"
notify:
- restart postgresql
- restart postgresql with service
- restart postgresql with systemd
12 changes: 4 additions & 8 deletions tasks/extensions/postgis.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
3 changes: 2 additions & 1 deletion tests/docker/group_vars/postgresql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@ 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
extensions:
- adminpack
- pgcrypto
- unaccent
- postgis
1 change: 0 additions & 1 deletion tests/vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ postgresql_users:
pass: md51a1dc91c907325c69271ddf0c944bc72
encrypted: yes


- name: zab
pass: md51a1dc91c907325c69271ddf0c944bc72
encrypted: yes
Expand Down
7 changes: 7 additions & 0 deletions vars/Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
13 changes: 13 additions & 0 deletions vars/RedHat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"