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
3a228b9d
Commit
3a228b9d
authored
Aug 21, 2014
by
Serge van Ginderachter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
InventoryScript: better syntax checking for json stream
parent
b8d05729
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
0 deletions
+8
-0
lib/ansible/inventory/script.py
+8
-0
No files found.
lib/ansible/inventory/script.py
View file @
3a228b9d
...
@@ -84,10 +84,14 @@ class InventoryScript(object):
...
@@ -84,10 +84,14 @@ class InventoryScript(object):
if
not
isinstance
(
data
,
dict
):
if
not
isinstance
(
data
,
dict
):
data
=
{
'hosts'
:
data
}
data
=
{
'hosts'
:
data
}
# is not those subkeys, then simplified syntax, host with vars
elif
not
any
(
k
in
data
for
k
in
(
'hosts'
,
'vars'
)):
elif
not
any
(
k
in
data
for
k
in
(
'hosts'
,
'vars'
)):
data
=
{
'hosts'
:
[
group_name
],
'vars'
:
data
}
data
=
{
'hosts'
:
[
group_name
],
'vars'
:
data
}
if
'hosts'
in
data
:
if
'hosts'
in
data
:
if
not
isinstance
(
data
[
'hosts'
],
list
):
raise
errors
.
AnsibleError
(
"You defined a group
\"
%
s
\"
with bad "
"data for the host list:
\n
%
s"
%
(
group_name
,
data
))
for
hostname
in
data
[
'hosts'
]:
for
hostname
in
data
[
'hosts'
]:
if
not
hostname
in
all_hosts
:
if
not
hostname
in
all_hosts
:
...
@@ -96,6 +100,10 @@ class InventoryScript(object):
...
@@ -96,6 +100,10 @@ class InventoryScript(object):
group
.
add_host
(
host
)
group
.
add_host
(
host
)
if
'vars'
in
data
:
if
'vars'
in
data
:
if
not
isinstance
(
data
[
'vars'
],
dict
):
raise
errors
.
AnsibleError
(
"You defined a group
\"
%
s
\"
with bad "
"data for variables:
\n
%
s"
%
(
group_name
,
data
))
for
k
,
v
in
data
[
'vars'
]
.
iteritems
():
for
k
,
v
in
data
[
'vars'
]
.
iteritems
():
if
group
.
name
==
all
.
name
:
if
group
.
name
==
all
.
name
:
all
.
set_variable
(
k
,
v
)
all
.
set_variable
(
k
,
v
)
...
...
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