From 91e3b72a23a4bde3c811cedf2224f682aa4d99b7 Mon Sep 17 00:00:00 2001 From: Michael Turek Date: Thu, 12 Oct 2017 10:38:23 -0400 Subject: [PATCH] Add iscsi-boot element This patch adds an element that handles the configuration for creating a disk capable of being a remote root filesystem through iSCSI on Ubuntu and Debian images. Change-Id: Ibf9e39d2bdab530106015f156d23d28029d12b0d Closes-bug: #1716794 --- diskimage_builder/elements/iscsi-boot/README.rst | 13 +++++++++++++ diskimage_builder/elements/iscsi-boot/element-deps | 1 + .../elements/iscsi-boot/package-installs.yaml | 2 ++ .../iscsi-boot/post-install.d/open-iscsi-config | 13 +++++++++++++ 4 files changed, 29 insertions(+) create mode 100644 diskimage_builder/elements/iscsi-boot/README.rst create mode 100644 diskimage_builder/elements/iscsi-boot/element-deps create mode 100644 diskimage_builder/elements/iscsi-boot/package-installs.yaml create mode 100755 diskimage_builder/elements/iscsi-boot/post-install.d/open-iscsi-config diff --git a/diskimage_builder/elements/iscsi-boot/README.rst b/diskimage_builder/elements/iscsi-boot/README.rst new file mode 100644 index 00000000..70a674e1 --- /dev/null +++ b/diskimage_builder/elements/iscsi-boot/README.rst @@ -0,0 +1,13 @@ +========== +iscsi-boot +========== +Handles configuration for the disk to be capable of serving as +a remote root filesystem through iSCSI. Currently, this element +only configures Ubuntu/Debian images. + +It performs the following actions: + +* Installs the ``open-iscsi`` package. +* Creates the ``etc/iscsi/iscsi.initramfs`` configuration file and sets + ``ISCSI_AUTO=true`` within it. +* Updates the initramfs to apply the changes. diff --git a/diskimage_builder/elements/iscsi-boot/element-deps b/diskimage_builder/elements/iscsi-boot/element-deps new file mode 100644 index 00000000..7076aba9 --- /dev/null +++ b/diskimage_builder/elements/iscsi-boot/element-deps @@ -0,0 +1 @@ +package-installs diff --git a/diskimage_builder/elements/iscsi-boot/package-installs.yaml b/diskimage_builder/elements/iscsi-boot/package-installs.yaml new file mode 100644 index 00000000..9eeeeec5 --- /dev/null +++ b/diskimage_builder/elements/iscsi-boot/package-installs.yaml @@ -0,0 +1,2 @@ +open-iscsi: + phase: install.d diff --git a/diskimage_builder/elements/iscsi-boot/post-install.d/open-iscsi-config b/diskimage_builder/elements/iscsi-boot/post-install.d/open-iscsi-config new file mode 100755 index 00000000..4ad292c3 --- /dev/null +++ b/diskimage_builder/elements/iscsi-boot/post-install.d/open-iscsi-config @@ -0,0 +1,13 @@ +#!/bin/bash + +if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then + set -x +fi + +set -eu +set -o pipefail + +if [[ $DISTRO_NAME = "ubuntu" || $DISTRO_NAME = "debian" ]]; then + echo "ISCSI_AUTO=true" > /etc/iscsi/iscsi.initramfs + update-initramfs -u +fi