diff options
author | Justin Santa Barbara <justin@fathomdb.com> | 2012-02-24 00:48:13 -0800 |
---|---|---|
committer | Justin Santa Barbara <justin@fathomdb.com> | 2012-02-24 02:57:09 -0800 |
commit | f4bf828775db8bed77df12a5947de64427ddad3b (patch) | |
tree | aa41c16f897b4dad0974ecb53269a36f6a4bd982 /contrib | |
parent | 8924ad8d6d57810d4de6ce4ce61efdccc759b066 (diff) | |
download | nova-f4bf828775db8bed77df12a5947de64427ddad3b.tar.gz nova-f4bf828775db8bed77df12a5947de64427ddad3b.tar.xz nova-f4bf828775db8bed77df12a5947de64427ddad3b.zip |
Example config_drive init script, label the config drive
Configuration with DHCP & cloud-init can be painful. The config_drive is great,
and it avoids disk injection, but there's no example of how to use it.
So here's a little example init.d script for contrib, and a code patch to make
sure the config drive gets a nice volume label.
Change-Id: I22a1d6a824856ca9651b435d0fe54e348ab107fe
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/openstack-config | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/contrib/openstack-config b/contrib/openstack-config new file mode 100755 index 000000000..d7979f7ff --- /dev/null +++ b/contrib/openstack-config @@ -0,0 +1,65 @@ +#!/bin/sh -e +### BEGIN INIT INFO +# Provides: openstack +# Required-Start: mountkernfs $local_fs +# Required-Stop: $local_fs +# X-Start-Before: networking +# Should-Start: +# Default-Start: S +# Default-Stop: +# Short-Description: Apply configuration from OpenStack Config Drive +### END INIT INFO + +PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin" + +. /lib/lsb/init-functions + +copy_cloud_config() { + LABEL="config" + if [ ! -e /dev/disk/by-label/${LABEL} ]; then + log_warning_msg "OpenStack Cloud Config drive not found" + return 1 + fi + + MNT=/tmp/config + mkdir -p ${MNT} + mount /dev/disk/by-label/${LABEL} ${MNT} + if [ -e ${MNT}/root/.ssh/authorized_keys ]; then + mkdir -m 700 -p /root/.ssh/ + cp ${MNT}/root/.ssh/authorized_keys /root/.ssh/ + chmod 600 ${MNT}/root/.ssh/authorized_keys + fi + if [ -e ${MNT}/etc/network/interfaces ]; then + cp ${MNT}/etc/network/interfaces /etc/network/ + chmod 644 /etc/network/interfaces + fi + umount ${MNT} + return 0 +} + +case "$1" in + start|"") + log_action_begin_msg "Applying OpenStack Cloud Config" + if copy_cloud_config; then + log_action_end_msg $? + else + log_action_end_msg $? + fi + ;; + + restart|reload|force-reload|status) + echo "Error: argument '$1' not supported" >&2 + exit 3 + ;; + + stop) + # No-op + ;; + + *) + echo "Usage: openstack.sh [start|stop]" >&2 + exit 3 + ;; +esac + +: |