|
|
@ -547,7 +547,7 @@ class Connection(ansible.plugins.connection.ConnectionBase):
|
|
|
|
def connected(self):
|
|
|
|
def connected(self):
|
|
|
|
return self.context is not None
|
|
|
|
return self.context is not None
|
|
|
|
|
|
|
|
|
|
|
|
def _spec_from_via(self, via_spec):
|
|
|
|
def _spec_from_via(self, proxied_inventory_name, via_spec):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Produce a dict connection specifiction given a string `via_spec`, of
|
|
|
|
Produce a dict connection specifiction given a string `via_spec`, of
|
|
|
|
the form `[[become_method:]become_user@]inventory_hostname`.
|
|
|
|
the form `[[become_method:]become_user@]inventory_hostname`.
|
|
|
@ -555,15 +555,17 @@ class Connection(ansible.plugins.connection.ConnectionBase):
|
|
|
|
become_user, _, inventory_name = via_spec.rpartition('@')
|
|
|
|
become_user, _, inventory_name = via_spec.rpartition('@')
|
|
|
|
become_method, _, become_user = become_user.rpartition(':')
|
|
|
|
become_method, _, become_user = become_user.rpartition(':')
|
|
|
|
|
|
|
|
|
|
|
|
via_vars = self.host_vars[inventory_name]
|
|
|
|
# must use __contains__ to avoid a TypeError for a missing host on
|
|
|
|
if isinstance(via_vars, jinja2.runtime.Undefined):
|
|
|
|
# Ansible 2.3.
|
|
|
|
|
|
|
|
if self.host_vars is None or inventory_name not in self.host_vars:
|
|
|
|
raise ansible.errors.AnsibleConnectionFailure(
|
|
|
|
raise ansible.errors.AnsibleConnectionFailure(
|
|
|
|
self.unknown_via_msg % (
|
|
|
|
self.unknown_via_msg % (
|
|
|
|
via_spec,
|
|
|
|
via_spec,
|
|
|
|
inventory_name,
|
|
|
|
proxied_inventory_name,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
via_vars = self.host_vars[inventory_name]
|
|
|
|
return ansible_mitogen.transport_config.MitogenViaSpec(
|
|
|
|
return ansible_mitogen.transport_config.MitogenViaSpec(
|
|
|
|
inventory_name=inventory_name,
|
|
|
|
inventory_name=inventory_name,
|
|
|
|
host_vars=dict(via_vars), # TODO: make it lazy
|
|
|
|
host_vars=dict(via_vars), # TODO: make it lazy
|
|
|
@ -615,7 +617,7 @@ class Connection(ansible.plugins.connection.ConnectionBase):
|
|
|
|
|
|
|
|
|
|
|
|
if spec.mitogen_via():
|
|
|
|
if spec.mitogen_via():
|
|
|
|
stack = self._stack_from_spec(
|
|
|
|
stack = self._stack_from_spec(
|
|
|
|
self._spec_from_via(spec.mitogen_via()),
|
|
|
|
self._spec_from_via(spec.inventory_name(), spec.mitogen_via()),
|
|
|
|
stack=stack,
|
|
|
|
stack=stack,
|
|
|
|
seen_names=seen_names + (spec.inventory_name(),),
|
|
|
|
seen_names=seen_names + (spec.inventory_name(),),
|
|
|
|
)
|
|
|
|
)
|
|
|
|