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
5a8dff5b
Commit
5a8dff5b
authored
Apr 20, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Instantiate inventory plugins only once for efficiency reasons.
parent
817b0cdc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
2 deletions
+7
-2
lib/ansible/inventory/__init__.py
+7
-2
No files found.
lib/ansible/inventory/__init__.py
View file @
5a8dff5b
...
...
@@ -37,7 +37,8 @@ class Inventory(object):
"""
__slots__
=
[
'host_list'
,
'groups'
,
'_restriction'
,
'_also_restriction'
,
'_subset'
,
'parser'
,
'_vars_per_host'
,
'_vars_per_group'
,
'_hosts_cache'
,
'_groups_list'
]
'parser'
,
'_vars_per_host'
,
'_vars_per_group'
,
'_hosts_cache'
,
'_groups_list'
,
'_vars_plugins'
]
def
__init__
(
self
,
host_list
=
C
.
DEFAULT_HOST_LIST
):
...
...
@@ -97,6 +98,9 @@ class Inventory(object):
else
:
raise
errors
.
AnsibleError
(
"Unable to find an inventory file, specify one with -i ?"
)
self
.
_vars_plugins
=
[
x
for
x
in
utils
.
plugins
.
vars_loader
.
all
(
self
)
]
def
_match
(
self
,
str
,
pattern_str
):
if
pattern_str
.
startswith
(
'~'
):
return
re
.
search
(
pattern_str
[
1
:],
str
)
...
...
@@ -277,7 +281,8 @@ class Inventory(object):
raise
errors
.
AnsibleError
(
"host not found:
%
s"
%
hostname
)
vars
=
{}
for
updated
in
map
(
lambda
x
:
x
.
run
(
host
),
utils
.
plugins
.
vars_loader
.
all
(
self
)):
vars_results
=
[
plugin
.
run
(
host
)
for
plugin
in
self
.
_vars_plugins
]
for
updated
in
vars_results
:
if
updated
is
not
None
:
vars
.
update
(
updated
)
...
...
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