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
30c1a2d8
Commit
30c1a2d8
authored
Jun 16, 2015
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Have group/host var file loading check for YAML extensions too
Fixes #11132
parent
98e5f73f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
9 deletions
+23
-9
lib/ansible/inventory/__init__.py
+2
-2
lib/ansible/vars/__init__.py
+21
-7
No files found.
lib/ansible/inventory/__init__.py
View file @
30c1a2d8
...
...
@@ -661,11 +661,11 @@ class Inventory(object):
if
group
and
host
is
None
:
# load vars in dir/group_vars/name_of_group
base_path
=
os
.
path
.
join
(
basedir
,
"group_vars/
%
s"
%
group
.
name
)
self
.
_variable_manager
.
add_group_vars_file
(
base_path
,
self
.
_loader
)
results
=
self
.
_variable_manager
.
add_group_vars_file
(
base_path
,
self
.
_loader
)
elif
host
and
group
is
None
:
# same for hostvars in dir/host_vars/name_of_host
base_path
=
os
.
path
.
join
(
basedir
,
"host_vars/
%
s"
%
host
.
name
)
self
.
_variable_manager
.
add_host_vars_file
(
base_path
,
self
.
_loader
)
results
=
self
.
_variable_manager
.
add_host_vars_file
(
base_path
,
self
.
_loader
)
# all done, results is a dictionary of variables for this particular host.
return
results
...
...
lib/ansible/vars/__init__.py
View file @
30c1a2d8
...
...
@@ -272,9 +272,17 @@ class VariableManager:
data
=
self
.
_combine_vars
(
data
,
results
)
else
:
data
=
loader
.
load_from_file
(
path
)
if
data
is
None
:
data
=
dict
()
file_name
,
ext
=
os
.
path
.
splitext
(
path
)
data
=
None
if
not
ext
:
for
ext
in
(
''
,
'.yml'
,
'.yaml'
):
new_path
=
path
+
ext
if
loader
.
path_exists
(
new_path
):
data
=
loader
.
load_from_file
(
new_path
)
break
else
:
if
loader
.
path_exists
(
path
):
data
=
loader
.
load_from_file
(
path
)
name
=
self
.
_get_inventory_basename
(
path
)
return
(
name
,
data
)
...
...
@@ -286,9 +294,12 @@ class VariableManager:
the extension, for matching against a given inventory host name
'''
if
loader
.
path_exists
(
path
):
(
name
,
data
)
=
self
.
_load_inventory_file
(
path
,
loader
)
(
name
,
data
)
=
self
.
_load_inventory_file
(
path
,
loader
)
if
data
:
self
.
_host_vars_files
[
name
]
=
data
return
data
else
:
return
dict
()
def
add_group_vars_file
(
self
,
path
,
loader
):
'''
...
...
@@ -297,9 +308,12 @@ class VariableManager:
the extension, for matching against a given inventory host name
'''
if
loader
.
path_exists
(
path
):
(
name
,
data
)
=
self
.
_load_inventory_file
(
path
,
loader
)
(
name
,
data
)
=
self
.
_load_inventory_file
(
path
,
loader
)
if
data
:
self
.
_group_vars_files
[
name
]
=
data
return
data
else
:
return
dict
()
def
set_host_facts
(
self
,
host
,
facts
):
'''
...
...
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