mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 13:52:54 +00:00
[stable-10] Backport fixes from community.proxmox (#10553)
* Import paramiko directly.8f90ab075c* Remove deprecated disable_lookups parameter.c0fc31241b
This commit is contained in:
2
changelogs/fragments/108--disable_lookups.yml
Normal file
2
changelogs/fragments/108--disable_lookups.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
bugfixes:
|
||||
- "proxmox inventory plugin - avoid using deprecated option when templating options (https://github.com/ansible-collections/community.proxmox/pull/108, https://github.com/ansible-collections/community.general/pull/10553)."
|
||||
3
changelogs/fragments/151-connection-paramiko.yml
Normal file
3
changelogs/fragments/151-connection-paramiko.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
bugfixes:
|
||||
- "proxmox_pct_remote connection plugin - avoid deprecated ansible-core paramiko import helper, import paramiko directly instead
|
||||
(https://github.com/ansible-collections/community.proxmox/issues/146, https://github.com/ansible-collections/community.proxmox/pull/151, https://github.com/ansible-collections/community.general/pull/10553)."
|
||||
@@ -398,6 +398,7 @@ import os
|
||||
import pathlib
|
||||
import socket
|
||||
import tempfile
|
||||
import traceback
|
||||
import typing as t
|
||||
|
||||
from ansible.errors import (
|
||||
@@ -406,14 +407,20 @@ from ansible.errors import (
|
||||
AnsibleError,
|
||||
)
|
||||
from ansible_collections.community.general.plugins.module_utils._filelock import FileLock, LockTimeout
|
||||
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
|
||||
from ansible.module_utils.common.text.converters import to_bytes, to_native, to_text
|
||||
from ansible.module_utils.compat.paramiko import PARAMIKO_IMPORT_ERR, paramiko
|
||||
from ansible.module_utils.compat.version import LooseVersion
|
||||
from ansible.plugins.connection import ConnectionBase
|
||||
from ansible.utils.display import Display
|
||||
from ansible.utils.path import makedirs_safe
|
||||
from binascii import hexlify
|
||||
|
||||
try:
|
||||
import paramiko
|
||||
PARAMIKO_IMPORT_ERR = None
|
||||
except ImportError:
|
||||
paramiko = None
|
||||
PARAMIKO_IMPORT_ERR = traceback.format_exc()
|
||||
|
||||
|
||||
display = Display()
|
||||
|
||||
@@ -513,7 +520,7 @@ class Connection(ConnectionBase):
|
||||
def _connect(self) -> Connection:
|
||||
""" activates the connection object """
|
||||
|
||||
if paramiko is None:
|
||||
if PARAMIKO_IMPORT_ERR is not None:
|
||||
raise AnsibleError(f'paramiko is not installed: {to_native(PARAMIKO_IMPORT_ERR)}')
|
||||
|
||||
port = self.get_option('port')
|
||||
|
||||
@@ -687,7 +687,7 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
||||
for o in ('url', 'user', 'password', 'token_id', 'token_secret'):
|
||||
v = self.get_option(o)
|
||||
if self.templar.is_template(v):
|
||||
v = self.templar.template(v, disable_lookups=False)
|
||||
v = self.templar.template(v)
|
||||
setattr(self, f'proxmox_{o}', v)
|
||||
|
||||
# some more cleanup and validation
|
||||
|
||||
@@ -14,7 +14,6 @@ from ansible_collections.community.general.plugins.connection.proxmox_pct_remote
|
||||
from ansible_collections.community.general.plugins.module_utils._filelock import FileLock, LockTimeout
|
||||
from ansible.errors import AnsibleError, AnsibleAuthenticationFailure, AnsibleConnectionFailure
|
||||
from ansible.module_utils.common.text.converters import to_bytes
|
||||
from ansible.module_utils.compat.paramiko import paramiko
|
||||
from ansible.playbook.play_context import PlayContext
|
||||
from ansible.plugins.loader import connection_loader
|
||||
from io import StringIO
|
||||
@@ -22,7 +21,7 @@ from pathlib import Path
|
||||
from unittest.mock import patch, MagicMock, mock_open
|
||||
|
||||
|
||||
pytest.importorskip('paramiko')
|
||||
paramiko = pytest.importorskip('paramiko')
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
Reference in New Issue
Block a user