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
339c05bb
Commit
339c05bb
authored
Oct 16, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allows delegate_to to use inventory host/port info.
parent
ac16efe2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
5 deletions
+23
-5
lib/ansible/inventory/__init__.py
+1
-1
lib/ansible/runner/__init__.py
+21
-3
lib/ansible/runner/connection_plugins/paramiko_ssh.py
+1
-1
No files found.
lib/ansible/inventory/__init__.py
View file @
339c05bb
...
@@ -286,7 +286,7 @@ class Inventory(object):
...
@@ -286,7 +286,7 @@ class Inventory(object):
host
=
self
.
get_host
(
hostname
)
host
=
self
.
get_host
(
hostname
)
if
host
is
None
:
if
host
is
None
:
raise
Exception
(
"host not found:
%
s"
%
hostname
)
raise
errors
.
AnsibleError
(
"host not found:
%
s"
%
hostname
)
return
host
.
get_variables
()
return
host
.
get_variables
()
def
add_group
(
self
,
group
):
def
add_group
(
self
,
group
):
...
...
lib/ansible/runner/__init__.py
View file @
339c05bb
...
@@ -384,14 +384,32 @@ class Runner(object):
...
@@ -384,14 +384,32 @@ class Runner(object):
actual_host
=
host
actual_host
=
host
try
:
try
:
delegate_to
=
inject
.
get
(
'delegate_to'
,
None
)
delegate_to
=
inject
.
get
(
'delegate_to'
,
None
)
alternative_host
=
inject
.
get
(
'ansible_ssh_host'
,
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
:
if
delegate_to
is
not
None
:
delegate_vars
=
{}
try
:
delegate_vars
=
inject
[
'hostvars'
][
delegate_to
]
for
(
k
,
v
)
in
delegate_vars
.
iteritems
():
if
k
.
startswith
(
'ansible_ssh_'
):
inject
[
k
]
=
v
except
errors
.
AnsibleError
:
# host not listed in inventory, it's ok
pass
# the host record may just be an alias in case of tunnels
alternative_host
=
inject
.
get
(
'ansible_ssh_host'
,
None
)
if
delegate_to
is
not
None
and
not
alternative_host
:
actual_host
=
delegate_to
actual_host
=
delegate_to
elif
alternative_host
is
not
None
:
actual_host
=
alternative_hos
t
# connec
t
conn
=
self
.
connector
.
connect
(
actual_host
,
port
)
conn
=
self
.
connector
.
connect
(
actual_host
,
port
)
if
delegate_to
is
not
None
or
alternative_host
is
not
None
:
if
delegate_to
is
not
None
or
alternative_host
is
not
None
:
conn
.
_delegate_for
=
host
conn
.
_delegate_for
=
host
except
errors
.
AnsibleConnectionFailed
,
e
:
except
errors
.
AnsibleConnectionFailed
,
e
:
result
=
dict
(
failed
=
True
,
msg
=
"FAILED:
%
s"
%
str
(
e
))
result
=
dict
(
failed
=
True
,
msg
=
"FAILED:
%
s"
%
str
(
e
))
return
ReturnData
(
host
=
host
,
comm_ok
=
False
,
result
=
result
)
return
ReturnData
(
host
=
host
,
comm_ok
=
False
,
result
=
result
)
...
...
lib/ansible/runner/connection_plugins/paramiko_ssh.py
View file @
339c05bb
...
@@ -53,7 +53,7 @@ class Connection(object):
...
@@ -53,7 +53,7 @@ class Connection(object):
user
=
self
.
runner
.
remote_user
user
=
self
.
runner
.
remote_user
vvv
(
"ESTABLISH CONNECTION FOR USER:
%
s
"
%
user
,
host
=
self
.
host
)
vvv
(
"ESTABLISH CONNECTION FOR USER:
%
s
on PORT
%
s TO
%
s"
%
(
user
,
self
.
port
,
self
.
host
)
,
host
=
self
.
host
)
ssh
=
paramiko
.
SSHClient
()
ssh
=
paramiko
.
SSHClient
()
ssh
.
set_missing_host_key_policy
(
paramiko
.
AutoAddPolicy
())
ssh
.
set_missing_host_key_policy
(
paramiko
.
AutoAddPolicy
())
...
...
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