I go and post here my method to deploy cloud init vm's
https://cloud.centos.org/centos/7/images/
https://cloud-images.ubuntu.com/
https://cdimage.debian.org/cdimage/openstack/current-10/
P.S. Read the end part before to begin.
P.S.1. For more info send me a beer, open yours and after this step we can discuss
#create a new vm
qm create 9004 --memory 2048 --net0 virtio,bridge=vmbr0
# import the downloaded disk to local storage (in this case it's about ubuntu but can be use ani distr, see links on the top)
qm importdisk 9004 bionic-server-cloudimg-amd64.img local
# finally attach the new disk to the VM as scsi drive
qm set 9004 --scsihw virtio-scsi-pci --scsi0 local:9004/vm-9004-disk-0.raw
#NOTE: images requires the `virtio-scsi-pci` controller type for SCSI drives.
# The next step is to configure a CDROM drive, used to pass the Cloud-Init data to the VM.
qm set 9004 --ide2 local:cloudinit
# We want to boot directly from the Cloud-Init image, so we set the `bootdisk` parameter to `scsi0` and restrict BIOS to boot from disk
# only. This simply speeds up booting, because VM BIOS skips testing for a bootable CDROM.
qm set 9004 --boot c --bootdisk scsi0
#We also want to configure a serial console and use that as display. Many Cloud-Init images rely on that, because it is an requirement for OpenStack #images.
qm set 9004 --serial0 socket --vga serial0
# Finally, it is usually a good idea to transform such VM into a template. You can create linked clones with them, so deployment from VM templates #is much faster than creating a full clone (copy).
100 qm template 9004
Create/clone firs vm from this template:
qm clone <id tpl> <new id> --name <name>
qm set <new id> --ipconfig0 ip=10.0.10.123/24,gw=10.0.10.1 --ciuser=<username> --cipassword=<pass> --nameserver=8.8.8.8 --searchdomain=domain.com
qm start <new id>
Be careful when you set the ip, because if your gw it's out of range, based on netmask used, network on your vm will not work.
You will be able to connect using username and password used into the command (even user root work fine)
Read before to start!!
Well each templ need to be edited on his own way before to use it.
Why? Because all of them (centos, deb, ubnt) have for example root disable from ssh, sshd dosen't permit password ...
So we need to use virt-edit to configure templ imediatly after download.
So the steps are:
apt-get install libguestfs-tools
#define nano as a default editor (you can use vim or simply go to next step )
export EDITOR=nano
#we go and edit cloud.cfg
virt-edit -a path/to/your.download.image/bionic-server-cloudimg-amd64.img /etc/cloud/cloud.cfg
#here we ned to change next lines or check if have this values:
disable_root: false #centos for example use 0 and 1 where 0 is false and 1 is true
#only for centos
ssh_pwauth: 1
#for all
lock_passwd: false
#Now we need to edit sshd_config
virt-edit -a path/to/your.download.image/bionic-server-cloudimg-amd64.img /etc/ssh/sshd_config
#permit root login (remove # from this line and set to yes)
PermitRootLogin yes
#permit password auth (remove # from this line and set to yes)
PasswordAuthentication yes
#Additional you can add some app who can be installed at deploy like this into the end of cloud.cfg
#Pay attention for the formatting, is crucial , copy my example and keep like this
#To work need to mentain update step enable into cloud.cfg and not delete it (by default it's there and enabled) so if you not delete it will be #work like a charm
packages:
- qemu-guest-agent
- nano
- net-tools