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
acf2c238
Commit
acf2c238
authored
Oct 17, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Various tweaking of the delegate_to loop code.
parent
37b91c7b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
24 deletions
+21
-24
lib/ansible/runner/__init__.py
+14
-19
lib/ansible/runner/return_data.py
+7
-5
No files found.
lib/ansible/runner/__init__.py
View file @
acf2c238
...
...
@@ -381,28 +381,23 @@ class Runner(object):
return
ReturnData
(
host
=
host
,
result
=
result
)
conn
=
None
actual_host
=
host
actual_port
=
port
try
:
alternative_host
=
inject
.
get
(
'ansible_ssh_host'
,
None
)
if
alternative_host
is
not
None
:
actual_host
=
alternative_host
delegate_to
=
inject
.
get
(
'delegate_to'
,
None
)
# the delegated host may have different SSH port configured, etc
# and we need to transfer those, and only those, variables
if
delegate_to
is
not
None
:
delegate_to
=
utils
.
template
(
self
.
basedir
,
delegate_to
,
inject
)
actual_host
=
inject
[
'hostvars'
][
delegate_to
]
.
get
(
'ansible_ssh_host'
,
delegate_to
)
actual_port
=
inject
[
'hostvars'
][
delegate_to
]
.
get
(
'ansible_ssh_port'
,
port
)
actual_host
=
inject
.
get
(
'ansible_ssh_host'
,
host
)
actual_port
=
inject
.
get
(
'ansible_ssh_port'
,
port
)
# the delegated host may have different SSH port configured, etc
# and we need to transfer those, and only those, variables
delegate_to
=
inject
.
get
(
'delegate_to'
,
None
)
if
delegate_to
is
not
None
:
delegate_to
=
utils
.
template
(
self
.
basedir
,
delegate_to
,
inject
)
delegate_info
=
inject
[
'hostvars'
][
delegate_to
]
actual_host
=
delegate_info
.
get
(
'ansible_ssh_host'
,
delegate_to
)
actual_port
=
delegate_info
.
get
(
'ansible_ssh_port'
,
port
)
try
:
# connect
conn
=
self
.
connector
.
connect
(
actual_host
,
actual_port
)
if
delegate_to
is
not
None
or
alternative_host
is
not
None
:
conn
.
_delegate_for
=
host
if
delegate_to
:
conn
.
delegate
=
host
except
errors
.
AnsibleConnectionFailed
,
e
:
result
=
dict
(
failed
=
True
,
msg
=
"FAILED:
%
s"
%
str
(
e
))
...
...
lib/ansible/runner/return_data.py
View file @
acf2c238
...
...
@@ -26,11 +26,12 @@ class ReturnData(object):
# which host is this ReturnData about?
if
conn
is
not
None
:
delegate_for
=
getattr
(
conn
,
'_delegate_for'
,
None
)
if
delegate_for
:
self
.
host
=
delegate_for
else
:
self
.
host
=
conn
.
host
self
.
host
=
conn
.
host
delegate
=
getattr
(
conn
,
'delegate'
,
None
)
if
delegate
is
not
None
:
self
.
host
=
delegate
else
:
self
.
host
=
host
...
...
@@ -40,6 +41,7 @@ class ReturnData(object):
if
type
(
self
.
result
)
in
[
str
,
unicode
]:
self
.
result
=
utils
.
parse_json
(
self
.
result
)
if
self
.
host
is
None
:
raise
Exception
(
"host not set"
)
if
type
(
self
.
result
)
!=
dict
:
...
...
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