summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/cloud-install.yml4
-rw-r--r--roles/cloud/install/tasks/hetzner_installimage.yml1
-rw-r--r--roles/cloud/install/templates/hetzner_postinst.sh.j220
-rw-r--r--roles/cloud/post-install/tasks/hcloud.yml2
-rw-r--r--roles/cloud/post-install/tasks/hetzner_postinst.yml20
-rw-r--r--roles/cloud/post-install/tasks/hroot.yml2
6 files changed, 39 insertions, 10 deletions
diff --git a/common/cloud-install.yml b/common/cloud-install.yml
index 79e22378..304bef8b 100644
--- a/common/cloud-install.yml
+++ b/common/cloud-install.yml
@@ -5,7 +5,7 @@
roles:
- role: cloud/install
-- name: wait for new vm to start up
+- name: wait for new machine to start up
hosts: "{{ hostname }}"
gather_facts: no
tasks:
@@ -13,7 +13,7 @@
- name: disable ssh StrictHostKeyChecking for the next step
set_fact:
ansible_ssh_extra_args: -o StrictHostKeyChecking=no
- - name: wait for vm to start up
+ - name: wait for new machine to start up
wait_for_connection:
delay: 5
timeout: 120
diff --git a/roles/cloud/install/tasks/hetzner_installimage.yml b/roles/cloud/install/tasks/hetzner_installimage.yml
index f54a785b..c2b8f89d 100644
--- a/roles/cloud/install/tasks/hetzner_installimage.yml
+++ b/roles/cloud/install/tasks/hetzner_installimage.yml
@@ -24,7 +24,6 @@
- name: run installimage
command: /root/.oldroot/nfs/install/installimage -a -c installimage.conf -x postinst.sh
register: hetzner_installimage_cmd
- changed_when: true
args:
chdir: /root
diff --git a/roles/cloud/install/templates/hetzner_postinst.sh.j2 b/roles/cloud/install/templates/hetzner_postinst.sh.j2
index 271e51b7..7991ea19 100644
--- a/roles/cloud/install/templates/hetzner_postinst.sh.j2
+++ b/roles/cloud/install/templates/hetzner_postinst.sh.j2
@@ -26,21 +26,29 @@ sed -e '/^\/swapfile/d' -i /etc/fstab
rm -f /swapfile
{% if install_cooked.disks.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
+cat > /post-post-install.sh <<EOF
+#!/bin/bash
+
+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"
+ 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
+
+rm -rf /dummy
+EOF
+
+chmod +x /post-post-install.sh
{% endif %}
+{% if install_distro == "debian" %}
update-grub
+{% endif %}
echo "postinst.sh finished successfully"
diff --git a/roles/cloud/post-install/tasks/hcloud.yml b/roles/cloud/post-install/tasks/hcloud.yml
index 96108c58..0674d270 100644
--- a/roles/cloud/post-install/tasks/hcloud.yml
+++ b/roles/cloud/post-install/tasks/hcloud.yml
@@ -1,4 +1,6 @@
---
+- include_tasks: hetzner_postinst.yml
+
- name: install additional packages
apt:
name:
diff --git a/roles/cloud/post-install/tasks/hetzner_postinst.yml b/roles/cloud/post-install/tasks/hetzner_postinst.yml
new file mode 100644
index 00000000..546cc5ca
--- /dev/null
+++ b/roles/cloud/post-install/tasks/hetzner_postinst.yml
@@ -0,0 +1,20 @@
+---
+- name: check post-post-install script is present
+ stat:
+ path: /post-post-install.sh
+ register: hetzner_post_post_install
+
+- name: run post-post-install script
+ when: hetzner_post_post_install.stat.exists
+ command: /post-post-install.sh
+
+- name: remove installimage artifacts
+ loop:
+ - /installimage.conf
+ - /installimage.debug
+ - /post-install
+ - /post-post-install.sh
+ - /target
+ file:
+ path: "{{ item }}"
+ state: absent
diff --git a/roles/cloud/post-install/tasks/hroot.yml b/roles/cloud/post-install/tasks/hroot.yml
index 51315101..b5a4972f 100644
--- a/roles/cloud/post-install/tasks/hroot.yml
+++ b/roles/cloud/post-install/tasks/hroot.yml
@@ -1,2 +1,2 @@
---
-# nothing to do here.
+- include_tasks: hetzner_postinst.yml