From f8ea93c732df881fe051bcc2bc832af05c364fbb Mon Sep 17 00:00:00 2001 From: Serge van Ginderachter Date: Wed, 19 Mar 2014 11:09:38 +0100 Subject: [PATCH] Move inventory.set_playbook_basedir from ansible-playbook to playbook constructor --- bin/ansible-playbook | 3 --- lib/ansible/inventory/__init__.py | 3 ++- lib/ansible/playbook/__init__.py | 4 ++++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/bin/ansible-playbook b/bin/ansible-playbook index d91e2d94847..4a8edad5eff 100755 --- a/bin/ansible-playbook +++ b/bin/ansible-playbook @@ -158,9 +158,6 @@ def main(args): # run all playbooks specified on the command line for playbook in args: - # let inventory know which playbooks are using so it can know the basedirs - inventory.set_playbook_basedir(os.path.dirname(playbook)) - stats = callbacks.AggregateStats() playbook_cb = callbacks.PlaybookCallbacks(verbose=utils.VERBOSITY) if options.step: diff --git a/lib/ansible/inventory/__init__.py b/lib/ansible/inventory/__init__.py index 06acf87e484..53cc0af5d88 100644 --- a/lib/ansible/inventory/__init__.py +++ b/lib/ansible/inventory/__init__.py @@ -57,7 +57,8 @@ class Inventory(object): self._groups_list = {} self._pattern_cache = {} - # to be set by calling set_playbook_basedir by ansible-playbook + self._inventory_basedir = inventory.basedir() + # to be set by calling set_playbook_basedir by playbook code self._playbook_basedir = None # the inventory object holds a list of groups diff --git a/lib/ansible/playbook/__init__.py b/lib/ansible/playbook/__init__.py index f624be1b297..8b07a52c0ae 100644 --- a/lib/ansible/playbook/__init__.py +++ b/lib/ansible/playbook/__init__.py @@ -159,6 +159,10 @@ class PlayBook(object): self.basedir = os.path.dirname(playbook) or '.' utils.plugins.push_basedir(self.basedir) + + # let inventory know the playbook basedir so it can load more vars + self.inventory.set_playbook_basedir(self.basedir) + vars = extra_vars.copy() vars['playbook_dir'] = self.basedir if self.inventory.basedir() is not None: