theforeman / foreman_fog_proxmox

Foreman plugin to add Proxmox compute resource based on fog-proxmox gem
GNU General Public License v3.0
105 stars 30 forks source link

Disk resize on image based host creation #80

Closed pdzionek closed 4 years ago

pdzionek commented 5 years ago

Is your feature request related to a problem? Please describe. If you create a new VM using the image based provisioning, it would be nice to run a resize on a cloned template disk. Right now, it only clones a template and run some configure things. Therefore, we always start with a same OS disk size.

Describe the solution you'd like Plugin should create a new VM by cloning existing template and resize cloned disk to size specified in VM Creation process. Before resizing, it should check if cloned template disk size is smaller than a disk size requested by the user.

Additional context I am aware that there could be templates with more than a one disk, but in most scenarios, you clone a template with only one disk containing your OS. So it should only be limited to this use case.

And one more thing, as soon as, cloud init, is done, this will work perfectly with a finish scripts, which would login and grow your FS to maximum specified size.

tristanrobert commented 5 years ago

I don't quite understand your feature. You could first resize your disk (plugin version >= 0.7) and then clone your vm. Doing many operations all in one may be usefull for you but I am not sure it will be for everybody. Keeping it simple and atomic should be better for everybody.

pdzionek commented 5 years ago

This way you could automate the whole process of provisioning this type of VM (image based provisioning). So steps would be for Create Host like:

  1. Clone a specific template based on user choice.
  2. Resize OS disk to size specified by a user.
  3. Provide cloud init data (I saw that this is on todo list)
  4. Start a VM - (now it doesn't start a VM, it would be nice to have this as a feature)
  5. Run finish script, which will login, resize disk, install all things you need, puppet and more.
  6. Done. Installation finished, without login to Proxmox even once.

As an example, this type of provisioning you can achieve with simple libvirt/KVM and pxe/dhcp provisioning. Where you don't have to login to kvm machine console or GUI at all. Foreman is able to deploy everything by itself. It creates VM, set disks, boots the vm, provides data via pxe/dhcp and installs whole OS. I think that the same thing is possible with proxmox with pxe/dhcp (didn't it try yet, because of instability, right now) and it would be nice to have something similar with image based provisioning.

This is just an idea, based on what I was doing while working with libvirt, foreman and proxmox.

tristanrobert commented 5 years ago
  1. included since 0.5
  2. included since 0.8
  3. planned in 0.8
  4. included since 0.5
  5. included in foreman (see provisionning templates)
pdzionek commented 5 years ago

Yes, I am aware of all of this, but you are still unable to do it with one "Submit click" from Create Host. I have to manually click edit and resize vm for already created host. I have to manually click start in Foreman. Foreman after submiting vm doesn't start VM, I have to do it via Start button for already created host or via Proxmox GUI. Therefore, it is hard to call it an unattended installation.

tristanrobert commented 5 years ago

If you need to resize your disk, maybe your initial size is not sufficient. You can automatically start a VM at boot when you specify onboot=true. You could add a cdrom iso image to boot in. You will need a provision template to automate anything else. In Debian you can use preseed templates to automate this. iPXE templates (tft server) are another tools to automate provisionning, etc.

pdzionek commented 5 years ago

@tristanrobert I use predefined Ubuntu Cloud Images, which are already prepared to be used on cloud systems. e.g. bionic prepared image has by default 2,2 GB size. My idea here was not to edit manually, but let, like in other Cloud solution, foreman do a resize on creation and later run growfs/resize2fs in finish script. Therefore, you could set a main disk size to whatever value you want in creation process.

Regarding, onboot=true if you are referring to "Start on boot" option (i am not sure if this is the same as onboot=yes) it only starts the VM when compute node is started. There is also something like "Start after created" in VM creation process in Proxmox, in a last Confirm Tab. Maybe it would be possible to add this as a checkbox in this plugin ? However, i guess it only applies to create call, I am not sure if it is possible to use this in clone API call.

pdzionek commented 5 years ago

So I assume you did not like me idea ;)

tristanrobert commented 5 years ago

No it is fixed in master 0.8.0.

pdzionek commented 5 years ago

Great, I will test it as soon as it is released with foreman.