Best method for automatic provisionig

bit2gb

Well-Known Member
Jul 20, 2016
84
2
48
28
Hello Guys,

Can someoane tell me the best method for provisioning, respecting the next requirements:
What is the flow:
1. Select x os (linux diff distr or win)
2. asign 1 to x ips from my subnets
3.Set x amount of storage space

start it.
Thanks a lot
 
Bumping is generally considered bad style here and will most likely not give you a faster response. Staff is checking up on unanswered threads on a regular basis in case the community could not give an answer.

If you want a guaranteed response in <1 day (which is what your bump conveys), I suggest you take a look at our Basic or Standard subscriptions.
 
Ok I understand.

I try with cloud-init and for some reasone i cant login via console.

i go into gui, clone it, go into cloud init tab, set an username , password, dns domain and server and an ip.
Click on regenerate and start the image.
I cant login into it with any user.
I have:
Proxmox 5.4

Kernel Version

Linux 4.15.18-27-pve #1 SMP PVE 4.15.18-55


Thanks,
Alin.
 
Last edited:
I figure out at the end but i have only 1 problem. Why dosen't have internet on it?
My ip is set, resolv.conf it's ok , hosts are fine... ifcfg-eth0 same fine..
Only issue is on route -n, kernel route map is empty
 
Last edited:
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 :D

#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 :D
packages:
- qemu-guest-agent
- nano
- net-tools
 
Last edited:
Thank you for sharing your guide! Two small remarks: You should
  • pay attention to the security implications of your sshd settings. It might be safer to use SSH keys instead of passwords.
  • be aware that Proxmox VE 5 will reach end of life in July (see our wiki) and plan upgrading to version 6.
Note that our reference documentation contains sections about importing virtual machines and disk images and Cloud-Init.
 
Well i try to use pve 6 but i have some issue like:

clone take more longer in comp with pve 5
durring the install mouse dosen't work
other problems related to qemu last version

I need to have ssh pass instead of rsa key because this is my flow :D
 
Dminic, one question, you know why it's added into vm only 2 ip's via cloud init, even iof i create 3 net interface and into cloud init tab i add for each one an ip?
if i run route -n i see there only 2 eth (0 and 1)

More exactly my question is:
how can i create via cloud init files like ifcfg-eth0:1 instead of ifcfg-eth1 2...
 
Last edited:

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!