1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/tests/integration/targets/postgresql_ext/tasks/postgresql_ext_initial.yml
John R Barker 1f06a02043
Shippable: community/general (#12)
* Shippable: community/general
2020-03-17 08:59:17 +00:00

170 lines
4.7 KiB
YAML

- name: postgresql_ext - install postgis on Linux
package: name=postgis state=present
when: ansible_os_family != "Windows"
- name: postgresql_ext - install postgis on Windows
when: ansible_os_family == "Windows"
ansible.windows.win_package: name=postgis state=present
- name: postgresql_ext - create schema schema1
become_user: '{{ pg_user }}'
become: true
postgresql_schema:
database: postgres
name: schema1
state: present
- name: postgresql_ext - drop extension if exists
become_user: '{{ pg_user }}'
become: true
postgresql_query:
db: postgres
query: DROP EXTENSION IF EXISTS postgis
ignore_errors: true
- name: postgresql_ext - create extension postgis in check_mode
become_user: '{{ pg_user }}'
become: true
postgresql_ext:
login_db: postgres
login_port: 5432
name: postgis
check_mode: true
ignore_errors: true
register: result
- assert:
that:
- result is changed
- result.queries == []
- 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:
login_db: postgres
login_port: 5432
name: postgis
ignore_errors: true
register: result
- assert:
that:
- result is changed
- result.queries == ['CREATE EXTENSION "postgis"']
- 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
become_user: '{{ pg_user }}'
become: true
postgresql_ext:
db: postgres
name: postgis
state: absent
cascade: true
ignore_errors: true
register: result
- assert:
that:
- result is changed
- result.queries == ['DROP EXTENSION "postgis" CASCADE']
- 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 cascade
become_user: '{{ pg_user }}'
become: true
postgresql_ext:
db: postgres
name: postgis
cascade: true
ignore_errors: true
register: result
when: postgres_version_resp.stdout is version('9.6', '<=')
- assert:
that:
- result is changed
- result.queries == ['CREATE EXTENSION "postgis" CASCADE"']
when: postgres_version_resp.stdout is version('9.6', '<=')
- 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
when: postgres_version_resp.stdout is version('9.6', '<=')
- assert:
that:
- result.rowcount == 1
when: postgres_version_resp.stdout is version('9.6', '<=')