From 6277e770a100234c6984ba863f3874260b0d00f5 Mon Sep 17 00:00:00 2001 From: Serge van Ginderachter Date: Fri, 25 Oct 2013 07:53:52 +0200 Subject: [PATCH] include basedir as 'playbook_dir' variable closes #4246 --- lib/ansible/playbook/__init__.py | 1 + lib/ansible/playbook/play.py | 1 + lib/ansible/runner/__init__.py | 1 + 3 files changed, 3 insertions(+) diff --git a/lib/ansible/playbook/__init__.py b/lib/ansible/playbook/__init__.py index 7213d9ffa4..7625c7ec8a 100644 --- a/lib/ansible/playbook/__init__.py +++ b/lib/ansible/playbook/__init__.py @@ -138,6 +138,7 @@ class PlayBook(object): self.basedir = os.path.dirname(playbook) or '.' utils.plugins.push_basedir(self.basedir) vars = extra_vars.copy() + vars['playbook_dir'] = 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 dc4421756c..47f80f0611 100644 --- a/lib/ansible/playbook/play.py +++ b/lib/ansible/playbook/play.py @@ -123,6 +123,7 @@ class Play(object): self.max_fail_pct = int(ds.get('max_fail_percentage', 100)) load_vars = {} + load_vars['playbook_dir'] = self.basedir if self.playbook.inventory.basedir() is not None: load_vars['inventory_dir'] = self.playbook.inventory.basedir() diff --git a/lib/ansible/runner/__init__.py b/lib/ansible/runner/__init__.py index b3d27fefef..62c2c8a394 100644 --- a/lib/ansible/runner/__init__.py +++ b/lib/ansible/runner/__init__.py @@ -415,6 +415,7 @@ class Runner(object): inject['vars'] = self.module_vars inject['defaults'] = self.default_vars inject['environment'] = self.environment + inject['playbook_dir'] = self.basedir if self.inventory.basedir() is not None: inject['inventory_dir'] = self.inventory.basedir()