ensure we use delegated vars on delegation
this prevents falling back to connection vars from the inventory_hostname when matching connection var is not in delegated host.
This commit is contained in:
parent
0a457230ab
commit
292be944c6
1 changed files with 6 additions and 3 deletions
|
@ -359,12 +359,15 @@ class PlayContext(Base):
|
||||||
for variable_name in variable_names:
|
for variable_name in variable_names:
|
||||||
if attr in attrs_considered:
|
if attr in attrs_considered:
|
||||||
continue
|
continue
|
||||||
if isinstance(delegated_vars, dict) and variable_name in delegated_vars:
|
# if delegation task ONLY use delegated host vars, avoid delegated FOR host vars
|
||||||
setattr(new_info, attr, delegated_vars[variable_name])
|
if task.delegate_to is not None:
|
||||||
attrs_considered.append(attr)
|
if isinstance(delegated_vars, dict) and variable_name in delegated_vars:
|
||||||
|
setattr(new_info, attr, delegated_vars[variable_name])
|
||||||
|
attrs_considered.append(attr)
|
||||||
elif variable_name in variables:
|
elif variable_name in variables:
|
||||||
setattr(new_info, attr, variables[variable_name])
|
setattr(new_info, attr, variables[variable_name])
|
||||||
attrs_considered.append(attr)
|
attrs_considered.append(attr)
|
||||||
|
# no else, as no other vars should be considered
|
||||||
|
|
||||||
# make sure we get port defaults if needed
|
# make sure we get port defaults if needed
|
||||||
if new_info.port is None and C.DEFAULT_REMOTE_PORT is not None:
|
if new_info.port is None and C.DEFAULT_REMOTE_PORT is not None:
|
||||||
|
|
Loading…
Reference in a new issue