112112 type: bool
113113 aliases:
114114 - admin_option
115- host:
116- description:
117- - Database host address. If unspecified, connect via Unix socket.
118- type: str
119- default: ''
120- aliases:
121- - login_host
122- port:
123- description:
124- - Database port to connect to.
125- type: int
126- default: 5432
127- aliases:
128- - login_port
129- unix_socket:
130- description:
131- - Path to a Unix domain socket for local connections.
132- type: str
133- default: ''
134- aliases:
135- - login_unix_socket
136- login:
137- description:
138- - The username to authenticate with.
139- type: str
140- default: postgres
141- aliases:
142- - login_user
143115 password:
144116 description:
145117 - The password to authenticate with.
118+ - This option has been B(deprecated) and will be removed in community.postgresql 4.0.0,
119+ use the I(login_password) option instead.
120+ - Mutually exclusive with I(login_password).
146121 type: str
147122 default: ''
148- aliases:
149- - login_password
150123 ssl_mode:
151124 description:
152125 - Determines whether or with what priority a secure SSL TCP/IP connection will be negotiated with the server.
193166 access via privileges granted to any role R is a member of including C(PUBLIC).
194167- Note that when you use C(PUBLIC) role, the module always reports that the state has been changed.
195168- Note that when revoking privileges from a role R, you do so as the user
196- specified via I(login ). If R has been granted the same privileges by
169+ specified via I(login_user ). If R has been granted the same privileges by
197170 another user also, R can still access database objects via these privileges.
198171- When revoking privileges, C(RESTRICT) is assumed (see PostgreSQL docs).
199172
@@ -525,9 +498,9 @@ def __init__(self, params, module):
525498 # check which values are empty and don't include in the **kw
526499 # dictionary
527500 params_map = {
528- "host " : "host" ,
529- "login " : "user" ,
530- "password " : "password" ,
501+ "login_host " : "host" ,
502+ "login_user " : "user" ,
503+ "login_password " : "password" ,
531504 "port" : "port" ,
532505 "database" : "database" ,
533506 "ssl_mode" : "sslmode" ,
@@ -537,10 +510,10 @@ def __init__(self, params, module):
537510 kw = dict ((params_map [k ], getattr (params , k )) for k in params_map
538511 if getattr (params , k ) != '' and getattr (params , k ) is not None )
539512
540- # If a unix_socket is specified, incorporate it here.
513+ # If a login_unix_socket is specified, incorporate it here.
541514 is_localhost = "host" not in kw or kw ["host" ] == "" or kw ["host" ] == "localhost"
542- if is_localhost and params .unix_socket != "" :
543- kw ["host" ] = params .unix_socket
515+ if is_localhost and params .login_unix_socket != "" :
516+ kw ["host" ] = params .login_unix_socket
544517
545518 sslrootcert = params .ca_cert
546519 if psycopg2 .__version__ < '2.4.3' and sslrootcert is not None :
@@ -1070,13 +1043,16 @@ def main():
10701043 target_roles = dict (required = False ),
10711044 grant_option = dict (required = False , type = 'bool' ,
10721045 aliases = ['admin_option' ]),
1073- host = dict (default = '' , aliases = ['login_host' ]),
1074- unix_socket = dict (default = '' , aliases = ['login_unix_socket' ]),
1075- login = dict (default = 'postgres' , aliases = ['login_user' ]),
1076- password = dict (default = '' , aliases = ['login_password' ], no_log = True ),
1046+ # WARNING: password is deprecated and will be removed in community.postgresql 4.0.0,
1047+ # login_password should be used instead
1048+ password = dict (default = '' , no_log = True ,
1049+ removed_in_version = '4.0.0' ,
1050+ removed_from_collection = 'community.postgreql' ),
10771051 fail_on_role = dict (type = 'bool' , default = True ),
10781052 trust_input = dict (type = 'bool' , default = True ),
1079- usage_on_types = dict (type = 'bool' , default = True , removed_in_version = '3.0.0' , removed_from_collection = 'community.postgresql' ),
1053+ usage_on_types = dict (type = 'bool' , default = True ,
1054+ removed_in_version = '3.0.0' ,
1055+ removed_from_collection = 'community.postgresql' ),
10801056 )
10811057
10821058 module = AnsibleModule (
@@ -1089,6 +1065,16 @@ def main():
10891065
10901066 # Create type object as namespace for module params
10911067 p = type ('Params' , (), module .params )
1068+
1069+ # WARNING: password is deprecated and will be removed in community.postgresql 4.0.0,
1070+ # login_password should be used instead
1071+ # https://github.com/ansible-collections/community.postgresql/issues/406
1072+ if p .password :
1073+ if p .login_password :
1074+ module .fail_json (msg = 'Use the "password" or "login_password" option but not both '
1075+ 'to pass a password to log in with.' )
1076+ p .login_password = p .password
1077+
10921078 # param "schema": default, allowed depends on param "type"
10931079 if p .type in ['table' , 'sequence' , 'function' , 'procedure' , 'type' , 'default_privs' ]:
10941080 if p .objs == 'schemas' or p .schema == 'not-specified' :
0 commit comments