Ansible and Google Docker Manifest

Hi

I’m having troubles adding a metadata key/value where the value is a multiline string when provisioning with the gce module. I just can’t get it to work from Ansible, I get the error: bad metadata: malformed string. If I do it in the command

The background is this Docker preview in GCE: https://developers.google.com/compute/docs/containers

If I provision a GCE machine manually I can se the --metadata-from-file flag to load a whole YAML file into a value. The content ends up in the key google-container-manifest.

If I provision manually using the command:

gcloud compute instances create containervm-test-1 \

–image projects/google-containers/global/images/container-vm-v20140522 \

–metadata-from-file google-container-manifest=containers.yaml \

–zone us-central1-a \

–machine-type f1-micro

It looks like this in the prompt for metadata:

metadata:

fingerprint: n5JL5z74Ofk=

items:

  • key: google-container-manifest

value: "version: v1beta1\ncontainers:\n - name: simple-echo\n image: google/busybox\n\

\ command: [‘nc’, ‘-p’, ‘8080’, ‘-l’, ‘-l’, ‘-e’, ‘echo’, ‘hello world!’]\n\

\ ports:\n - name: nc-echo\n hostPort: 8080\n containerPort:\

\ 8080"

My Ansible variable looks like this:

vars:
manifest: |
version: v1beta1
containers:

  • name: repository
    image: google/docker-registry
    ports:
  • name: registry
    containerPort: 5000
    env:
  • key: GCS_BUCKET
    value: mlwr-docker-registry
  • name: client
    image: localhost:5000/data-loader
    volumeMounts:
  • name: data
    path: /mnt/data
  • name: server
    image: localhost:5000/data-server
    ports:
  • name: www
    containerPort: 80
    volumeMounts:
  • name: data
    path: /mnt/data
    volumes:
  • name: data

Used like this:
gce_metadata: ‘{“google-container-manifest”: “{{ manifest }}”}’

I have tried all combinations I could come up with, but it seems that something goes wrong with the data before yaml parsing and literal_eval in the GCE Ansible-module. I tried to reproduce in a python console but it seemed to work fine.

Thanks
/Magnus

Ask on the GCE lists if this is about the GCE YAML tool thing.

(Looked incredibly rough to me, at first glance, but I know nothing about it)