Multiple Startup Scripts, one project-wide mandatory, and possibly an optional instance level

1,176 views
Skip to first unread message

Dennis Ordanov

unread,
Mar 30, 2016, 10:17:57 PM3/30/16
to gce-discussion
Hi,

What is the best way to enforce a project-wide startup script and also allow for an additional startup script at the instance level?

The use case is:  every VM in a project would have a script that installs a few pieces of mandatory software and then I can configure per instance other additional things to happen. 

Something like  "startup-script-url-2" at the instance level or "startup-script-url" at the project level.  This way I can avoid having to maintain a custom image or always calling the project wide script from the instance level script manually.  Does cloud-init have a facility to solve this?


Regards,

Dennis O.

Faizan (Google Cloud Support)

unread,
Mar 31, 2016, 1:19:25 PM3/31/16
to gce-discussion
Hello Dennis,

You can add startup script to project and instance metadata at the same time. The startup script in the project metadata will be applied to all the instances in the project. You can add the project metadata using your Developer console or gcloud command line tool. You can refer to this link for more information on startup scripts.

I hope that helps.

Faizan
 

Dennis

unread,
Apr 1, 2016, 5:24:12 AM4/1/16
to Faizan (Google Cloud Support), gce-discussion
Hi,

I tested this today and I only see the instance level startup script being injected (/var/run/google.startup.script).  Can both be run in succession or is it that if an instance-level script is specified only that is run?

Regards,

Dennis O.



--
© 2014 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-dis...@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to the Google Groups "gce-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gce-discussio...@googlegroups.com.
To post to this group, send email to gce-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gce-discussion/1bb8d3e0-4eb4-4905-8e01-de3c00397d8e%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Faizan (Google Cloud Support)

unread,
Apr 1, 2016, 3:35:51 PM4/1/16
to gce-discussion, fai...@google.com
Hello Dennis,

I did some test as well and can confirm the same behavior as you. If there is a startup script in instance metadata, script in project metadata doesn't run. As such, its currently not possible to run both the scripts at the same time.

With that said, one approach that you can take is to use startup script from project metadata when you create an instance and later add start up script to the instance metadata for instance specific updates.

Jules Chevalier

unread,
Mar 1, 2018, 11:29:22 AM3/1/18
to gce-discussion
Hello Denis,

I'm quite late, but I was looking for the same thing as you.
Turns out that it is possible, if you create a MIME file with all your scripts, and pass it to the startup-script metadata.

Cheers

Sean Erswell-Liljefelt

unread,
Nov 14, 2018, 9:55:59 AM11/14/18
to gce-discussion
Hi @jules

Do you have a link to that documented somewhere or a working example?

/Sean

Jason

unread,
Nov 14, 2018, 11:31:14 AM11/14/18
to gce-discussion
You can run a project wide startup script; however, as described in this article, if you set a startup script on the Instance level, the instance level startup script will run, but the project level startup script will not. The instance level startup script will take precedence. 
Reply all
Reply to author
Forward
0 new messages