How to use xcp-ng templates?

I wanted to simulate an infrastructure of separate services in their own VM’s for scability, so I needed to install several VM’s for each service. I saw that XO offers to use templates when creating vm’s but, until now, I have not seen any added value over using them. Looking around how templates are created, it seems that I want the installation media to have cloud-init installed, which most (all?) default iso’s don’t. It seems that I"m using the wrong iso, but I can’t find any ready to use image that includes them. How can I correctly leverage the templates and saving me the hassle of having to manually configure every vm?

I don’t really use them, I simply have a base VM for the systems I want that I clone for projects as needed.

is that still the case? Usually VMs have residual IDs. In KVM with virsh-sysprep there are 32 checks that clean the image and prepare it for being used as template. If there is no preparation of the image from xcp-ng side, would you recommend getting a template from KVM migrate it to xcp-ng and use that as template? This way your image will be clean and there wouldn’t be any problems down the road.

I am still doing the same, I simply have a base VM for the systems I want that I clone for projects as needed. I do reset SSH as need using this, I never really bothered to script it.

sudo rm -v /etc/ssh/ssh_host_*
sudo dpkg-reconfigure openssh-server
sudo systemctl restart ssh

so would you recommend cleaning the image on the KVM side and porting it to xcp-ng?

Don’t know what that entails so I have no idea, do it how ever you are comfortable doing it.

[~]$ virt-sysprep --list-operations
abrt-data * Remove the crash data generated by ABRT
backup-files * Remove editor backup files from the guest
bash-history * Remove the bash history in the guest
blkid-tab * Remove blkid tab in the guest
ca-certificates Remove CA certificates in the guest
crash-data * Remove the crash data generated by kexec-tools
cron-spool * Remove user at-jobs and cron-jobs
customize * Customize the guest
dhcp-client-state * Remove DHCP client leases
dhcp-server-state * Remove DHCP server leases
dovecot-data * Remove Dovecot (mail server) data
firewall-rules Remove the firewall rules
flag-reconfiguration Flag the system for reconfiguration
fs-uuids Change filesystem UUIDs
ipa-client * Remove the IPA files
kerberos-data Remove Kerberos data in the guest
kerberos-hostkeytab * Remove the Kerberos host keytab file in the guest
logfiles * Remove many log files from the guest
lvm-system-devices * Remove LVM2 system.devices file
lvm-uuids * Change LVM2 PV and VG UUIDs
machine-id * Remove the local machine ID
mail-spool * Remove email from the local mail spool directory
net-hostname * Remove HOSTNAME and DHCP_HOSTNAME in network interface configuration
net-hwaddr * Remove HWADDR (hard-coded MAC address) configuration
net-nmconn * Remove system-local NetworkManager connection profiles (keyfiles)
pacct-log * Remove the process accounting log files
package-manager-cache * Remove package manager cache
pam-data * Remove the PAM data in the guest
passwd-backups * Remove /etc/passwd- and similar backup files
puppet-data-log * Remove the data and log files of puppet
rh-subscription-manager * Remove the RH subscription manager files
rhn-systemid * Remove the RHN system ID
rpm-db * Remove host-specific RPM database files
samba-db-log * Remove the database and log files of Samba
script * Run arbitrary scripts against the guest
smolt-uuid * Remove the Smolt hardware UUID
ssh-hostkeys * Remove the SSH host keys in the guest
ssh-userdir * Remove “.ssh” directories in the guest
sssd-db-log * Remove the database and log files of sssd
tmp-files * Remove temporary files
udev-persistent-net * Remove udev persistent net rules
user-account Remove the user accounts in the guest
utmp * Remove the utmp file
yum-uuid * Remove the yum UUID