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
c18fdd0c
Commit
c18fdd0c
authored
Jul 13, 2015
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Re-implement "conditional imports" for vars_files
parent
1255a070
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
6 deletions
+19
-6
lib/ansible/vars/__init__.py
+19
-6
No files found.
lib/ansible/vars/__init__.py
View file @
c18fdd0c
...
...
@@ -189,13 +189,26 @@ class VariableManager:
if
play
:
all_vars
=
self
.
_combine_vars
(
all_vars
,
play
.
get_vars
())
templar
=
Templar
(
loader
=
loader
,
variables
=
all_vars
)
for
vars_file
in
play
.
get_vars_files
():
for
vars_file_item
in
play
.
get_vars_files
():
try
:
vars_file
=
templar
.
template
(
vars_file
)
data
=
loader
.
load_from_file
(
vars_file
)
if
data
is
None
:
data
=
dict
()
all_vars
=
self
.
_combine_vars
(
all_vars
,
data
)
# we assume each item in the list is itself a list, as we
# support "conditional includes" for vars_files, which mimics
# the with_first_found mechanism.
vars_file_list
=
templar
.
template
(
vars_file_item
)
if
not
isinstance
(
vars_file_list
,
list
):
vars_file_list
=
[
vars_file_list
]
# now we iterate through the (potential) files, and break out
# as soon as we read one from the list. If none are found, we
# raise an error, which is silently ignored at this point.
for
vars_file
in
vars_file_list
:
data
=
loader
.
load_from_file
(
vars_file
)
if
data
is
not
None
:
all_vars
=
self
.
_combine_vars
(
all_vars
,
data
)
break
else
:
raise
AnsibleError
(
"vars file
%
s was not found"
%
vars_file_item
)
except
:
# FIXME: get_vars should probably be taking a flag to determine
# whether or not vars files errors should be fatal at this
...
...
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