diff --git a/lib/ansible/playbook/__init__.py b/lib/ansible/playbook/__init__.py index c2e9cadb276..ed7dae20d7c 100644 --- a/lib/ansible/playbook/__init__.py +++ b/lib/ansible/playbook/__init__.py @@ -171,7 +171,7 @@ class PlayBook(object): self.inventory.set_playbook_basedir(self.basedir) vars = extra_vars.copy() - vars['playbook_dir'] = self.basedir + vars['playbook_dir'] = os.path.abspath(self.basedir) if self.inventory.basedir() is not None: vars['inventory_dir'] = self.inventory.basedir() diff --git a/lib/ansible/playbook/play.py b/lib/ansible/playbook/play.py index ed8a6e672eb..38aab2de7bd 100644 --- a/lib/ansible/playbook/play.py +++ b/lib/ansible/playbook/play.py @@ -77,6 +77,7 @@ class Play(object): self.tags = [] # 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: self.vars['inventory_dir'] = self.playbook.inventory.basedir() if self.playbook.inventory.src() is not None: @@ -153,7 +154,6 @@ class Play(object): load_vars = {} 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._handlers = self._load_tasks(self._ds.get('handlers', []), load_vars) diff --git a/lib/ansible/runner/__init__.py b/lib/ansible/runner/__init__.py index d4591fb73b0..e79a22f0a5a 100644 --- a/lib/ansible/runner/__init__.py +++ b/lib/ansible/runner/__init__.py @@ -612,7 +612,7 @@ class Runner(object): inject['vars'] = self.module_vars inject['defaults'] = self.default_vars 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 delegate_to = self.module_vars.get('delegate_to')