summaryrefslogtreecommitdiff
path: root/roles/cloud/install
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2020-07-04 17:39:00 +0200
committerChristian Pointner <equinox@spreadspace.org>2020-07-04 17:39:00 +0200
commita1f5550dd6de108f68ea3d6b2a42fe47b49561a4 (patch)
treec96c0b98bf84f30c192708f765e1cb57b78d46ab /roles/cloud/install
parentremove: ch k8s cluster vms, and hroot-test, add hcloud-test (diff)
cloud install: support custom partition layout
Diffstat (limited to 'roles/cloud/install')
-rw-r--r--roles/cloud/install/defaults/main.yml21
-rw-r--r--roles/cloud/install/templates/hetzner_installimage.conf.j214
-rw-r--r--roles/cloud/install/templates/hetzner_postinst.sh.j210
3 files changed, 37 insertions, 8 deletions
diff --git a/roles/cloud/install/defaults/main.yml b/roles/cloud/install/defaults/main.yml
new file mode 100644
index 00000000..975400a5
--- /dev/null
+++ b/roles/cloud/install/defaults/main.yml
@@ -0,0 +1,21 @@
+---
+hetzner_boot_size: 512M
+
+hetzner_system_lvm_size_default: all
+hetzner_system_lvm_volumes_default:
+ - name: root
+ size: 2560M
+ filesystem: ext4
+ mountpoint: /
+ - name: var
+ size: 1280M
+ filesystem: ext4
+ mountpoint: /var
+ - name: var+log
+ size: 768M
+ filesystem: ext4
+ mountpoint: /var/log
+ mount_options:
+ - noatime
+ - nodev
+ - noexec
diff --git a/roles/cloud/install/templates/hetzner_installimage.conf.j2 b/roles/cloud/install/templates/hetzner_installimage.conf.j2
index ed22f286..e3cd4c4e 100644
--- a/roles/cloud/install/templates/hetzner_installimage.conf.j2
+++ b/roles/cloud/install/templates/hetzner_installimage.conf.j2
@@ -13,12 +13,14 @@ DRIVE1 {{ install_cooked.disks.primary }}
DRIVE1 /dev/sda
{% endif %}
BOOTLOADER grub
-PART /boot ext4 512M
-PART lvm {{ host_name }} {{ install_cooked.disks.root_lvm_size }}
-{% if install_cooked.disks.root_lvm_size != "all" %}
+PART /boot ext4 {{ hetzner_boot_size }}
+{% set system_lvm_size = install_cooked.system_lvm.size | default(hetzner_system_lvm_size_default) %}
+PART lvm {{ host_name }} {{ system_lvm_size }}
+{% if system_lvm_size != "all" %}
PART /dummy ext4 all
{% endif %}
-LV {{ host_name }} root / ext4 2560M
-LV {{ host_name }} var /var ext4 1280M
-LV {{ host_name }} var+log /var/log ext4 768M
+{% set system_lvm_volumes = install_cooked.system_lvm.volumes | default(hetzner_system_lvm_volumes_default) %}
+{% for volume in system_lvm_volumes %}
+LV {{ host_name }} {{ volume.name }} {{ volume.mountpoint }} {{ volume.filesystem }} {{ volume.size }}
+{% endfor %}
IMAGE {{ latest_image.stdout }}
diff --git a/roles/cloud/install/templates/hetzner_postinst.sh.j2 b/roles/cloud/install/templates/hetzner_postinst.sh.j2
index 613f57ac..d9de15c9 100644
--- a/roles/cloud/install/templates/hetzner_postinst.sh.j2
+++ b/roles/cloud/install/templates/hetzner_postinst.sh.j2
@@ -27,7 +27,12 @@ passwd -d root && passwd -l root
{% if install_distro == "debian" %}
sed -e 's/^allow-hotplug/auto/' -i /etc/network/interfaces
{% endif %}
-sed -r 's#(\s+/var/log\s+ext4\s+)defaults#\1noatime,nodev,noexec#g' -i /etc/fstab
+{% set system_lvm_volumes = install_cooked.system_lvm.volumes | default(hetzner_system_lvm_volumes_default) %}
+{% for volume in system_lvm_volumes %}
+{% if 'mount_options' in volume %}
+sed -r 's#(\s+{{ volume.mountpoint }}\s+{{ volume.filesystem }}\s+)defaults#\1{{ volume.mount_options | join(",") }}#g' -i /etc/fstab
+{% endif %}
+{% endfor %}
mkdir -p -m 0700 /target/root/.ssh
cat <<EOK > /root/.ssh/authorized_keys
@@ -42,7 +47,8 @@ swapoff -a
sed -e '/^\/swapfile/d' -i /etc/fstab
rm -f /swapfile
-{% if install_cooked.disks.root_lvm_size != "all" %}
+{% set system_lvm_size = install_cooked.system_lvm.size | default('all') %}
+{% if system_lvm_size != "all" %}
sed -e '/\/dummy/d' -i /etc/fstab
cat > /post-install-finalize <<EOF