mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 03:41:25 -07:00
Add ability for connection plugins to set attributes based on host variables (v2)
This commit is contained in:
parent
8fae2abed4
commit
d34b586eb6
2 changed files with 14 additions and 1 deletions
|
@ -209,6 +209,8 @@ class TaskExecutor:
|
||||||
|
|
||||||
# get the connection and the handler for this execution
|
# get the connection and the handler for this execution
|
||||||
self._connection = self._get_connection(variables)
|
self._connection = self._get_connection(variables)
|
||||||
|
self._connection.set_host_overrides(host=self._host)
|
||||||
|
|
||||||
self._handler = self._get_action_handler(connection=self._connection, templar=templar)
|
self._handler = self._get_action_handler(connection=self._connection, templar=templar)
|
||||||
|
|
||||||
# Evaluate the conditional (if any) for this task, which we do before running
|
# Evaluate the conditional (if any) for this task, which we do before running
|
||||||
|
|
|
@ -64,6 +64,17 @@ class ConnectionBase:
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
|
def set_host_overrides(self, host):
|
||||||
|
'''
|
||||||
|
An optional method, which can be used to set connection plugin parameters
|
||||||
|
from variables set on the host (or groups to which the host belongs)
|
||||||
|
|
||||||
|
Any connection plugin using this should first initialize its attributes in
|
||||||
|
an overridden `def __init__(self):`, and then use `host.get_vars()` to find
|
||||||
|
variables which may be used to set those attributes in this method.
|
||||||
|
'''
|
||||||
|
pass
|
||||||
|
|
||||||
@abstractproperty
|
@abstractproperty
|
||||||
def transport(self):
|
def transport(self):
|
||||||
"""String used to identify this Connection class from other classes"""
|
"""String used to identify this Connection class from other classes"""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue