mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
added become check back to connections
This commit is contained in:
parent
de82c953f2
commit
c3ccf26b70
1 changed files with 6 additions and 3 deletions
|
@ -63,10 +63,10 @@ class ConnectionBase(with_metaclass(ABCMeta, object)):
|
||||||
if not hasattr(self, '_connected'):
|
if not hasattr(self, '_connected'):
|
||||||
self._connected = False
|
self._connected = False
|
||||||
|
|
||||||
def _become_method_supported(self, become_method):
|
def _become_method_supported(self):
|
||||||
''' Checks if the current class supports this privilege escalation method '''
|
''' Checks if the current class supports this privilege escalation method '''
|
||||||
|
|
||||||
if become_method in self.__class__.become_methods:
|
if self._connection_info.become_method in self.__class__.become_methods:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
raise AnsibleError("Internal Error: this connection module does not support running commands via %s" % become_method)
|
raise AnsibleError("Internal Error: this connection module does not support running commands via %s" % become_method)
|
||||||
|
@ -90,7 +90,10 @@ class ConnectionBase(with_metaclass(ABCMeta, object)):
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def _connect(self):
|
def _connect(self):
|
||||||
"""Connect to the host we've been initialized with"""
|
"""Connect to the host we've been initialized with"""
|
||||||
pass
|
|
||||||
|
# Check if PE is supported
|
||||||
|
if self._connection_info.become:
|
||||||
|
self.__become_method_supported()
|
||||||
|
|
||||||
@ensure_connect
|
@ensure_connect
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
|
|
Loading…
Reference in a new issue