Skip to content

Conversation

@Perdu
Copy link
Contributor

@Perdu Perdu commented Dec 2, 2025

SUMMARY

ansible 2.20 deprecates importing from ansible.module_utils._text. This displays warnings to users of the modules.

For instance, this tasks:

- name: 'Create a postgres user for Debian-exim'
  community.postgresql.postgresql_user:
    name: 'Debian-exim'
  become: true
  become_user: 'postgres'

yields these warnings:

TASK [postgresql : Create a postgres user for Debian-exim] *********************
[WARNING]: Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
[DEPRECATION WARNING]: Importing 'to_bytes' from 'ansible.module_utils._text' is deprecated. This feature will be removed from ansible-core version 2.24. Use ansible.module_utils.common.text.converters instead.
[DEPRECATION WARNING]: Importing 'to_native' from 'ansible.module_utils._text' is deprecated. This feature will be removed from ansible-core version 2.24. Use ansible.module_utils.common.text.converters instead.
[DEPRECATION WARNING]: Importing 'to_text' from 'ansible.module_utils._text' is deprecated. This feature will be removed from ansible-core version 2.24. Use ansible.module_utils.common.text.converters instead.
ok: [instance]

This commit fixes all related warning by using ansible.module_utils.common.text.converters as requested by ansible.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

Happens in various places

@andreasscherbaum
Copy link
Collaborator

I kicked off the tests, a couple of them are failing.

@Perdu
Copy link
Contributor Author

Perdu commented Dec 2, 2025

I kicked off the tests, a couple of them are failing.

I dug into it, and all these fails seem unrelated to the patch:

https://dev.azure.com/ansible/community.postgresql/_build/results?buildId=165038&view=logs&j=a429a702-48d3-54c6-a0ae-9bbe5e258d6b&t=0aa2a608-45f3-53e7-212a-4a161d8c44de

03:00 FATAL: Command "ssh -i /home/AzDevOps_azpcontainer/.ansible/test/id_rsa -o BatchMode=yes -o ServerAliveCountMax=4 -o ServerAliveInterval=15 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -q -vvv -E /tmp/ansible-test-ssh-debug-bthk1j71.log -p 22 ec2-user@28zmx-t10ps-yxvvr-8a79f-v75ml-03uhj7p.us-east-1.ip.aws 'sudo -in sh -c '"'"'tar oxzf - -C /root'"'"''" returned exit status 255.
03:00 >>> SSH Debug Output
03:00 OpenSSH_9.6p1 Ubuntu-3ubuntu13.13, OpenSSL 3.0.13 30 Jan 2024
03:00 debug1: Reading configuration data /etc/ssh/ssh_config
03:00 debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
03:00 debug1: /etc/ssh/ssh_config line 21: Applying options for *
03:00 debug2: resolving "28zmx-t10ps-yxvvr-8a79f-v75ml-03uhj7p.us-east-1.ip.aws" port 22
03:00 debug3: resolve_host: lookup 28zmx-t10ps-yxvvr-8a79f-v75ml-03uhj7p.us-east-1.ip.aws:22
03:00 debug3: channel_clear_timeouts: clearing
03:00 debug3: ssh_connect_direct: entering
03:00 debug1: Connecting to 28zmx-t10ps-yxvvr-8a79f-v75ml-03uhj7p.us-east-1.ip.aws [13.221.69.133] port 22.
03:00 debug3: set_sock_tos: set socket 4 IP_TOS 0x10
03:00 debug1: Connection established.
03:00 debug1: identity file /home/AzDevOps_azpcontainer/.ansible/test/id_rsa type 0
03:00 debug1: identity file /home/AzDevOps_azpcontainer/.ansible/test/id_rsa-cert type -1
03:00 debug1: Local version string SSH-2.0-OpenSSH_9.6p1 Ubuntu-3ubuntu13.13
03:00 kex_exchange_identification: read: Connection reset by peer
03:00 Connection reset by 13.221.69.133 port 22

This is just a common CI job fail due to network issue

https://dev.azure.com/ansible/community.postgresql/_build/results?buildId=165038&view=logs&j=4d999b1f-f183-5e77-5533-67637ede41a2&t=9b2ad04f-1c68-5189-c5eb-50576517ecbf

00:10 FATAL: Environment --remote rhel/8.8 is unknown. Use a predefined environment instead. Alternatively, to use an unknown environment, use the --python option to specify a Python version.

This seems to be an issue with the CI itself

