From f620a0ac41c82edc1e894734f4e0c4dbf63dfd3f Mon Sep 17 00:00:00 2001 From: HelenaTian Date: Tue, 12 May 2015 20:53:36 -0700 Subject: [PATCH] Update gce.py to correctly handle propagated metadata type from a mother template My project is using Ansible to automate cloud build process. Ansible has a core module gce.py for managing GCE instances. We've come across a use case that's not yet supported - when executing ansible-playbook, if a child template is included, then metadata which is defined in and propagated from the mother template is treated as string type and not parsed correctly(which instead is dictionary type), and triggers release flow failure. We currently put some fix by explicitly casting metadata to string type in our own branch, but would like to contribute the fix to Ansible so that everyone onboarding GCE and using Ansible for release management could benefit from it, or hear owner's opinion on fixing the issue if there's a better fix in owner's mind:) --- cloud/google/gce.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloud/google/gce.py b/cloud/google/gce.py index 314f1200161..be9e6818c76 100644 --- a/cloud/google/gce.py +++ b/cloud/google/gce.py @@ -317,7 +317,7 @@ def create_instances(module, gce, instance_names): # [ {'key': key1, 'value': value1}, {'key': key2, 'value': value2}, ...] if metadata: try: - md = literal_eval(metadata) + md = literal_eval(str(metadata)) if not isinstance(md, dict): raise ValueError('metadata must be a dict') except ValueError, e: