2019-03-26 13:11:47 +01:00
|
|
|
# Test code for the postgresql_info module
|
2019-03-18 12:31:32 +01:00
|
|
|
# Copyright: (c) 2019, Andrew Klychkov (@Andersson007) <aaklychkov@mail.ru>
|
|
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
|
2019-03-26 13:11:47 +01:00
|
|
|
- name: postgresql_info - create role to check session_role
|
2019-03-18 12:31:32 +01:00
|
|
|
become_user: "{{ pg_user }}"
|
|
|
|
become: yes
|
|
|
|
postgresql_user:
|
|
|
|
db: "{{ db_default }}"
|
|
|
|
login_user: "{{ pg_user }}"
|
|
|
|
name: session_superuser
|
|
|
|
role_attr_flags: SUPERUSER
|
|
|
|
|
2019-03-26 13:11:47 +01:00
|
|
|
- name: postgresql_info - test return values and session_role param
|
2019-03-18 12:31:32 +01:00
|
|
|
become_user: "{{ pg_user }}"
|
|
|
|
become: yes
|
2019-03-26 13:11:47 +01:00
|
|
|
postgresql_info:
|
2019-03-18 12:31:32 +01:00
|
|
|
db: "{{ db_default }}"
|
|
|
|
login_user: "{{ pg_user }}"
|
|
|
|
session_role: session_superuser
|
|
|
|
register: result
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- result.version != {}
|
|
|
|
- result.databases.{{ db_default }}.collate
|
|
|
|
- result.databases.{{ db_default }}.languages
|
|
|
|
- result.databases.{{ db_default }}.namespaces
|
|
|
|
- result.databases.{{ db_default }}.extensions
|
|
|
|
- result.settings
|
|
|
|
- result.tablespaces
|
|
|
|
- result.roles
|
|
|
|
|
2019-03-26 13:11:47 +01:00
|
|
|
- name: postgresql_info - check filter param passed by list
|
2019-03-18 12:31:32 +01:00
|
|
|
become_user: "{{ pg_user }}"
|
|
|
|
become: yes
|
2019-03-26 13:11:47 +01:00
|
|
|
postgresql_info:
|
2019-03-18 12:31:32 +01:00
|
|
|
db: "{{ db_default }}"
|
|
|
|
login_user: "{{ pg_user }}"
|
|
|
|
filter:
|
|
|
|
- ver*
|
|
|
|
- rol*
|
|
|
|
register: result
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- result.version != {}
|
|
|
|
- result.roles
|
|
|
|
- result.databases == {}
|
|
|
|
- result.repl_slots == {}
|
|
|
|
- result.replications == {}
|
|
|
|
- result.settings == {}
|
|
|
|
- result.tablespaces == {}
|
|
|
|
|
2019-03-26 13:11:47 +01:00
|
|
|
- name: postgresql_info - check filter param passed by string
|
2019-03-18 12:31:32 +01:00
|
|
|
become_user: "{{ pg_user }}"
|
|
|
|
become: yes
|
2019-03-26 13:11:47 +01:00
|
|
|
postgresql_info:
|
2019-03-18 12:31:32 +01:00
|
|
|
db: "{{ db_default }}"
|
|
|
|
filter: ver*,role*
|
|
|
|
login_user: "{{ pg_user }}"
|
|
|
|
register: result
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- result.version != {}
|
|
|
|
- result.roles
|
|
|
|
- result.databases == {}
|
|
|
|
- result.repl_slots == {}
|
|
|
|
- result.replications == {}
|
|
|
|
- result.settings == {}
|
|
|
|
- result.tablespaces == {}
|
|
|
|
|
2019-03-26 13:11:47 +01:00
|
|
|
- name: postgresql_info - check filter param passed by string
|
2019-03-18 12:31:32 +01:00
|
|
|
become_user: "{{ pg_user }}"
|
|
|
|
become: yes
|
2019-03-26 13:11:47 +01:00
|
|
|
postgresql_info:
|
2019-03-18 12:31:32 +01:00
|
|
|
db: "{{ db_default }}"
|
|
|
|
filter: ver*
|
|
|
|
login_user: "{{ pg_user }}"
|
|
|
|
register: result
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- result.version
|
|
|
|
- result.roles == {}
|
|
|
|
|
2019-03-26 13:11:47 +01:00
|
|
|
- name: postgresql_info - check excluding filter param passed by list
|
2019-03-18 12:31:32 +01:00
|
|
|
become_user: "{{ pg_user }}"
|
|
|
|
become: yes
|
2019-03-26 13:11:47 +01:00
|
|
|
postgresql_info:
|
2019-03-18 12:31:32 +01:00
|
|
|
db: "{{ db_default }}"
|
|
|
|
filter:
|
|
|
|
- "!ver*"
|
|
|
|
- "!rol*"
|
|
|
|
login_user: "{{ pg_user }}"
|
|
|
|
register: result
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- result.version == {}
|
|
|
|
- result.roles == {}
|
|
|
|
- result.databases
|