mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
postgresql_info: add in_recovery return value to show if a service in recovery mode or not (#1091)
* postgresql_info: add in_recovery return value to show if a service is in recovery mode or not * add changelog fragment * fix sanity
This commit is contained in:
parent
159f38f4f2
commit
da7f9ffc3f
3 changed files with 20 additions and 1 deletions
|
@ -0,0 +1,2 @@
|
|||
minor_changes:
|
||||
- postgresql_info - add ``in_recovery`` return value to show if a service in recovery mode or not (https://github.com/ansible-collections/community.general/issues/1068).
|
|
@ -18,7 +18,7 @@ options:
|
|||
description:
|
||||
- Limit the collected information by comma separated string or YAML list.
|
||||
- Allowable values are C(version),
|
||||
C(databases), C(settings), C(tablespaces), C(roles),
|
||||
C(databases), C(in_recovery), C(settings), C(tablespaces), C(roles),
|
||||
C(replications), C(repl_slots).
|
||||
- By default, collects all subsets.
|
||||
- You can use shell-style (fnmatch) wildcard to pass groups of values (see Examples).
|
||||
|
@ -117,6 +117,11 @@ version:
|
|||
returned: always
|
||||
type: int
|
||||
sample: 1
|
||||
in_recovery:
|
||||
description: Indicates if the service is in recovery mode or not.
|
||||
returned: always
|
||||
type: bool
|
||||
sample: false
|
||||
databases:
|
||||
description: Information about databases.
|
||||
returned: always
|
||||
|
@ -550,6 +555,7 @@ class PgClusterInfo(object):
|
|||
self.cursor = db_conn_obj.connect()
|
||||
self.pg_info = {
|
||||
"version": {},
|
||||
"in_recovery": None,
|
||||
"tablespaces": {},
|
||||
"databases": {},
|
||||
"replications": {},
|
||||
|
@ -563,6 +569,7 @@ class PgClusterInfo(object):
|
|||
"""Collect information based on 'filter' option."""
|
||||
subset_map = {
|
||||
"version": self.get_pg_version,
|
||||
"in_recovery": self.get_recovery_state,
|
||||
"tablespaces": self.get_tablespaces,
|
||||
"databases": self.get_db_info,
|
||||
"replications": self.get_repl_info,
|
||||
|
@ -922,6 +929,10 @@ class PgClusterInfo(object):
|
|||
minor=int(raw[1]),
|
||||
)
|
||||
|
||||
def get_recovery_state(self):
|
||||
"""Get if the service is in recovery mode."""
|
||||
self.pg_info["in_recovery"] = self.__exec_sql("SELECT pg_is_in_recovery()")[0][0]
|
||||
|
||||
def get_db_info(self):
|
||||
"""Get information about the current database."""
|
||||
# Following query returns:
|
||||
|
|
|
@ -63,6 +63,7 @@
|
|||
- assert:
|
||||
that:
|
||||
- result.version != {}
|
||||
- result.in_recovery == false
|
||||
- result.databases.{{ db_default }}.collate
|
||||
- result.databases.{{ db_default }}.languages
|
||||
- result.databases.{{ db_default }}.namespaces
|
||||
|
@ -81,11 +82,13 @@
|
|||
filter:
|
||||
- ver*
|
||||
- rol*
|
||||
- in_recov*
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.version != {}
|
||||
- result.roles
|
||||
- result.in_recovery == false
|
||||
- result.databases == {}
|
||||
- result.repl_slots == {}
|
||||
- result.replications == {}
|
||||
|
@ -126,10 +129,12 @@
|
|||
filter:
|
||||
- "!ver*"
|
||||
- "!rol*"
|
||||
- "!in_rec*"
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.version == {}
|
||||
- result.in_recovery == None
|
||||
- result.roles == {}
|
||||
- result.databases
|
||||
|
||||
|
@ -144,6 +149,7 @@
|
|||
- assert:
|
||||
that:
|
||||
- result.version != {}
|
||||
- result.in_recovery == false
|
||||
- result.databases.{{ db_default }}.collate
|
||||
- result.databases.{{ db_default }}.languages
|
||||
- result.databases.{{ db_default }}.namespaces
|
||||
|
|
Loading…
Reference in a new issue