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
1c852704
Commit
1c852704
authored
Jun 03, 2015
by
Toshio Kuratomi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix error handling when pasing output from dynamic inventory
parent
67d065c7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
5 deletions
+12
-5
lib/ansible/inventory/script.py
+12
-5
No files found.
lib/ansible/inventory/script.py
View file @
1c852704
...
@@ -23,6 +23,8 @@ import os
...
@@ -23,6 +23,8 @@ import os
import
subprocess
import
subprocess
import
sys
import
sys
from
collections
import
Mapping
from
ansible
import
constants
as
C
from
ansible
import
constants
as
C
from
ansible.errors
import
*
from
ansible.errors
import
*
from
ansible.inventory.host
import
Host
from
ansible.inventory.host
import
Host
...
@@ -62,7 +64,16 @@ class InventoryScript:
...
@@ -62,7 +64,16 @@ class InventoryScript:
all_hosts
=
{}
all_hosts
=
{}
# not passing from_remote because data from CMDB is trusted
# not passing from_remote because data from CMDB is trusted
self
.
raw
=
self
.
_loader
.
load
(
self
.
data
)
try
:
self
.
raw
=
self
.
_loader
.
load
(
self
.
data
)
except
Exception
as
e
:
sys
.
stderr
.
write
(
err
+
"
\n
"
)
raise
AnsibleError
(
"failed to parse executable inventory script results:
%
s"
%
str
(
e
))
if
not
isinstance
(
self
.
raw
,
Mapping
):
sys
.
stderr
.
write
(
err
+
"
\n
"
)
raise
AnsibleError
(
"failed to parse executable inventory script results: data needs to be formatted as a json dict"
)
self
.
raw
=
json_dict_bytes_to_unicode
(
self
.
raw
)
self
.
raw
=
json_dict_bytes_to_unicode
(
self
.
raw
)
all
=
Group
(
'all'
)
all
=
Group
(
'all'
)
...
@@ -70,10 +81,6 @@ class InventoryScript:
...
@@ -70,10 +81,6 @@ class InventoryScript:
group
=
None
group
=
None
if
'failed'
in
self
.
raw
:
sys
.
stderr
.
write
(
err
+
"
\n
"
)
raise
AnsibleError
(
"failed to parse executable inventory script results:
%
s"
%
self
.
raw
)
for
(
group_name
,
data
)
in
self
.
raw
.
items
():
for
(
group_name
,
data
)
in
self
.
raw
.
items
():
# in Ansible 1.3 and later, a "_meta" subelement may contain
# in Ansible 1.3 and later, a "_meta" subelement may contain
...
...
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