libcloud-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Johnson <erjoh...@apache.org>
Subject Re: startup script support for GCP?
Date Mon, 16 Oct 2017 17:45:58 GMT
Yes, I was thinking something like,

"""
def metadata_from_file(path_to_file):
  with file(path_to_file) as fp:
    contents = fp.read()

  metadata = {
    'startup-script': contents
  }
  return metadata
"""

Then pass in the returned metedata to your GCE create_node() call in
libcloud.

Note, I just wrote this code w/o testing or anything. You'd obviously want
to put in error checking, etc.


On Mon, Oct 16, 2017 at 10:40 AM, Pratik Bandarkar <
pratik.bandarkar@gmail.com> wrote:

> Thanks for info Eric.
>
> On Thu, Oct 12, 2017 at 9:11 AM, Eric Johnson <erjohnso@apache.org> wrote:
>
> > Hi Pratik,
> >
> > No, it doesn't support a from-file option. But it should be pretty
> > straightforward to write a wrapper function that reads the contents of
> the
> > file and puts it into the standard 'startup-script' metadata format.
> >
> Do you mean outside of libcloud/gce should I create function which will
> read from script file and put it into "startup-script" ? It would be great
> if you can provide more pointers on it.
>
> Thanks in advance.
>
> Regards,
> Pratik.
>
> >
> > On Thu, Oct 12, 2017 at 10:04 AM, Pratik Bandarkar <
> > pratik.bandarkar@gmail.com> wrote:
> >
> > > Hi,
> > >
> > > can anyone confirm if using API, instead of writing all commands in the
> > > "startup-script" value, is it possible to write startup script and pass
> > > location of the script in the metadata ?
> > >
> > >
> > > Regards,
> > > Pratik.
> > >
> > > On Mon, Oct 9, 2017 at 12:28 PM, Pratik Bandarkar <
> > > pratik.bandarkar@gmail.com> wrote:
> > >
> > > > Hi Markos,
> > > >
> > > > Thanks for your reply.
> > > >
> > > >
> > > >
> > > > On Mon, Oct 9, 2017 at 11:58 AM, Markos Gogoulos <mgogoulos@mist.io>
> > > > wrote:
> > > >
> > > >> Hi Pratik,
> > > >>
> > > >> libcloud function that creates a VM on GCP (aka create_node() on
> > > >> libcloud/libcloud/compute/drivers/gce.py) accepts an ex_metadata
> > > >> dictionary
> > > >> that can contain the startup script. It expects something like this:
> > > >>
> > > >>     metadata = {
> > > >>         'startup-script': '#!/bin/bash\ntouch /tmp/hello',
> > > >>     }
> > > >>
> > > >> or if you also specify an ssh key to be deployed on the VM
> > > >>
> > > >>     key = "ssh-rsa AAAAB3Nz.... (rest of a pub key)"
> > > >>     metadata = {
> > > >>         'startup-script': '#!/bin/bash\ntouch /tmp/hello',
> > > >>         'sshKeys': 'user:%s' % key
> > > >>     }
> > > >>
> > > >>
> > > >> not sure though if this is supported by saltstack.
> > > >>
> > > > Saltstack does support specifying "startup-script" in "metadata".
> But,
> > > > instead of writing all commands in the "startup-script" value, is it
> > > > possible to write startup script and pass location of the script in
> the
> > > > metadata ?
> > > >
> > > > Regards,
> > > > Pratik.
> > > >
> > > >>
> > > >> Cheers,
> > > >> Markos
> > > >>
> > > >>
> > > >> On Fri, Oct 6, 2017 at 8:27 PM, Pratik Bandarkar <
> > > >> pratik.bandarkar@gmail.com
> > > >> > wrote:
> > > >>
> > > >> > To be more specific, does it provide "--metadata-from-file" option
> > to
> > > >> > specify startup script file?
> > > >> >
> > > >> > Regards,
> > > >> > Pratik.
> > > >> >
> > > >> >
> > > >> >
> > > >> > On Fri, Oct 6, 2017 at 5:36 PM, Pratik Bandarkar <
> > > >> > pratik.bandarkar@gmail.com
> > > >> > > wrote:
> > > >> >
> > > >> > > Hi,
> > > >> > >
> > > >> > > I am using saltstack for deployment of instances on top
of GCE.
> I
> > > >> would
> > > >> > > like to know if we can provide startup/cloud-init script
while
> > > >> spawning
> > > >> > an
> > > >> > > instance? Does libcloud support this functionality for
> saltstack?
> > > >> > >
> > > >> > > Regards,
> > > >> > > Pratik.
> > > >> > >
> > > >> >
> > > >>
> > > >
> > > >
> > >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message