summaryrefslogtreecommitdiff
path: root/roles/cloud-install/templates/hetzner_postinst.sh.j2
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2019-04-14 19:09:49 +0200
committerChristian Pointner <equinox@spreadspace.org>2019-04-14 19:09:49 +0200
commita93773afc2e512f5a6c04326825df17c8899fd43 (patch)
tree6134809cfa2d045b9041f8a75e66368076a5061f /roles/cloud-install/templates/hetzner_postinst.sh.j2
parentmake hetzner postinst script nicer (diff)
hetzner smaller root lv
Diffstat (limited to 'roles/cloud-install/templates/hetzner_postinst.sh.j2')
-rw-r--r--roles/cloud-install/templates/hetzner_postinst.sh.j221
1 files changed, 20 insertions, 1 deletions
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"