Skip to content

[DEV-1038] Cloud init lvm growpart #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Sep 5, 2022
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions elements/cloud-init-growpart-lvm/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
=============
cloud-init-growpart-lvm
=============

This element enables growpart for OS images with LVM.
To enable this element simply include it in the elements list.

* ``DIB_CLOUD_INIT_GROWPART_DEVICES`` list of partition names that needs to be
populated in order for cloud-init to grow it. Populating it is mandatory.

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.
2 changes: 2 additions & 0 deletions elements/cloud-init-growpart-lvm/element-deps
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pkg-map
package-installs
1 change: 1 addition & 0 deletions elements/cloud-init-growpart-lvm/package-installs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
growpart_package:
10 changes: 10 additions & 0 deletions elements/cloud-init-growpart-lvm/pkg-map
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"family": {
"redhat": {
"growpart_package": "cloud-utils-growpart"
},
"debian": {
"growpart_package": "cloud-guest-utils"
}
}
}
21 changes: 21 additions & 0 deletions elements/cloud-init-growpart-lvm/post-install.d/55-growpart-lvm
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

if [ ${DIB_DEBUG_TRACE:-1} -gt 0 ]; then
set -x
fi
set -euo 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-lvm.cfg <<EOF
#cloud-config
growpart:
mode: auto
devices: $DIB_CLOUD_INIT_GROWPART_DEVICES
ignore_growroot_disabled: false
EOF
fi
else
echo "You must set the device list: \"$DIB_CLOUD_INIT_GROWPART_DEVICES\"."
exit 1
fi