From 822644fc5460165c2597c284d8cfd8d6a102881d Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Sat, 17 May 2014 11:31:09 -0700 Subject: [PATCH] feat(build_image): Add support for injecting a cloud config The new --developer_data option can be used to specify a path to a cloud config to bundle into the image. If none is provided but a shared user password (for core) is set then generate a config to set that password. This lets us use the same mechanism for setting the default password for both disk and PXE images. --- build_image | 19 +++++++++++++++++++ build_library/build_image_util.sh | 8 ++++++++ build_library/vm_image_util.sh | 12 ------------ 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/build_image b/build_image index 39ed8446b5..5e21637fda 100755 --- a/build_image +++ b/build_image @@ -38,6 +38,8 @@ DEFINE_string group "${DEFAULT_GROUP}" \ "The update group." DEFINE_boolean generate_update "${FLAGS_FALSE}" \ "Generate update payload. (prod only)" +DEFINE_string developer_data "" \ + "Insert a custom cloudinit file into the image." # include upload options . "${BUILD_LIBRARY_DIR}/release_util.sh" || exit 1 @@ -131,6 +133,23 @@ mkdir -p "${BUILD_DIR}" DISK_LAYOUT="${FLAGS_disk_layout:-base}" +if [[ -n "${FLAGS_developer_data}" ]]; then + if [[ ! -f "${FLAGS_developer_data}" ]]; then + die_notrace "Developer data is not a file: ${FLAGS_developer_data}" + fi + info "Using developer cloudinit data: ${FLAGS_developer_data}" +elif [[ -s /etc/shared_user_passwd.txt ]]; then + FLAGS_developer_data="${BUILD_DIR}/developer_data" + info "Generating developer cloudinit with shared user password." + cat >"${FLAGS_developer_data}" <"${VM_TMP_DIR}/extra" else - # Use OEM cloud-config to setup the core user's password - if [[ -s /etc/shared_user_passwd.txt ]]; then - sudo mkdir -p "${cpio_target}/usr/share/oem" - sudo_clobber "${cpio_target}/usr/share/oem/cloud-config.yml" <"${VM_TMP_DIR}/extra" fi