- name:postgresql_ext - check that extension exists after the previous step
become_user:'{{ pg_user }}'
become:true
postgresql_query:
db:postgres
query:SELECT extname FROM pg_extension WHERE extname='postgis'
ignore_errors:true
register:result
- assert:
that:
- result.rowcount == 1
- name:postgresql_ext - drop extension postgis
become_user:'{{ pg_user }}'
become:true
postgresql_ext:
db:postgres
name:postgis
state:absent
ignore_errors:true
register:result
- assert:
that:
- result is changed
- result.queries == ['DROP EXTENSION "postgis"']
- name:postgresql_ext - check that extension doesn't exist after the previous step
become_user:'{{ pg_user }}'
become:true
postgresql_query:
db:postgres
query:SELECT extname FROM pg_extension WHERE extname='postgis'
ignore_errors:true
register:result
- assert:
that:
- result.rowcount == 0
- name:postgresql_ext - create extension postgis
become_user:'{{ pg_user }}'
become:true
postgresql_ext:
db:postgres
name:postgis
schema:schema1
ignore_errors:true
register:result
- assert:
that:
- result is changed
- result.queries == ['CREATE EXTENSION "postgis" WITH SCHEMA "schema1"']
- name:postgresql_ext - check that extension exists after the previous step
become_user:'{{ pg_user }}'
become:true
postgresql_query:
db:postgres
query:"SELECT extname FROM pg_extension AS e LEFT JOIN pg_catalog.pg_namespace AS n \nON n.oid = e.extnamespace WHERE e.extname='postgis' AND n.nspname='schema1'\n"
ignore_errors:true
register:result
- assert:
that:
- result.rowcount == 1
- name:postgresql_ext - drop extension postgis cascade