diff --git a/hot/software-config/elements/heat-config-ansible/install.d/hook-ansible.py b/hot/software-config/elements/heat-config-ansible/install.d/hook-ansible.py index c48c3322..426ee544 100755 --- a/hot/software-config/elements/heat-config-ansible/install.d/hook-ansible.py +++ b/hot/software-config/elements/heat-config-ansible/install.d/hook-ansible.py @@ -51,6 +51,7 @@ def main(argv=sys.argv): variables[input['name']] = input.get('value', '') tags = c['options'].get('tags') + modulepath = c['options'].get('modulepath') fn = os.path.join(WORKING_DIR, '%s_playbook.yaml' % c['id']) vars_filename = os.path.join(WORKING_DIR, '%s_variables.json' % c['id']) @@ -80,6 +81,10 @@ def main(argv=sys.argv): if tags: cmd.insert(3, '--tags') cmd.insert(4, tags) + if modulepath: + cmd.insert(3, '--module-path') + cmd.insert(4, modulepath) + log.debug('Running %s' % (' '.join(cmd),)) try: subproc = subprocess.Popen(cmd, stdout=subprocess.PIPE, diff --git a/tests/software_config/test_hook_ansible.py b/tests/software_config/test_hook_ansible.py index 8f0b789e..68494727 100644 --- a/tests/software_config/test_hook_ansible.py +++ b/tests/software_config/test_hook_ansible.py @@ -47,6 +47,17 @@ class HookAnsibleTest(common.RunScriptTest): 'config': 'the ansible playbook' } + data_modulepath = data.copy() + data_modulepath.update({ + 'options': {'modulepath': '/opt/ansible:/usr/share/ansible'}, + }) + + data_tags_modulepath = data.copy() + data_tags_modulepath.update({ + 'options': {'modulepath': '/opt/ansible:/usr/share/ansible', + 'tags': 'abc,def'}, + }) + def setUp(self): super(HookAnsibleTest, self).setUp() self.hook_path = self.relative_path( @@ -78,6 +89,17 @@ class HookAnsibleTest(common.RunScriptTest): def test_hook_tags(self): self._hook_run(data=self.data_tags, options=['--tags', 'abc,def']) + def test_hook_modulepath(self): + self._hook_run(data=self.data_modulepath, + options=['--module-path', + '/opt/ansible:/usr/share/ansible']) + + def test_hook_tags_modulepath(self): + self._hook_run(data=self.data_tags_modulepath, + options=['--module-path', + '/opt/ansible:/usr/share/ansible', + '--tags', 'abc,def']) + def _hook_run(self, data=None, options=None): self.env.update({