From 3a86f8789cb1a22353c172b4fbcccb71e9080948 Mon Sep 17 00:00:00 2001 From: Steve Baker Date: Fri, 28 Apr 2017 13:33:27 +1200 Subject: [PATCH] Set the config ID as an ansible variable This change sets the ansible variable called heat_config_id to the 'id' value of the heat config data. This will be useful in some playbooks to make idempotency decisions. Change-Id: I5f03e012b2fb97cc0076c886ca7bd3f284d19032 --- heat-config-ansible/install.d/hook-ansible.py | 1 + tests/test_hook_ansible.py | 1 + 2 files changed, 2 insertions(+) diff --git a/heat-config-ansible/install.d/hook-ansible.py b/heat-config-ansible/install.d/hook-ansible.py index 419c281..67336fb 100755 --- a/heat-config-ansible/install.d/hook-ansible.py +++ b/heat-config-ansible/install.d/hook-ansible.py @@ -47,6 +47,7 @@ def main(argv=sys.argv): c = json.load(sys.stdin) variables = {} + variables['heat_config_id'] = c['id'] for input in c['inputs']: variables[input['name']] = input.get('value', '') diff --git a/tests/test_hook_ansible.py b/tests/test_hook_ansible.py index d5a7e30..986e66b 100644 --- a/tests/test_hook_ansible.py +++ b/tests/test_hook_ansible.py @@ -187,6 +187,7 @@ class HookAnsibleTest(common.RunScriptTest): variables = self.json_from_file(vars_filename) self.assertEqual('bar', variables['foo']) self.assertEqual('input', variables['another']) + self.assertEqual('1234', variables['heat_config_id']) self.assertEqual(self.outputs_dir.join('1234'), variables['heat_outputs_path'])