|
|
@ -442,18 +442,22 @@ class PlayContextSpec(Spec):
|
|
|
|
raise
|
|
|
|
raise
|
|
|
|
|
|
|
|
|
|
|
|
LOG.info(
|
|
|
|
LOG.info(
|
|
|
|
'Used PlayContext fallback for plugin=%r, option=%r',
|
|
|
|
'Used fallback=PlayContext.%s for plugin=%r, option=%r',
|
|
|
|
self._connection, name,
|
|
|
|
name, self._connection, name,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
return getattr(self._play_context, name)
|
|
|
|
return getattr(self._play_context, name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _connection_option(self, name, fallback_attr=None):
|
|
|
|
def _connection_option(self, name):
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
return self._connection.get_option(name, hostvars=self._task_vars)
|
|
|
|
return self._connection.get_option(name, hostvars=self._task_vars)
|
|
|
|
except KeyError:
|
|
|
|
except KeyError:
|
|
|
|
LOG.debug('Used PlayContext fallback for option=%r', name)
|
|
|
|
if fallback_attr is None:
|
|
|
|
return getattr(self._play_context, name)
|
|
|
|
fallback_attr = name
|
|
|
|
|
|
|
|
LOG.info(
|
|
|
|
|
|
|
|
'Used fallback=PlayContext.%s for plugin=%r, option=%r',
|
|
|
|
|
|
|
|
fallback_attr, self._connection, name,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
return getattr(self._play_context, fallback_attr)
|
|
|
|
|
|
|
|
|
|
|
|
def transport(self):
|
|
|
|
def transport(self):
|
|
|
|
return self._transport
|
|
|
|
return self._transport
|
|
|
@ -462,7 +466,7 @@ class PlayContextSpec(Spec):
|
|
|
|
return self._inventory_name
|
|
|
|
return self._inventory_name
|
|
|
|
|
|
|
|
|
|
|
|
def remote_addr(self):
|
|
|
|
def remote_addr(self):
|
|
|
|
return self._play_context.remote_addr
|
|
|
|
return self._connection_option('host', fallback_attr='remote_addr')
|
|
|
|
|
|
|
|
|
|
|
|
def remote_user(self):
|
|
|
|
def remote_user(self):
|
|
|
|
return self._connection_option('remote_user')
|
|
|
|
return self._connection_option('remote_user')
|
|
|
|