33 lines
No EOL
1.1 KiB
YAML
33 lines
No EOL
1.1 KiB
YAML
---
|
|
- name: Enable PostGIS Extension
|
|
hosts: lab02
|
|
become: true
|
|
vars:
|
|
ct_id: 300
|
|
|
|
tasks:
|
|
- name: Try to enable PostGIS extension
|
|
command: |
|
|
pct exec {{ ct_id }} -- sudo -u postgres psql -d aprs -c "CREATE EXTENSION IF NOT EXISTS postgis;"
|
|
register: postgis_enable
|
|
ignore_errors: yes
|
|
|
|
- name: Install PostGIS for PostgreSQL 15 if extension failed
|
|
command: pct exec {{ ct_id }} -- bash -c "apt-get install -y postgresql-15-postgis-3 || apt-get install -y postgis postgresql-postgis"
|
|
when: postgis_enable.rc != 0
|
|
register: install_result
|
|
ignore_errors: yes
|
|
|
|
- name: Try to enable PostGIS again if it was just installed
|
|
command: |
|
|
pct exec {{ ct_id }} -- sudo -u postgres psql -d aprs -c "CREATE EXTENSION IF NOT EXISTS postgis;"
|
|
when: postgis_enable.rc != 0
|
|
|
|
- name: Show results
|
|
debug:
|
|
msg: |
|
|
{% if postgis_enable.rc == 0 %}
|
|
PostGIS extension enabled successfully!
|
|
{% else %}
|
|
PostGIS installation attempt: {{ install_result.stderr | default('') }}
|
|
{% endif %} |