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
2ef5d6be
Commit
2ef5d6be
authored
Jan 19, 2015
by
Brian Coca
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9702 from bcoca/better_errors_on_delegate
better exception handling with delegated hosts
parents
23783a52
1c5f6252
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
16 deletions
+16
-16
lib/ansible/inventory/__init__.py
+2
-2
lib/ansible/runner/__init__.py
+14
-14
No files found.
lib/ansible/inventory/__init__.py
View file @
2ef5d6be
...
...
@@ -420,7 +420,7 @@ class Inventory(object):
group
=
self
.
get_group
(
groupname
)
if
group
is
None
:
raise
Exception
(
"group not found:
%
s"
%
groupname
)
raise
errors
.
AnsibleError
(
"group not found:
%
s"
%
groupname
)
vars
=
{}
...
...
@@ -439,7 +439,7 @@ class Inventory(object):
host
=
self
.
get_host
(
hostname
)
if
not
host
:
raise
Exception
(
"host not found:
%
s"
%
hostname
)
raise
errors
.
AnsibleError
(
"host not found:
%
s"
%
hostname
)
return
host
.
get_variables
()
def
get_host_variables
(
self
,
hostname
,
update_cached
=
False
,
vault_password
=
None
):
...
...
lib/ansible/runner/__init__.py
View file @
2ef5d6be
...
...
@@ -394,20 +394,20 @@ class Runner(object):
actual_user
=
inject
.
get
(
'ansible_ssh_user'
,
self
.
remote_user
)
thisuser
=
None
if
host
in
inject
[
'hostvars'
]
:
if
inject
[
'hostvars'
][
host
]
.
get
(
'ansible_ssh_user'
)
:
# user for delegate host in inventory
thisuser
=
inject
[
'hostvars'
][
host
]
.
get
(
'ansible_ssh_user'
)
else
:
# look up the variables for the host directly from inventory
try
:
host_vars
=
self
.
inventory
.
get_variables
(
host
,
vault_password
=
self
.
vault_pass
)
if
'ansible_ssh_user'
in
host_vars
:
thisuser
=
host_vars
[
'ansible_ssh_user'
]
except
Exception
,
e
:
# the hostname was not found in the inventory, so
# we just ignore this and try the next method
pass
try
:
if
host
in
inject
[
'hostvars'
]
:
if
inject
[
'hostvars'
][
host
]
.
get
(
'ansible_ssh_user'
):
# user for delegate host in inventory
thisuser
=
inject
[
'hostvars'
][
host
]
.
get
(
'ansible_ssh_user'
)
else
:
# look up the variables for the host directly from inventory
host_vars
=
self
.
inventory
.
get_variables
(
host
,
vault_password
=
self
.
vault_pass
)
if
'ansible_ssh_user'
in
host_vars
:
thisuser
=
host_vars
[
'ansible_ssh_user'
]
except
errors
.
AnsibleError
,
e
:
# the hostname was not found in the inventory, so
# we just ignore this and try the next method
pass
if
thisuser
is
None
and
self
.
remote_user
:
# user defined by play/runner
...
...
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