[Openstack] reboot/shutdown in cloud-init script

Adnan Smajlovic a.smajlovic at gmail.com
Mon Feb 23 15:04:51 UTC 2015

On 19 February 2015 at 16:33, Grant Schoep <matobinder at gmail.com> wrote:

> So I've been playing around with cloud init scripts for VMs I have been
> building.
> I have one example, which I isn't working. Got it from the following
> http://cloudinit.readthedocs.org/en/latest/topics/examples.html
> So, its for the reboot/power off section
> I've stripped out my cloud-init to just the basics, taken right from the
> page. File contents are
> power_state:
>  delay: "+30"
>  mode: poweroff
>  message: Bye Bye
>  timeout: 30
> It doesn't work,  I noticed this line in my /var/log/cloud-init-output.log
> __init__.py[WARNING]: Unhandled non-multipart (text/x-not-multipart)
> userdata: 'power_state:\n delay: "+3...'
> So I am thinking I need to define the format. I was looking at
> http://cloudinit.readthedocs.org/en/latest/topics/format.html
> But the examples don't seem to show any of that. Pointers would be great.
> Thanks
I believe that the issue you have outlined will depend on at least a couple
of things:

1. cloud-init version

You haven't stated the OS distro and versions you are currently using with
your instances while the doc links are specific to the latest version of
cloud-init (0.7.6 at the time of writing).  The 'power-state-change' module
appears to have been added in Nov 2012 (
https://code.launchpad.net/~smoser/cloud-init/finalcmd/+merge/134029) -
which should have been included in cloud-init 0.7.1, at least according to
the timeline on the Launchpad pages and my interpretation thereof :)

The reason I mention this is that I know that Ubuntu 12.04 LTS makes use of
cloud-init 0.6.3 and similar may be true for other OS distros/versions.

2. Inclusion in cloud-init config

While I would expect it to appear there by default (it does in Ubuntu 14.04
LTS), and assuming you are making use of cloud-init >= 0.7.1, the instance
should have an entry in /etc/cloud/cloud.cfg (under the
'cloud_final_modules' section) for the 'power-state-change' module in order
for it to be considered during a run e.g.

# The modules that run in the 'final' stage
 - rightscale_userdata
 - scripts-vendor
 - scripts-per-once
 - scripts-per-boot
 - scripts-per-instance
 - scripts-user
 - ssh-authkey-fingerprints
 - keys-to-console
 - phone-home
 - final-message
 - power-state-change

Naturally, if the module is not included it will not be considered.

I hope that one of those is the pointer you were looking for.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack/attachments/20150223/7339e341/attachment.html>

More information about the Openstack mailing list