1

I am trying to launch a CoreOS instance on GCE like this

gcloud compute instances create instance-1 --project myproject --image coreos-stable-607-0-0-v20150317 --zone us-central1-a --machine-type n1-standard-4 --metadata 'startup-script=#!/bin/sh
        ETCD_DISCOVERY_URL=https://discovery.etcd.io/a47e463f976655d93b3c77aaad1af77e
        HOSTNAME=$(curl http://metadata/computeMetadata/v1//hostname)
        IPADDR=$(ifconfig eth0| grep '\''inet '\'' | cut -dt -f2 | awk '\''{ print $1}'\'')
        sudo systemctl start fleet
        etcd -name $HOSTNAME -peer-addr $IPADDR:7001 -addr $IPADDR:4001 -discovery $ETCD_DISCOVERY_URL
        EOF'

And I keep getting back

usage: gcloud compute instances create  NAME [NAME ...] [optional flags]
ERROR: (gcloud.compute.instances.create) argument --metadata: key/value pair must be of the form KEY=VALUE; received: startup-script=#!/bin/sh
        ETCD_DISCOVERY_URL=https://discovery.etcd.io/a47e463f976655d93b3c777aaad1af77e
        HOSTNAME=$(curl http://metadata/computeMetadata/v1//hostname)
        IPADDR=$(ifconfig eth0| grep 'inet ' | cut -dt -f2 | awk '{ print $1}')
        sudo systemctl start fleet
        etcd -name $HOSTNAME -peer-addr $IPADDR:7001 -addr $IPADDR:4001 -discovery $ETCD_DISCOVERY_URL
        EOF

I followed the example at https://cloud.google.com/compute/docs/startupscript What am I doing wrong?

1 Answer 1

2

It looks like you have your quoting wrong. Consider the example

 ... --metadata startup-script='#! /bin/bash...

and then look at your similar stanza

 ... --metadata 'startup-script=#!/bin/sh ...

Note the different locations of the '. As you have used ' in your startup script you may have additional issues with your quoting that you will need to fix up.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .