openwisp / ansible-openwisp2

Ansible role that installs and upgrades OpenWISP.
https://openwisp.io/docs/dev/ansible/
BSD 3-Clause "New" or "Revised" License
474 stars 137 forks source link

Error - installing with PostgreSQL back end #416

Closed tricksol closed 1 year ago

tricksol commented 1 year ago

When attempting to use the ansible installer to setup PostgreSQL back end you receive an error.

The role variables tells you to use PostgreSQL in production (https://github.com/openwisp/ansible-openwisp2#usage-tutorial)

Specifically this section.

edit database settings only if you are not using sqlite

# eg, for deploying with PostgreSQL (recommended for production usage)
# you will need the PostGIS spatial extension, find more info at:
# https://docs.djangoproject.com/en/4.1/ref/contrib/gis/tutorial/
openwisp2_database:
    engine: django.contrib.gis.db.backends.postgis
    name: "{{ DB_NAME }}"
    user: "{{ DB_USER }}"
    host: "{{ DB_HOST }}"
    password: "{{ DB_PASSWORD }}"
    port: 5432

I have a working PostGIS server ready to take the database but when running the ansbile playbook I receive this error.

TASK [openwisp.openwisp2 : Set spatialite_path (Ubuntu >= 18.04 or Debian >= 10)] **** fatal: [hal2.nationalwi-fi.com]: FAILED! => {"msg": "The conditional check 'openwisp2_database.engine == \"django.contrib.gis.db.backends.spatialite\" and openwisp2_spatialite_path is none\n' failed. The error was: error while evaluating conditional (openwisp2_database.engine == \"django.contrib.gis.db.backends.spatialite\" and openwisp2_spatialite_path is none\n): {'engine': 'django.contrib.gis.db.backends.postgis', 'name': '{{openwsip2_databasename}', 'user': '{{username}}', 'host': '{{hostIP}}', 'password': '{{Password}}', 'port': 5432}: 'openwsip2_database' is undefined\n\nThe error appears to be in '/home/mmidgett/.ansible/roles/openwisp.openwisp2/tasks/variables-spatialite.yml': line 3, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Set spatialite_path (Ubuntu >= 18.04 or Debian >= 10)\n ^ here\n"}

The error suggests this file variables-spatialite.yml


SPATIALITE_LIBRARY_PATH django setting

The role will attempt determining the right mod-spatialite path automatically

But you can use this variable to customize the path or fix future arising issues

openwisp2_spatialite_path: null
nemesifier commented 1 year ago

@tricksol I cannot replicate this, we manage quite a few instances running postrgres and we are not incurring into this issue.