diff --git a/changelogs/fragments/suppress-paramiko-warnings.yml b/changelogs/fragments/suppress-paramiko-warnings.yml new file mode 100644 index 00000000000..15c726cb366 --- /dev/null +++ b/changelogs/fragments/suppress-paramiko-warnings.yml @@ -0,0 +1,2 @@ +minor_changes: + - Suppress cryptography deprecation warnings for Blowfish and TripleDES when the ``paramiko`` Python module is installed. diff --git a/lib/ansible/module_utils/compat/paramiko.py b/lib/ansible/module_utils/compat/paramiko.py index 8c84261cef8..302309cdaa8 100644 --- a/lib/ansible/module_utils/compat/paramiko.py +++ b/lib/ansible/module_utils/compat/paramiko.py @@ -11,7 +11,12 @@ PARAMIKO_IMPORT_ERR = None try: with warnings.catch_warnings(): - warnings.filterwarnings('ignore', message='Blowfish has been deprecated', category=UserWarning) + # Blowfish has been moved, but the deprecated import is used by paramiko versions older than 2.9.5. + # See: https://github.com/paramiko/paramiko/pull/2039 + warnings.filterwarnings('ignore', message='Blowfish has been ', category=UserWarning) + # TripleDES has been moved, but the deprecated import is used by paramiko versions older than 3.3.2 and 3.4.1. + # See: https://github.com/paramiko/paramiko/pull/2421 + warnings.filterwarnings('ignore', message='TripleDES has been ', category=UserWarning) import paramiko # pylint: disable=unused-import # paramiko and gssapi are incompatible and raise AttributeError not ImportError # When running in FIPS mode, cryptography raises InternalError