Make sure playbook_dir variable is an absolute path

Fixes #8317
pull/7425/head^2
James Cammarata 10 years ago
parent 8abd6370df
commit fc7859f445

@ -171,7 +171,7 @@ class PlayBook(object):
self.inventory.set_playbook_basedir(self.basedir) self.inventory.set_playbook_basedir(self.basedir)
vars = extra_vars.copy() vars = extra_vars.copy()
vars['playbook_dir'] = self.basedir vars['playbook_dir'] = os.path.abspath(self.basedir)
if self.inventory.basedir() is not None: if self.inventory.basedir() is not None:
vars['inventory_dir'] = self.inventory.basedir() vars['inventory_dir'] = self.inventory.basedir()

@ -77,6 +77,7 @@ class Play(object):
self.tags = [] self.tags = []
# make sure we have some special internal variables set # make sure we have some special internal variables set
self.vars['playbook_dir'] = os.path.abspath(self.basedir)
if self.playbook.inventory.basedir() is not None: if self.playbook.inventory.basedir() is not None:
self.vars['inventory_dir'] = self.playbook.inventory.basedir() self.vars['inventory_dir'] = self.playbook.inventory.basedir()
if self.playbook.inventory.src() is not None: if self.playbook.inventory.src() is not None:
@ -153,7 +154,6 @@ class Play(object):
load_vars = {} load_vars = {}
load_vars['role_names'] = ds.get('role_names',[]) load_vars['role_names'] = ds.get('role_names',[])
load_vars['playbook_dir'] = self.basedir
self._tasks = self._load_tasks(self._ds.get('tasks', []), load_vars) self._tasks = self._load_tasks(self._ds.get('tasks', []), load_vars)
self._handlers = self._load_tasks(self._ds.get('handlers', []), load_vars) self._handlers = self._load_tasks(self._ds.get('handlers', []), load_vars)

@ -612,7 +612,7 @@ class Runner(object):
inject['vars'] = self.module_vars inject['vars'] = self.module_vars
inject['defaults'] = self.default_vars inject['defaults'] = self.default_vars
inject['environment'] = self.environment inject['environment'] = self.environment
inject['playbook_dir'] = self.basedir inject['playbook_dir'] = os.path.abspath(self.basedir)
# template this one is available, callbacks use this # template this one is available, callbacks use this
delegate_to = self.module_vars.get('delegate_to') delegate_to = self.module_vars.get('delegate_to')

Loading…
Cancel
Save