112
112
type: bool
113
113
aliases:
114
114
- 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
143
115
password:
144
116
description:
145
117
- 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).
146
121
type: str
147
122
default: ''
148
- aliases:
149
- - login_password
150
123
ssl_mode:
151
124
description:
152
125
- Determines whether or with what priority a secure SSL TCP/IP connection will be negotiated with the server.
193
166
access via privileges granted to any role R is a member of including C(PUBLIC).
194
167
- Note that when you use C(PUBLIC) role, the module always reports that the state has been changed.
195
168
- 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
197
170
another user also, R can still access database objects via these privileges.
198
171
- When revoking privileges, C(RESTRICT) is assumed (see PostgreSQL docs).
199
172
@@ -525,9 +498,9 @@ def __init__(self, params, module):
525
498
# check which values are empty and don't include in the **kw
526
499
# dictionary
527
500
params_map = {
528
- "host " : "host" ,
529
- "login " : "user" ,
530
- "password " : "password" ,
501
+ "login_host " : "host" ,
502
+ "login_user " : "user" ,
503
+ "login_password " : "password" ,
531
504
"port" : "port" ,
532
505
"database" : "database" ,
533
506
"ssl_mode" : "sslmode" ,
@@ -537,10 +510,10 @@ def __init__(self, params, module):
537
510
kw = dict ((params_map [k ], getattr (params , k )) for k in params_map
538
511
if getattr (params , k ) != '' and getattr (params , k ) is not None )
539
512
540
- # If a unix_socket is specified, incorporate it here.
513
+ # If a login_unix_socket is specified, incorporate it here.
541
514
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
544
517
545
518
sslrootcert = params .ca_cert
546
519
if psycopg2 .__version__ < '2.4.3' and sslrootcert is not None :
@@ -1070,13 +1043,16 @@ def main():
1070
1043
target_roles = dict (required = False ),
1071
1044
grant_option = dict (required = False , type = 'bool' ,
1072
1045
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' ),
1077
1051
fail_on_role = dict (type = 'bool' , default = True ),
1078
1052
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' ),
1080
1056
)
1081
1057
1082
1058
module = AnsibleModule (
@@ -1089,6 +1065,16 @@ def main():
1089
1065
1090
1066
# Create type object as namespace for module params
1091
1067
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
+
1092
1078
# param "schema": default, allowed depends on param "type"
1093
1079
if p .type in ['table' , 'sequence' , 'function' , 'procedure' , 'type' , 'default_privs' ]:
1094
1080
if p .objs == 'schemas' or p .schema == 'not-specified' :
0 commit comments