Skip to content

Commit d5d8e9a

Browse files
authored
Deprecate port option (#860)
* Deprecate port aliases in favor of login_port
1 parent 8b2d17b commit d5d8e9a

File tree

6 files changed

+27
-14
lines changed

6 files changed

+27
-14
lines changed

changelogs/fragments/0-port.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
deprecated_features:
2+
- postgresql modules - the ``port`` alias is deprecated and will be removed in ``community.postgresql 5.0.0``, use the ``login_port`` argument instead.

plugins/doc_fragments/postgres.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@ class ModuleDocFragment(object):
3535
type: str
3636
default: ''
3737
aliases: [ unix_socket ]
38-
port:
38+
login_port:
3939
description:
4040
- Database port to connect to.
41+
- The C(port) alias is deprecated and will be removed in the next major release. Use C(login_port) instead.
4142
type: int
4243
default: 5432
43-
aliases: [ login_port ]
44+
aliases: [ port ]
4445
ssl_mode:
4546
description:
4647
- Determines whether or with what priority a secure SSL TCP/IP connection will be negotiated with the server.

plugins/module_utils/postgres.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,16 @@ def postgres_common_argument_spec():
104104
'collection_name': 'community.postgresql',
105105
}],
106106
),
107-
port=dict(
107+
login_port=dict(
108108
type='int',
109109
default=int(env_vars.get("PGPORT", 5432)),
110-
aliases=['login_port']
110+
aliases=['port'], deprecated_aliases=[
111+
{
112+
'name': 'port',
113+
'version': '5.0.0',
114+
'collection_name': 'community.postgresql',
115+
}
116+
],
111117
),
112118
ssl_mode=dict(
113119
default='prefer',
@@ -286,7 +292,7 @@ def get_conn_params(module, params_dict, warn_db_default=True):
286292
"login_host": "host",
287293
"login_user": "user",
288294
"login_password": "password",
289-
"port": "port",
295+
"login_port": "port",
290296
"ssl_mode": "sslmode",
291297
"ca_cert": "sslrootcert",
292298
"ssl_cert": "sslcert",

plugins/modules/postgresql_slot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
community.postgresql.postgresql_slot:
130130
name: logical_one
131131
login_host: mydatabase.example.org
132-
port: 5433
132+
login_port: 5433
133133
login_user: ourSuperuser
134134
login_password: thePassword
135135
state: absent

tests/integration/targets/setup_postgresql_db/tasks/main.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# WARNING: These are designed specifically for Ansible tests #
33
# and should not be used as examples of how to write Ansible roles #
44
####################################################################
5-
65
- name: python 2
76
set_fact:
87
python_suffix: ''
@@ -49,15 +48,14 @@
4948

5049
- name: remove old db config and files (debian)
5150
file:
52-
path: '{{ loop_item }}'
51+
path: '{{ item }}'
5352
state: absent
5453
ignore_errors: true
5554
when: ansible_os_family == "Debian"
5655
loop:
56+
- '{{ pg_dir }}'
5757
- /etc/postgresql
5858
- /var/lib/postgresql
59-
loop_control:
60-
loop_var: loop_item
6159

6260
#
6361
# Prepare Ubuntu for PostgreSQL install

tests/unit/plugins/module_utils/test_postgres.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
login_password=dict(default='test', no_log=True),
1818
login_host=dict(default='test'),
1919
login_unix_socket=dict(default=''),
20-
port=dict(type='int', default=5432, aliases=['login_port']),
20+
login_port=dict(type='int', default=5432, aliases=['port']),
2121
ssl_mode=dict(
2222
default='prefer',
2323
choices=['allow', 'disable', 'prefer', 'require', 'verify-ca', 'verify-full']
@@ -31,7 +31,7 @@
3131
user=dict(default='postgres'),
3232
password=dict(default='test', no_log=True),
3333
host=dict(default='test'),
34-
port=dict(type='int', default=5432, aliases=['login_port']),
34+
port=dict(type='int', aliases=['port'], default=5432),
3535
sslmode=dict(
3636
default='prefer',
3737
choices=['allow', 'disable', 'prefer', 'require', 'verify-ca', 'verify-full']
@@ -79,7 +79,13 @@ def test_postgres_common_argument_spec(self):
7979
'collection_name': 'community.postgresql',
8080
}
8181
]),
82-
port=dict(type='int', default=5432, aliases=['login_port']),
82+
login_port=dict(type='int', default=5432, aliases=['port'], deprecated_aliases=[
83+
{
84+
'collection_name': 'community.postgresql',
85+
'name': 'port',
86+
'version': '5.0.0'
87+
}
88+
]),
8389
ssl_mode=dict(
8490
default='prefer',
8591
choices=['allow', 'disable', 'prefer', 'require', 'verify-ca', 'verify-full']
@@ -92,7 +98,7 @@ def test_postgres_common_argument_spec(self):
9298
assert pg.postgres_common_argument_spec() == expected_dict
9399

94100
# Setting new values for checking environment variables
95-
expected_dict['port']['default'] = 5435
101+
expected_dict['login_port']['default'] = 5435
96102
expected_dict['login_user']['default'] = 'test_user'
97103

98104
# Setting environment variables

0 commit comments

Comments
 (0)