45 lines
No EOL
1.4 KiB
YAML
45 lines
No EOL
1.4 KiB
YAML
---
|
|
- name: Enable PostGIS in APRS Database
|
|
hosts: lab02
|
|
become: true
|
|
vars:
|
|
ct_id: 300
|
|
|
|
tasks:
|
|
- name: Check if PostGIS is installed
|
|
command: |
|
|
pct exec {{ ct_id }} -- dpkg -l | grep postgis
|
|
register: postgis_check
|
|
ignore_errors: yes
|
|
|
|
- name: Install PostGIS if not present
|
|
command: pct exec {{ ct_id }} -- apt-get install -y postgresql-16-postgis-3 postgresql-16-postgis-3-scripts
|
|
when: postgis_check.rc != 0
|
|
|
|
- name: Enable PostGIS extension in APRS database
|
|
command: |
|
|
pct exec {{ ct_id }} -- sudo -u postgres psql -d aprs -c "CREATE EXTENSION IF NOT EXISTS postgis;"
|
|
register: postgis_result
|
|
|
|
- name: Enable PostGIS topology extension
|
|
command: |
|
|
pct exec {{ ct_id }} -- sudo -u postgres psql -d aprs -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"
|
|
ignore_errors: yes
|
|
|
|
- name: Verify PostGIS installation
|
|
command: |
|
|
pct exec {{ ct_id }} -- sudo -u postgres psql -d aprs -c "SELECT PostGIS_Version();"
|
|
register: postgis_version
|
|
ignore_errors: yes
|
|
|
|
- name: Display results
|
|
debug:
|
|
msg: |
|
|
PostGIS setup completed!
|
|
|
|
Extension creation: {{ postgis_result.stdout | default('Done') }}
|
|
{% if postgis_version.rc == 0 %}
|
|
PostGIS Version: {{ postgis_version.stdout }}
|
|
{% else %}
|
|
Note: PostGIS may require package installation
|
|
{% endif %} |