Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
3bd71d06
Commit
3bd71d06
authored
Sep 30, 2015
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use delegated_to field for play context remote_addr, if none other exists
Fixes #12527
parent
40bdf099
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
0 deletions
+18
-0
lib/ansible/playbook/play_context.py
+17
-0
lib/ansible/vars/__init__.py
+1
-0
No files found.
lib/ansible/playbook/play_context.py
View file @
3bd71d06
...
...
@@ -39,6 +39,13 @@ from ansible.utils.unicode import to_unicode
__all__
=
[
'PlayContext'
]
try
:
from
__main__
import
display
display
=
display
except
ImportError
:
from
ansible.utils.display
import
Display
display
=
Display
()
# the magic variable mapping dictionary below is used to translate
# host/inventory variables to fields in the PlayContext
# object. The dictionary values are tuples, to account for aliases
...
...
@@ -296,6 +303,16 @@ class PlayContext(Base):
# the host name in the delegated variable dictionary here
delegated_host_name
=
templar
.
template
(
task
.
delegate_to
)
delegated_vars
=
variables
.
get
(
'ansible_delegated_vars'
,
dict
())
.
get
(
delegated_host_name
,
dict
())
# make sure this delegated_to host has something set for its remote
# address, otherwise we default to connecting to it by name. This
# may happen when users put an IP entry into their inventory, or if
# they rely on DNS for a non-inventory hostname
for
address_var
in
MAGIC_VARIABLE_MAPPING
.
get
(
'remote_addr'
):
if
address_var
in
delegated_vars
:
break
else
:
display
.
warning
(
"no remote address found for delegated host
%
s, using its name by default"
%
delegated_host_name
)
delegated_vars
[
'ansible_host'
]
=
delegated_host_name
else
:
delegated_vars
=
dict
()
...
...
lib/ansible/vars/__init__.py
View file @
3bd71d06
...
...
@@ -407,6 +407,7 @@ class VariableManager:
include_delegate_to
=
False
,
include_hostvars
=
False
,
)
all_vars
[
'ansible_delegated_vars'
]
=
delegated_host_vars
if
self
.
_inventory
is
not
None
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment