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

Install Postgis extension with yum #259

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
9 changes: 5 additions & 4 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ postgresql_ext_install_postgis: no

postgresql_ext_postgis_version: "2.1" # be careful: check whether the postgresql/postgis versions work together

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"

# List of databases to be created (optional)
postgresql_databases: []
Expand Down Expand Up @@ -741,3 +741,4 @@ postgresql_pgdg_releases:
postgresql_version_terse: "{{ postgresql_version | replace('.', '') }}"
postgresql_yum_repository_base_url: "http://yum.postgresql.org"
postgresql_yum_repository_url: "{{ postgresql_yum_repository_base_url }}/{{ postgresql_version }}/{{ ansible_os_family | lower }}/rhel-{{ ansible_distribution_major_version }}-{{ ansible_architecture }}/pgdg-{{ postgresql_pgdg_dists[ansible_distribution] }}{{ postgresql_version_terse }}-{{ postgresql_version }}-{{ postgresql_pgdg_releases.get(postgresql_pgdg_dists[ansible_distribution]).get(postgresql_version) }}.noarch.rpm"
postgresql_ext_postgis_version_terse: "{{ postgresql_ext_postgis_version | replace('.', '') }}"
2 changes: 1 addition & 1 deletion tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
path: "{{ postgresql_conf_directory }}"
owner: "{{ postgresql_service_user }}"
group: "{{ postgresql_service_group }}"
mode: 0750
mode: 0700
state: directory

- name: PostgreSQL | Update configuration - pt. 1 (pg_hba.conf)
Expand Down
31 changes: 28 additions & 3 deletions tasks/extensions/postgis.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,41 @@
# file: postgresql/tasks/extensions/postgis.yml

# - include_vars: "{{ item }}"
# with_first_found:
# - "../vars/{{ ansible_distribution_release }}.yml"
# - "../vars/empty.yml"

- include_vars: "{{ item }}"
with_first_found:
- "../vars/{{ ansible_distribution_release }}.yml"
- "../vars/{{ ansible_os_family }}.yml"
- "../vars/empty.yml"
tags: [always]

- name: PostgreSQL | Extensions | Make sure the postgis extensions are installed
- name: PostgreSQL | Extensions | Make sure the postgis extensions are installed | Debian
apt:
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"
# with_items: "{{ postgresql_ext_postgis_deps }}" # used to be in 'defaults/main.yml'
with_items:
- libgeos-c1
- "postgresql-{{postgresql_version}}-postgis-{{postgresql_ext_postgis_version}}"
- "postgresql-{{postgresql_version}}-postgis-scripts"
notify:
- restart postgresql

- name: PostgreSQL | Extensions | Make sure the postgis extensions are installed | RedHat
yum:
name: "{{ item }}"
state: present
update_cache: yes
when: ansible_os_family == "RedHat"
environment: "{{ postgresql_env }}"
with_items:
- "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"
notify:
- restart postgresql