summaryrefslogtreecommitdiff
path: root/roles/cloud-install
diff options
context:
space:
mode:
Diffstat (limited to 'roles/cloud-install')
-rw-r--r--roles/cloud-install/defaults/main.yml3
-rw-r--r--roles/cloud-install/templates/hetzner_installimage.conf.j211
-rw-r--r--roles/cloud-install/templates/hetzner_postinst.sh.j221
3 files changed, 29 insertions, 6 deletions
diff --git a/roles/cloud-install/defaults/main.yml b/roles/cloud-install/defaults/main.yml
index 33e5d165..75e47612 100644
--- a/roles/cloud-install/defaults/main.yml
+++ b/roles/cloud-install/defaults/main.yml
@@ -1,2 +1,3 @@
---
-hetzner_disk_config: "{% if cloud_provider == 'hroot' %}nvme_raid{% elif cloud_provider == 'hcloud' %}hcloud{% endif %}"
+hetzner_disk_setup: "{% if cloud_provider == 'hroot' %}nvme_raid{% elif cloud_provider == 'hcloud' %}hcloud{% endif %}"
+hetzner_root_lvm_size: all
diff --git a/roles/cloud-install/templates/hetzner_installimage.conf.j2 b/roles/cloud-install/templates/hetzner_installimage.conf.j2
index 4c834499..801d448f 100644
--- a/roles/cloud-install/templates/hetzner_installimage.conf.j2
+++ b/roles/cloud-install/templates/hetzner_installimage.conf.j2
@@ -1,20 +1,23 @@
HOSTNAME {{ host_name }}
-{% if hetzner_disk_config == "nvme_raid" %}
+{% if hetzner_disk_setup == "nvme_raid" %}
DRIVE1 /dev/nvme0n1
DRIVE2 /dev/nvme1n1
SWRAID 1
SWRAIDLEVEL 1
-{% elif hetzner_disk_config == "sata_raid" %}
+{% elif hetzner_disk_setup == "sata_raid" %}
DRIVE1 /dev/sda
DRIVE2 /dev/sdb
SWRAID 1
SWRAIDLEVEL 1
-{% elif hetzner_disk_config == "hcloud" %}
+{% elif hetzner_disk_setup == "hcloud" %}
DRIVE1 /dev/sda
{% endif %}
BOOTLOADER grub
PART /boot ext4 512M
-PART lvm {{ host_name }} all
+PART lvm {{ host_name }} {{ hetzner_root_lvm_size }}
+{% if hetzner_root_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
diff --git a/roles/cloud-install/templates/hetzner_postinst.sh.j2 b/roles/cloud-install/templates/hetzner_postinst.sh.j2
index 3ee5a390..2835b477 100644
--- a/roles/cloud-install/templates/hetzner_postinst.sh.j2
+++ b/roles/cloud-install/templates/hetzner_postinst.sh.j2
@@ -21,6 +21,25 @@ sed -e 's/^\(\s*#*\s*Port.*\)/Port {{ hostvars[hostname].ansible_port }}/' -i /e
{% endif %}
{# this is actually only needed on ubuntu bionic and beyond but should not hurt on other installations either #}
-swapoff -a; sed -e '/^\/swapfile/d' -i /etc/fstab; rm -f /swapfile
+swapoff -a
+sed -e '/^\/swapfile/d' -i /etc/fstab
+rm -f /swapfile
+
+{% if hetzner_root_lvm_size != "all" %}
+umount /dummy
+sed -e '/\/dummy/d' -i /etc/fstab
+rm -rf /dummy
+
+raid_devices=$(mdadm -Q -Y --detail /dev/md2 2> /dev/null | awk -F = '/MD_DEVICE_.*_DEV=/ { print($2) }')
+if [ -n "$raid_devices" ]; then
+ mdadm --stop /dev/md2 2> /dev/null
+ for dev in $raid_devices; do
+ wipefs -a "$dev"
+ done
+ sed -e '/^ARRAY \/dev\/md\/2 /d' -i /etc/mdadm/mdadm.conf
+ update-initramfs -u
+fi
+{% endif %}
+
echo "postinst.sh finished successfully"