diff --git a/lib/ansible/playbook/__init__.py b/lib/ansible/playbook/__init__.py index c1225a8e145..b216392ae0b 100644 --- a/lib/ansible/playbook/__init__.py +++ b/lib/ansible/playbook/__init__.py @@ -132,6 +132,9 @@ class PlayBook(object): else: self.inventory = inventory + if self.module_path is not None: + utils.plugins.module_finder.add_directory(self.module_path) + self.basedir = os.path.dirname(playbook) or '.' utils.plugins.push_basedir(self.basedir) vars = extra_vars.copy() diff --git a/lib/ansible/utils/plugins.py b/lib/ansible/utils/plugins.py index eb0f6fe8d14..8d1ef493c3c 100644 --- a/lib/ansible/utils/plugins.py +++ b/lib/ansible/utils/plugins.py @@ -132,7 +132,8 @@ class PluginLoader(object): if directory is not None: if with_subdir: directory = os.path.join(directory, self.subdir) - self._extra_dirs.append(directory) + if directory not in self._extra_dirs: + self._extra_dirs.append(directory) def find_plugin(self, name): ''' Find a plugin named name '''