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
4e94bb64
Commit
4e94bb64
authored
Jul 14, 2015
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix group/host var loading relative to playbook basedir
parent
7dd56008
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
8 deletions
+14
-8
lib/ansible/executor/playbook_executor.py
+1
-0
lib/ansible/inventory/__init__.py
+13
-8
No files found.
lib/ansible/executor/playbook_executor.py
View file @
4e94bb64
...
...
@@ -73,6 +73,7 @@ class PlaybookExecutor:
try
:
for
playbook_path
in
self
.
_playbooks
:
pb
=
Playbook
.
load
(
playbook_path
,
variable_manager
=
self
.
_variable_manager
,
loader
=
self
.
_loader
)
self
.
_inventory
.
set_playbook_basedir
(
os
.
path
.
dirname
(
playbook_path
))
if
self
.
_tqm
is
None
:
# we are doing a listing
entry
=
{
'playbook'
:
playbook_path
}
...
...
lib/ansible/inventory/__init__.py
View file @
4e94bb64
...
...
@@ -595,22 +595,27 @@ class Inventory(object):
""" returns the directory of the current playbook """
return
self
.
_playbook_basedir
def
set_playbook_basedir
(
self
,
dir
):
def
set_playbook_basedir
(
self
,
dir
_name
):
"""
sets the base directory of the playbook so inventory can use it as a
basedir for host_ and group_vars, and other things.
"""
# Only update things if dir is a different playbook basedir
if
dir
!=
self
.
_playbook_basedir
:
self
.
_playbook_basedir
=
dir
if
dir
_name
!=
self
.
_playbook_basedir
:
self
.
_playbook_basedir
=
dir
_name
# get group vars from group_vars/ files
# FIXME: excluding the new_pb_basedir directory may result in group_vars
# files loading more than they should, however with the file caching
# we do this shouldn't be too much of an issue. Still, this should
# be fixed at some point to allow a "first load" to touch all of the
# directories, then later runs only touch the new basedir specified
for
group
in
self
.
groups
:
#
FIXME: combine_vars
group
.
vars
=
combine_vars
(
group
.
vars
,
self
.
get_group_vars
(
group
,
new_pb_basedir
=
True
))
#
group.vars = combine_vars(group.vars, self.get_group_vars(group, new_pb_basedir=True))
group
.
vars
=
combine_vars
(
group
.
vars
,
self
.
get_group_vars
(
group
))
# get host vars from host_vars/ files
for
host
in
self
.
get_hosts
():
#
FIXME: combine_vars
host
.
vars
=
combine_vars
(
host
.
vars
,
self
.
get_host_vars
(
host
,
new_pb_basedir
=
True
))
#
host.vars = combine_vars(host.vars, self.get_host_vars(host, new_pb_basedir=True))
host
.
vars
=
combine_vars
(
host
.
vars
,
self
.
get_host_vars
(
host
))
# invalidate cache
self
.
_vars_per_host
=
{}
self
.
_vars_per_group
=
{}
...
...
@@ -646,7 +651,7 @@ class Inventory(object):
# this can happen from particular API usages, particularly if not run
# from /usr/bin/ansible-playbook
if
basedir
is
None
:
continue
basedir
=
'./'
scan_pass
=
scan_pass
+
1
...
...
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