commit c4e08c7045e3385b5f21799dc91f73b5e1f147c7
parent 2cc34fac23e4004483ac2f4841efd8eea06cd370
Author: Andreas Gruhler <andreas.gruhler@adfinis-sygroup.ch>
Date: Mon, 30 Dec 2019 16:42:18 +0000
install cloud-init after reboot
Diffstat:
4 files changed, 33 insertions(+), 20 deletions(-)
diff --git a/centos8.json b/centos8.json
@@ -49,6 +49,12 @@
"template_description": "CentOS 8, generated on {{ isotime }}"
}
],
+ "provisioners": [
+ {
+ "type": "shell",
+ "script": "scripts/cloud-config.sh"
+ }
+ ],
"post-processors": [
{
"type": "manifest",
diff --git a/config/ks.cfg b/config/ks.cfg
@@ -35,27 +35,10 @@ reboot
@core
@^minimal install
qemu-guest-agent
-cloud-init
-cloud-utils-growpart
%end
# once the installation is complete,
# but before the system is rebooted for the first time
-%post
-# disable cloud-init
-#touch /etc/cloud/cloud-init.disabled
-# reset cloud-init
-rm -rf /var/lib/cloud
-
-# change cloud-init default user
-sed -i \
- -e 's/name: cloud-user/name: centos/' \
- /etc/cloud/cloud.cfg
-
-# resolve fqdn/hostname to public address
-sed -i \
- -e 's/127.0.0.1 {{fqdn}} {{hostname}}/#127.0.0.1 {{fqdn}} {{hostname}}/' \
- -e 's/::1 {{fqdn}} {{hostname}}/#::1 {{fqdn}} {{hostname}}/' \
- /etc/cloud/templates/hosts.redhat.tmpl
-%end
+#%post
+#%end
diff --git a/scripts/cloud-config.sh b/scripts/cloud-config.sh
@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+
+set -o errexit
+set -o nounset
+#set -o xtrace
+
+# install cloud-init
+yum install -y cloud-init cloud-utils-growpart
+
+# disable cloud-init
+#touch /etc/cloud/cloud-init.disabled
+# reset cloud-init
+#rm -rf /var/lib/cloud
+
+# change cloud-init default user
+sed -i \
+ -e 's/name: cloud-user/name: centos/' \
+ /etc/cloud/cloud.cfg
+
+# resolve fqdn/hostname to public address
+sed -i \
+ -e 's/127.0.0.1 {{fqdn}} {{hostname}}/#127.0.0.1 {{fqdn}} {{hostname}}/' \
+ -e 's/::1 {{fqdn}} {{hostname}}/#::1 {{fqdn}} {{hostname}}/' \
+ /etc/cloud/templates/hosts.redhat.tmpl
diff --git a/scripts/post-process.sh b/scripts/post-process.sh
@@ -7,7 +7,7 @@ set -o nounset
# https://pve.proxmox.com/wiki/Proxmox_VE_API
# https://pve.proxmox.com/wiki/Cloud-Init_Support#_preparing_cloud_init_templates
-#yum install -y epel-release jq curl
+yum install -y epel-release jq curl
# read vm id from latest build
vmid=$(jq -r '.builds | sort_by(.build_time) | reverse | .[0].artifact_id' "$PACKER_MANIFEST")