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
98a19057
Commit
98a19057
authored
Aug 19, 2015
by
Abhijit Menon-Sen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename 'section' to 'groupname' to better reflect its purpose
parent
1284c49b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
12 deletions
+12
-12
lib/ansible/inventory/ini.py
+12
-12
No files found.
lib/ansible/inventory/ini.py
View file @
98a19057
...
@@ -80,7 +80,7 @@ class InventoryParser(object):
...
@@ -80,7 +80,7 @@ class InventoryParser(object):
# subgroups, and setting variables as we go.
# subgroups, and setting variables as we go.
pending_declarations
=
{}
pending_declarations
=
{}
section
=
'ungrouped'
groupname
=
'ungrouped'
state
=
'hosts'
state
=
'hosts'
i
=
0
i
=
0
...
@@ -99,14 +99,14 @@ class InventoryParser(object):
...
@@ -99,14 +99,14 @@ class InventoryParser(object):
m
=
self
.
patterns
[
'section'
]
.
match
(
line
)
m
=
self
.
patterns
[
'section'
]
.
match
(
line
)
if
m
:
if
m
:
(
section
,
state
)
=
m
.
groups
()
(
groupname
,
state
)
=
m
.
groups
()
state
=
state
or
'hosts'
state
=
state
or
'hosts'
if
state
not
in
[
'hosts'
,
'children'
,
'vars'
]:
if
state
not
in
[
'hosts'
,
'children'
,
'vars'
]:
title
=
":"
.
join
(
m
.
groups
())
title
=
":"
.
join
(
m
.
groups
())
raise
AnsibleError
(
"
%
s:
%
d: Section [
%
s] has unknown type:
%
s"
%
(
self
.
filename
,
i
,
title
,
state
))
raise
AnsibleError
(
"
%
s:
%
d: Section [
%
s] has unknown type:
%
s"
%
(
self
.
filename
,
i
,
title
,
state
))
# If we haven't seen this
section
before, we add a new Group.
# If we haven't seen this
group
before, we add a new Group.
#
#
# Either [groupname] or [groupname:children] is sufficient to
# Either [groupname] or [groupname:children] is sufficient to
# declare a group, but [groupname:vars] is allowed only if the
# declare a group, but [groupname:vars] is allowed only if the
...
@@ -114,17 +114,17 @@ class InventoryParser(object):
...
@@ -114,17 +114,17 @@ class InventoryParser(object):
# the group anyway, but make a note in pending_declarations to
# the group anyway, but make a note in pending_declarations to
# check at the end.
# check at the end.
if
section
not
in
self
.
groups
:
if
groupname
not
in
self
.
groups
:
self
.
groups
[
section
]
=
Group
(
name
=
section
)
self
.
groups
[
groupname
]
=
Group
(
name
=
groupname
)
if
state
==
'vars'
:
if
state
==
'vars'
:
pending_declarations
[
section
]
=
dict
(
line
=
i
,
state
=
state
,
name
=
section
)
pending_declarations
[
groupname
]
=
dict
(
line
=
i
,
state
=
state
,
name
=
groupname
)
# When we see a declaration that we've been waiting for, we can
# When we see a declaration that we've been waiting for, we can
# delete the note.
# delete the note.
if
section
in
pending_declarations
and
state
!=
'vars'
:
if
groupname
in
pending_declarations
and
state
!=
'vars'
:
del
pending_declarations
[
section
]
del
pending_declarations
[
groupname
]
continue
continue
...
@@ -137,13 +137,13 @@ class InventoryParser(object):
...
@@ -137,13 +137,13 @@ class InventoryParser(object):
if
state
==
'hosts'
:
if
state
==
'hosts'
:
hosts
=
self
.
_parse_host_definition
(
line
,
i
)
hosts
=
self
.
_parse_host_definition
(
line
,
i
)
for
h
in
hosts
:
for
h
in
hosts
:
self
.
groups
[
section
]
.
add_host
(
h
)
self
.
groups
[
groupname
]
.
add_host
(
h
)
# [groupname:vars] contains variable definitions that must be
# [groupname:vars] contains variable definitions that must be
# applied to the current group.
# applied to the current group.
elif
state
==
'vars'
:
elif
state
==
'vars'
:
(
k
,
v
)
=
self
.
_parse_variable_definition
(
line
,
i
)
(
k
,
v
)
=
self
.
_parse_variable_definition
(
line
,
i
)
self
.
groups
[
section
]
.
set_variable
(
k
,
v
)
self
.
groups
[
groupname
]
.
set_variable
(
k
,
v
)
# [groupname:children] contains subgroup names that must be
# [groupname:children] contains subgroup names that must be
# added as children of the current group. The subgroup names
# added as children of the current group. The subgroup names
...
@@ -154,9 +154,9 @@ class InventoryParser(object):
...
@@ -154,9 +154,9 @@ class InventoryParser(object):
if
child
not
in
self
.
groups
:
if
child
not
in
self
.
groups
:
self
.
groups
[
child
]
=
Group
(
name
=
child
)
self
.
groups
[
child
]
=
Group
(
name
=
child
)
pending_declarations
[
child
]
=
dict
(
line
=
i
,
state
=
state
,
name
=
child
,
parent
=
section
)
pending_declarations
[
child
]
=
dict
(
line
=
i
,
state
=
state
,
name
=
child
,
parent
=
groupname
)
self
.
groups
[
section
]
.
add_child_group
(
self
.
groups
[
child
])
self
.
groups
[
groupname
]
.
add_child_group
(
self
.
groups
[
child
])
# Note: there's no reason why we couldn't accept variable
# Note: there's no reason why we couldn't accept variable
# definitions here, and set them on the named child group.
# definitions here, and set them on the named child group.
...
...
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