https://dev.azure.com/ansible/community.postgresql/_build/results?buildId=165038&view=logs&j=df593170-0476-56b6-4a33-d8e2815d43d8&t=ed5b4094-b5e7-57c7-f236-602faf856c9f

01:27 ERROR: Found 9 pylint issue(s) which need to be resolved:
01:27 ERROR: plugins/module_utils/postgres.py:22:0: ansible-bad-import-from: Import iteritems from the Python standard library equivalent instead of ansible.module_utils.six (50%)
01:27 ERROR: plugins/modules/postgresql_copy.py:184:0: ansible-bad-import-from: Import iteritems from the Python standard library equivalent instead of ansible.module_utils.six (0%)
01:27 ERROR: plugins/modules/postgresql_info.py:159:0: ansible-bad-import-from: Import iteritems from the Python standard library equivalent instead of ansible.module_utils.six (50%)
01:27 ERROR: plugins/modules/postgresql_publication.py:257:0: ansible-bad-import-from: Import iteritems from the Python standard library equivalent instead of ansible.module_utils.six (0%)
01:27 ERROR: plugins/modules/postgresql_query.py:269:0: ansible-bad-import-from: Import iteritems from the Python standard library equivalent instead of ansible.module_utils.six (50%)
01:27 ERROR: plugins/modules/postgresql_script.py:219:0: ansible-bad-import-from: Import iteritems from the Python standard library equivalent instead of ansible.module_utils.six (50%)
01:27 ERROR: plugins/modules/postgresql_subscription.py:217:0: ansible-bad-import-from: Import iteritems from the Python standard library equivalent instead of ansible.module_utils.six (0%)
01:27 ERROR: plugins/modules/postgresql_tablespace.py:195:0: ansible-bad-import-from: Import iteritems from the Python standard library equivalent instead of ansible.module_utils.six (0%)
01:27 ERROR: plugins/modules/postgresql_user_obj_stat_info.py:110:0: ansible-bad-import-from: Import iteritems from the Python standard library equivalent instead of ansible.module_utils.six (0%)

These are not the lines I modified, this seems to be an unrelated issue

Copy link
Collaborator

@Andersson007 Andersson007 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Perdu thanks, yes, they look unrelated, let's ignore them for now

Would you like to tackle the following errors here or maybe to fix them in another PR?:)

01:27 ERROR: plugins/module_utils/postgres.py:22:0: ansible-bad-import-from: Import iteritems from the Python standard library equivalent instead of ansible.module_utils.six (50%)
01:27 ERROR: plugins/modules/postgresql_copy.py:184:0: ansible-bad-import-from: Import iteritems from the Python standard library equivalent instead of ansible.module_utils.six (0%)
01:27 ERROR: plugins/modules/postgresql_info.py:159:0: ansible-bad-import-from: Import iteritems from the Python standard library equivalent instead of ansible.module_utils.six (50%)
01:27 ERROR: plugins/modules/postgresql_publication.py:257:0: ansible-bad-import-from: Import iteritems from the Python standard library equivalent instead of ansible.module_utils.six (0%)
01:27 ERROR: plugins/modules/postgresql_query.py:269:0: ansible-bad-import-from: Import iteritems from the Python standard library equivalent instead of ansible.module_utils.six (50%)
01:27 ERROR: plugins/modules/postgresql_script.py:219:0: ansible-bad-import-from: Import iteritems from the Python standard library equivalent instead of ansible.module_utils.six (50%)
01:27 ERROR: plugins/modules/postgresql_subscription.py:217:0: ansible-bad-import-from: Import iteritems from the Python standard library equivalent instead of ansible.module_utils.six (0%)
01:27 ERROR: plugins/modules/postgresql_tablespace.py:195:0: ansible-bad-import-from: Import iteritems from the Python standard library equivalent instead of ansible.module_utils.six (0%)
01:27 ERROR: plugins/modules/postgresql_user_obj_stat_info.py:110:0: ansible-bad-import-from: Import iteritems from the Python standard library equivalent instead of ansible.module_utils.six (0%)

@Andersson007
Copy link
Collaborator

The RHEL failures are addressed in #899 , let's not test against really ancient stuff

@andreasscherbaum
Copy link
Collaborator

The RHEL failures are addressed in #899 , let's not test against really ancient stuff

Let's merge this one first, and then rebase #898.

@hunleyd hunleyd merged commit 9f1898c into ansible-collections:main Dec 2, 2025
32 of 34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants