|
|
|
@ -1,28 +1,67 @@
|
|
|
|
|
# Test code for the postgresql_info module
|
|
|
|
|
# Copyright: (c) 2019, Andrew Klychkov (@Andersson007) <aaklychkov@mail.ru>
|
|
|
|
|
# Copyright: (c) 2020, Andrew Klychkov (@Andersson007) <aaklychkov@mail.ru>
|
|
|
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
|
|
|
|
|
|
- name: postgresql_info - create role to check session_role
|
|
|
|
|
become_user: "{{ pg_user }}"
|
|
|
|
|
become: yes
|
|
|
|
|
postgresql_user:
|
|
|
|
|
db: "{{ db_default }}"
|
|
|
|
|
login_user: "{{ pg_user }}"
|
|
|
|
|
name: session_superuser
|
|
|
|
|
role_attr_flags: SUPERUSER
|
|
|
|
|
- vars:
|
|
|
|
|
task_parameters: &task_parameters
|
|
|
|
|
become_user: '{{ pg_user }}'
|
|
|
|
|
become: yes
|
|
|
|
|
register: result
|
|
|
|
|
pg_parameters: &pg_parameters
|
|
|
|
|
login_user: '{{ pg_user }}'
|
|
|
|
|
login_db: '{{ db_default }}'
|
|
|
|
|
|
|
|
|
|
- name: postgresql_info - test return values and session_role param
|
|
|
|
|
become_user: "{{ pg_user }}"
|
|
|
|
|
become: yes
|
|
|
|
|
postgresql_info:
|
|
|
|
|
db: "{{ db_default }}"
|
|
|
|
|
login_user: "{{ pg_user }}"
|
|
|
|
|
session_role: session_superuser
|
|
|
|
|
register: result
|
|
|
|
|
ignore_errors: yes
|
|
|
|
|
block:
|
|
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
|
that:
|
|
|
|
|
- name: Create test subscription
|
|
|
|
|
<<: *task_parameters
|
|
|
|
|
postgresql_subscription:
|
|
|
|
|
<<: *pg_parameters
|
|
|
|
|
login_port: '{{ replica_port }}'
|
|
|
|
|
name: '{{ test_subscription }}'
|
|
|
|
|
login_db: '{{ test_db }}'
|
|
|
|
|
state: present
|
|
|
|
|
publications: '{{ test_pub }}'
|
|
|
|
|
connparams:
|
|
|
|
|
host: 127.0.0.1
|
|
|
|
|
port: '{{ master_port }}'
|
|
|
|
|
user: '{{ replication_role }}'
|
|
|
|
|
password: '{{ replication_pass }}'
|
|
|
|
|
dbname: '{{ test_db }}'
|
|
|
|
|
|
|
|
|
|
- name: Create test subscription
|
|
|
|
|
<<: *task_parameters
|
|
|
|
|
postgresql_subscription:
|
|
|
|
|
<<: *pg_parameters
|
|
|
|
|
login_port: '{{ replica_port }}'
|
|
|
|
|
name: '{{ test_subscription2 }}'
|
|
|
|
|
login_db: '{{ test_db }}'
|
|
|
|
|
state: present
|
|
|
|
|
publications: '{{ test_pub2 }}'
|
|
|
|
|
connparams:
|
|
|
|
|
host: 127.0.0.1
|
|
|
|
|
port: '{{ master_port }}'
|
|
|
|
|
user: '{{ replication_role }}'
|
|
|
|
|
password: '{{ replication_pass }}'
|
|
|
|
|
dbname: '{{ test_db }}'
|
|
|
|
|
|
|
|
|
|
- name: postgresql_info - create role to check session_role
|
|
|
|
|
<<: *task_parameters
|
|
|
|
|
postgresql_user:
|
|
|
|
|
<<: *pg_parameters
|
|
|
|
|
login_port: '{{ replica_port }}'
|
|
|
|
|
login_user: "{{ pg_user }}"
|
|
|
|
|
name: session_superuser
|
|
|
|
|
role_attr_flags: SUPERUSER
|
|
|
|
|
|
|
|
|
|
- name: postgresql_info - test return values and session_role param
|
|
|
|
|
<<: *task_parameters
|
|
|
|
|
postgresql_info:
|
|
|
|
|
<<: *pg_parameters
|
|
|
|
|
login_port: '{{ replica_port }}'
|
|
|
|
|
session_role: session_superuser
|
|
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
|
that:
|
|
|
|
|
- result.version != {}
|
|
|
|
|
- result.databases.{{ db_default }}.collate
|
|
|
|
|
- result.databases.{{ db_default }}.languages
|
|
|
|
@ -31,41 +70,39 @@
|
|
|
|
|
- result.settings
|
|
|
|
|
- result.tablespaces
|
|
|
|
|
- result.roles
|
|
|
|
|
- result.subscriptions.{{ test_db }}.{{ test_subscription }}
|
|
|
|
|
- result.subscriptions.{{ test_db }}.{{ test_subscription2 }}
|
|
|
|
|
|
|
|
|
|
- name: postgresql_info - check filter param passed by list
|
|
|
|
|
become_user: "{{ pg_user }}"
|
|
|
|
|
become: yes
|
|
|
|
|
postgresql_info:
|
|
|
|
|
db: "{{ db_default }}"
|
|
|
|
|
login_user: "{{ pg_user }}"
|
|
|
|
|
filter:
|
|
|
|
|
- ver*
|
|
|
|
|
- rol*
|
|
|
|
|
register: result
|
|
|
|
|
ignore_errors: yes
|
|
|
|
|
- name: postgresql_info - check filter param passed by list
|
|
|
|
|
<<: *task_parameters
|
|
|
|
|
postgresql_info:
|
|
|
|
|
<<: *pg_parameters
|
|
|
|
|
login_port: '{{ replica_port }}'
|
|
|
|
|
filter:
|
|
|
|
|
- ver*
|
|
|
|
|
- rol*
|
|
|
|
|
- subscr*
|
|
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
|
that:
|
|
|
|
|
- assert:
|
|
|
|
|
that:
|
|
|
|
|
- result.version != {}
|
|
|
|
|
- result.roles
|
|
|
|
|
- result.subscriptions.{{ test_db }}.{{ test_subscription }} != {}
|
|
|
|
|
- result.subscriptions.{{ test_db }}.{{ test_subscription2 }} != {}
|
|
|
|
|
- result.databases == {}
|
|
|
|
|
- result.repl_slots == {}
|
|
|
|
|
- result.replications == {}
|
|
|
|
|
- result.settings == {}
|
|
|
|
|
- result.tablespaces == {}
|
|
|
|
|
|
|
|
|
|
- name: postgresql_info - check filter param passed by string
|
|
|
|
|
become_user: "{{ pg_user }}"
|
|
|
|
|
become: yes
|
|
|
|
|
postgresql_info:
|
|
|
|
|
db: "{{ db_default }}"
|
|
|
|
|
filter: ver*,role*
|
|
|
|
|
login_user: "{{ pg_user }}"
|
|
|
|
|
register: result
|
|
|
|
|
ignore_errors: yes
|
|
|
|
|
- name: postgresql_info - check filter param passed by string
|
|
|
|
|
<<: *task_parameters
|
|
|
|
|
postgresql_info:
|
|
|
|
|
<<: *pg_parameters
|
|
|
|
|
filter: ver*,role*
|
|
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
|
that:
|
|
|
|
|
- assert:
|
|
|
|
|
that:
|
|
|
|
|
- result.version != {}
|
|
|
|
|
- result.roles
|
|
|
|
|
- result.databases == {}
|
|
|
|
@ -74,35 +111,27 @@
|
|
|
|
|
- result.settings == {}
|
|
|
|
|
- result.tablespaces == {}
|
|
|
|
|
|
|
|
|
|
- name: postgresql_info - check filter param passed by string
|
|
|
|
|
become_user: "{{ pg_user }}"
|
|
|
|
|
become: yes
|
|
|
|
|
postgresql_info:
|
|
|
|
|
db: "{{ db_default }}"
|
|
|
|
|
filter: ver*
|
|
|
|
|
login_user: "{{ pg_user }}"
|
|
|
|
|
register: result
|
|
|
|
|
ignore_errors: yes
|
|
|
|
|
- name: postgresql_info - check filter param passed by string
|
|
|
|
|
<<: *task_parameters
|
|
|
|
|
postgresql_info:
|
|
|
|
|
<<: *pg_parameters
|
|
|
|
|
filter: ver*
|
|
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
|
that:
|
|
|
|
|
- assert:
|
|
|
|
|
that:
|
|
|
|
|
- result.version
|
|
|
|
|
- result.roles == {}
|
|
|
|
|
|
|
|
|
|
- name: postgresql_info - check excluding filter param passed by list
|
|
|
|
|
become_user: "{{ pg_user }}"
|
|
|
|
|
become: yes
|
|
|
|
|
postgresql_info:
|
|
|
|
|
db: "{{ db_default }}"
|
|
|
|
|
filter:
|
|
|
|
|
- name: postgresql_info - check excluding filter param passed by list
|
|
|
|
|
<<: *task_parameters
|
|
|
|
|
postgresql_info:
|
|
|
|
|
<<: *pg_parameters
|
|
|
|
|
filter:
|
|
|
|
|
- "!ver*"
|
|
|
|
|
- "!rol*"
|
|
|
|
|
login_user: "{{ pg_user }}"
|
|
|
|
|
register: result
|
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
|
that:
|
|
|
|
|
- assert:
|
|
|
|
|
that:
|
|
|
|
|
- result.version == {}
|
|
|
|
|
- result.roles == {}
|
|
|
|
|
- result.databases
|
|
|
|
|