The branch main has been updated by bapt:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=78b6117dac99c80fe618979fef4ef322b97415fa

commit 78b6117dac99c80fe618979fef4ef322b97415fa
Author:     Baptiste Daroussin <[email protected]>
AuthorDate: 2024-03-15 08:43:20 +0000
Commit:     Baptiste Daroussin <[email protected]>
CommitDate: 2024-03-18 09:58:50 +0000

    release: add basic cloudinit images
    
    Provide both zfs and ufs images which a 1MB partition reserved for the
    config drive wearing a GPT Label "config-drive" to allow consumer to
    know where they should push the config drive on the provided image.
    
    2 formats available: qcow2 and raw
    
    This has been tested on OVHCloud baremetal via "bring your own image"
    Also tested on openstack
    
    Reviewed by:            emaste
    Sponsored by:           OVHCloud
    Differential Revision:          https://reviews.freebsd.org/D44369
---
 release/Makefile.vm                |  4 ++++
 release/tools/basic-cloudinit.conf | 36 ++++++++++++++++++++++++++++++++++++
 release/tools/vmimage.subr         |  5 +++++
 3 files changed, 45 insertions(+)

diff --git a/release/Makefile.vm b/release/Makefile.vm
index b9c43e8b491f..2b252aa18c3a 100644
--- a/release/Makefile.vm
+++ b/release/Makefile.vm
@@ -19,6 +19,7 @@ RAW_DESC=     Unformatted raw disk image
 
 CLOUDWARE_TYPES?= AZURE \
                BASIC-CI \
+               BASIC-CLOUDINIT \
                EC2 \
                GCE \
                OCI \
@@ -29,6 +30,9 @@ AZURE_DESC=   Microsoft Azure platform image
 BASIC-CI_FORMAT=       raw
 BASIC-CI_FSLIST?=      ufs
 BASIC-CI_DESC=         Image for CI
+BASIC-CLOUDINIT_FORMAT=        raw qcow2
+BASIC-CLOUDINIT_FSLIST?=       ufs zfs
+BASIC_CLOUDINIT_DESC?= Images for VM with cloudinit disk config support
 EC2_FORMAT=    raw
 EC2_FSLIST?=   ufs zfs
 EC2_FLAVOURS?= BASE CLOUD-INIT
diff --git a/release/tools/basic-cloudinit.conf 
b/release/tools/basic-cloudinit.conf
new file mode 100644
index 000000000000..da4bed5ea5b5
--- /dev/null
+++ b/release/tools/basic-cloudinit.conf
@@ -0,0 +1,36 @@
+#!/bin/sh
+#
+#
+
+# Should be enough for base image, image can be resized in needed
+export VMSIZE=5g
+
+# 1M config drive should be enough in most cases
+export CONFIG_DRIVE=YES
+export CONFIG_DRIVE_SIZE=1M
+
+# Set to a list of third-party software to enable in rc.conf(5).
+export VM_RC_LIST="sshd growfs nuageinit"
+
+vm_extra_pre_umount() {
+       cat << EOF >> ${DESTDIR}/etc/rc.conf
+dumpdev="AUTO"
+ifconfig_DEFAULT="DHCP"
+sshd_enable="YES"
+EOF
+
+       cat << EOF >> ${DESTDIR}/boot/loader.conf
+autoboot_delay="-1"
+beastie_disable="YES"
+loader_logo="none"
+console="comconsole,vidconsole"
+EOF
+    cat <<EOF >> ${DESTDIR}/etc/ssh/sshd_config
+PasswordAuthentication yes
+UsePAM no
+EOF
+
+       touch ${DESTDIR}/firstboot
+
+       return 0
+}
diff --git a/release/tools/vmimage.subr b/release/tools/vmimage.subr
index 41437a9e1edb..0346e33b81b4 100644
--- a/release/tools/vmimage.subr
+++ b/release/tools/vmimage.subr
@@ -239,6 +239,10 @@ vm_create_disk() {
                BOOTPARTSOFFSET=":${VM_BOOTPARTSOFFSET}"
        fi
 
+       if [ -n "${CONFIG_DRIVE}" ]; then
+               CONFIG_DRIVE="-p freebsd/config-drive::${CONFIG_DRIVE_SIZE}"
+       fi
+
        case "${VMFS}" in
        ufs)
                FSPARTTYPE=freebsd-ufs
@@ -312,6 +316,7 @@ vm_create_disk() {
        mkimg -s ${PARTSCHEME} -f ${VMFORMAT} \
                ${BOOTPARTS} \
                ${SWAPOPT} \
+               ${CONFIG_DRIVE} \
                ${ROOTFSPART} \
                -o ${VMIMAGE}
 

Reply via email to