[ubuntu-cloud] Can I reboot from cloud-init?

Scott Moser smoser at ubuntu.com
Wed Sep 26 12:54:52 UTC 2012


On Tue, 25 Sep 2012, Dave Hein wrote:

> On Mon, Sep 24, 2012 at 7:50 AM, Scott Moser <smoser at ubuntu.com> wrote:
>
> > The config snippet, will do what you'd want in 12.10 and later.  It
> > reboots immediately after 'apt-get upgrade' by cloud-init if there is a
> > reboot required.  This also allows you to install new packages and make
> > sure that by the time your user-data scripts run, you're in the right
> > kernel and modules for that kernel too.
> >
> >   #cloud-config
> >   apt_upgrade: True
> >   apt_reboot_if_required: True
> >
> > cloud-init is still a bit annoying in the logs to the console when this
> > runs (as it's logging is going to rsyslog, and both cloud-init and rsyslog
> > get killed by 'reboot'), but it generally works, and anything that was
> > going to run after the 'apt_update_upgrade' config module will just run
> > after reboot.
> >
> >
> This is really nice and seems to work almost exactly as I would want.
> However, the lack of persistent logs is a big roadblock.

I'm not really sure what you mean here.
All data will be logged.  And everything before '/sbin/reboot' will get to
syslog even.  The rest, after failure to write to /dev/log gets to the
images' console only.

I've not tried it, but you should actually be able to craft cloud-config
that sepecifies a python-logging configuration that would go to a remote
syslog.  Then, after user-data is consumed subsequent logs would go there.
You could even add a boothook that wrote this data to
/etc/cloud/cloud.cfg.d/90_custom_logging.conf, then the next boot would
pick up that configuration earlier.

See the /etc/cloud/cloud.cfg.d/05_logging.cfg file for example of what
that config looks like.  The end result is a string that is consumable by
http://docs.python.org/library/logging.config.html

Again, when I did this, the intent was to support remote logging, but I
have not tested it extensively.

> I'm trying to think of a way to attach a very small EBS volume and direct
> or copy the logs there (before the reboot). I have a vague notion of how to
> make that work when launching a single instance, but it seems difficult to
> do when launching multiple instances in one EC2 request.
>
> Or perhaps it would be possible to e-mail the logs before the reboot, or
> write them to S3, or post them to a web service?

email would seem a reasonable POST mechanism for non-sensitve data.
Dustin Kirkland wrote a package named 'bootmail' that can sign data from
the instance.  I'm not sure about encryption of that data using a
host-only key.
>
> --
> Dave
>



More information about the Ubuntu-cloud mailing list