From b73048f98d92f1f92b42e333c77c27fc657babf3 Mon Sep 17 00:00:00 2001 From: Rafal Lewandowski Date: Mon, 5 Sep 2022 10:18:41 +0200 Subject: [PATCH] Added cloud-init growpart element Added growpart element. It allows for growing specific partitions during the deployment, which will result in less post deploy actions needed for the server to be ready for use. Change-Id: I6519fba3e8f1d078b99d3c03f2ac85f7b6e37d8a --- .../elements/cloud-init-growpart/README.rst | 17 +++++++++++++ .../elements/cloud-init-growpart/element-deps | 2 ++ .../cloud-init-growpart/package-installs.yaml | 1 + .../elements/cloud-init-growpart/pkg-map | 10 ++++++++ .../post-install.d/55-growpart | 25 +++++++++++++++++++ ...ded_growpart_for_lvm-0ce76ba71710c720.yaml | 7 ++++++ 6 files changed, 62 insertions(+) create mode 100644 diskimage_builder/elements/cloud-init-growpart/README.rst create mode 100644 diskimage_builder/elements/cloud-init-growpart/element-deps create mode 100644 diskimage_builder/elements/cloud-init-growpart/package-installs.yaml create mode 100644 diskimage_builder/elements/cloud-init-growpart/pkg-map create mode 100755 diskimage_builder/elements/cloud-init-growpart/post-install.d/55-growpart create mode 100644 diskimage_builder/elements/cloud-init-growpart/releasenotes/notes/added_growpart_for_lvm-0ce76ba71710c720.yaml diff --git a/diskimage_builder/elements/cloud-init-growpart/README.rst b/diskimage_builder/elements/cloud-init-growpart/README.rst new file mode 100644 index 00000000..72810639 --- /dev/null +++ b/diskimage_builder/elements/cloud-init-growpart/README.rst @@ -0,0 +1,17 @@ +=================== +cloud-init-growpart +=================== + +This element enables growpart for OS images. It allows to grow +Specific partitions during the deployment process. +To enable this element simply include it in the elements list. + +**Disclaimer:** This element might not work with some device names supplied, for example when server is deployed and the image is written to a fibre channel device, or a SAS/SATA SSD controller. + +* ``DIB_CLOUD_INIT_GROWPART_DEVICES``: List of partition names that needs to be populated in order to be grown by cloud-init. **Populating this variable is mandatory.** + Cloud-init growpart module documentation - https://cloudinit.readthedocs.io/en/latest/topics/modules.html?highlight=growpart#growpart + +Dependencies: + +* ``/usr/bin/growpart``: **is needed on the system in order to grow the partition**, + however it is part of different packages depending on linux family. That is already taken care of by package-installs. diff --git a/diskimage_builder/elements/cloud-init-growpart/element-deps b/diskimage_builder/elements/cloud-init-growpart/element-deps new file mode 100644 index 00000000..73015c24 --- /dev/null +++ b/diskimage_builder/elements/cloud-init-growpart/element-deps @@ -0,0 +1,2 @@ +package-installs +pkg-map diff --git a/diskimage_builder/elements/cloud-init-growpart/package-installs.yaml b/diskimage_builder/elements/cloud-init-growpart/package-installs.yaml new file mode 100644 index 00000000..46a70873 --- /dev/null +++ b/diskimage_builder/elements/cloud-init-growpart/package-installs.yaml @@ -0,0 +1 @@ +growpart_package: diff --git a/diskimage_builder/elements/cloud-init-growpart/pkg-map b/diskimage_builder/elements/cloud-init-growpart/pkg-map new file mode 100644 index 00000000..4bfbc20e --- /dev/null +++ b/diskimage_builder/elements/cloud-init-growpart/pkg-map @@ -0,0 +1,10 @@ +{ + "family": { + "redhat": { + "growpart_package": "cloud-utils-growpart" + }, + "debian": { + "growpart_package": "cloud-guest-utils" + } + } +} diff --git a/diskimage_builder/elements/cloud-init-growpart/post-install.d/55-growpart b/diskimage_builder/elements/cloud-init-growpart/post-install.d/55-growpart new file mode 100755 index 00000000..0f433b68 --- /dev/null +++ b/diskimage_builder/elements/cloud-init-growpart/post-install.d/55-growpart @@ -0,0 +1,25 @@ +#!/bin/bash + +if [ ${DIB_DEBUG_TRACE:-1} -gt 0 ]; then + set -x +fi +set -eu +set -o pipefail + +if [[ -n ${DIB_CLOUD_INIT_GROWPART_DEVICES} ]]; then + if [ -d /etc/cloud/cloud.cfg.d ]; then + cat > /etc/cloud/cloud.cfg.d/55-growpart.cfg <