Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for disk-based deployment mode for Debian 11 #261

Closed
1 task done
tenthirtyam opened this issue Aug 24, 2022 · 10 comments · Fixed by #272
Closed
1 task done

Add support for disk-based deployment mode for Debian 11 #261

tenthirtyam opened this issue Aug 24, 2022 · 10 comments · Fixed by #272
Assignees
Labels
priority/medium Priority Medium sev/low Low type/enhancement Enhancement
Milestone

Comments

@tenthirtyam
Copy link
Collaborator

tenthirtyam commented Aug 24, 2022

Code of Conduct

  • I have read and agree to the project's Code of Conduct.

Description

Debian 11 was introduced to the project in the v22.08 release with only support for HTTP-based deployment only.

This issue will track the an enhancement for disk-based deployment support.

Use Case(s)

Support disk-based deployment.

Potential Configuration

To be determined.

References

CHANGELOG:

> **Note**
>
> - HTTP-based deployment only. Disk-based deployment planned.

GH-195

Mentions

cc @joisika

@tenthirtyam tenthirtyam self-assigned this Aug 24, 2022
@tenthirtyam tenthirtyam added this to the Backlog milestone Aug 24, 2022
@tenthirtyam
Copy link
Collaborator Author

Discovery Context

  1. Ensure the the locals for the data_source_command includes the correct the disk -based data source option for kickstart to use the methods mentions earlier in the thread, but retain the http -based methods as the default.

data_source_command:

locals {
   # ... excluded for brevity ...
   data_source_content = {
     "/ks.cfg" = templatefile("${abspath(path.root)}/data/ks.pkrtpl.hcl", {
       build_username           = var.build_username
       build_password_encrypted = var.build_password_encrypted
       vm_guest_os_language     = var.vm_guest_os_language
       vm_guest_os_keyboard     = var.vm_guest_os_keyboard
       vm_guest_os_timezone     = var.vm_guest_os_timezone
     })
   }
   data_source_command = var.common_data_source == "http" ? "url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg" : "file=dev/sr1:/ks.cfg"
   # ... excluded for brevity ...

This will allow the OS to boot from the `.iso; however, two additional requirements are required:

  1. The boot_command must be modified to mount the .iso based on the var.common_data_source != http (disk). For example:
boot_command = [
     "c<wait>", 
     "linux /install.amd/vmlinuz", 
     " auto-install/enable=true", 
     " debconf/priority=critical",
     " preseed/file=/mnt/cdrom2/ks.cfg<enter><wait>", 
     "initrd /install.amd/initrd.gz<enter><wait>", 
     "boot<enter><wait>", 
     "<leftAltOn><f2><leftAltOff>", 
     "<enter><wait>", 
     "mkdir /mnt/cdrom2<enter>", 
     "mount /dev/sr1 /mnt/cdrom2<enter>", 
     "<leftAltOn><f1><leftAltOff>", 
     "<enter><wait><enter>", 
     "<down><down><down><down><enter>" 
]
  1. Next, will need to determine if the preseed (ks.cfg) can be updated based on the disk source so that it's removed upon completion of the OS installation. For example:

ks.cfg:

d-i preseed/early_command string umount /mnt/cdrom2 && echo 1 > /sys/block/sr1/device/delete

Note: It was observed in some initial testing that the use of the .iso for the kickstart file may require supplying an md5 checksum for the ks.cfg.

Ryan Johnson
Senior Staff Solutions Architect | Product Engineering @ VMware, Inc.

@tenthirtyam tenthirtyam modified the milestones: Backlog, v22.09 Aug 25, 2022
@ukushisanet
Copy link
Contributor

ukushisanet commented Sep 19, 2022

Hi,

Tested here, it works. I did not need to pass the md5 hash for the .iso.

Regards

@tenthirtyam
Copy link
Collaborator Author

@ukushisanet - Did you make the direct change or modify it to work based on the datasource selection?

@ukushisanet
Copy link
Contributor

ukushisanet commented Sep 19, 2022

Sorry, but not sure to understand but yes it is based on datasource selection.

My datasource content and command look like this:

  data_source_content = {
    "/preseed.cfg" = templatefile("${abspath(path.root)}/data/preseed.pkrtpl.hcl", {
      build_username           = var.build_username
      build_password_encrypted = var.build_password_encrypted
      build_public_key         = var.build_public_key
      vm_guest_os_language     = var.vm_guest_os_language
      vm_guest_os_keyboard     = var.vm_guest_os_keyboard
      vm_guest_os_timezone     = var.vm_guest_os_timezone
    })
  }
  
  data_source_command = var.common_data_source == "http" ? "url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg" : "file=/media/preseed.cfg"

I need to use the cd_content variable instead of floppy_content like this:

 cd_content = var.common_data_source == "disk" ? local.data_source_content : null

The http_content is like other template:

http_content   = var.common_data_source == "http" ? local.data_source_content : null

And my boot_command look like this:

  boot_command = [
    "<wait3s>c<wait3s>",
    "linux /install.amd/vmlinuz",
    " auto=true priority=critical locale=${var.vm_guest_os_language}",
    " debconf/frontend=noninteractive",
    " ${local.data_source_command}<enter>",
    "initrd /install.amd/initrd.gz<enter>",
    "boot<enter>",
    "<wait30s>",
    "<enter><wait>",
    "<enter><wait>",
    "<leftAltOn><f2><leftAltOff>",
    "<enter><wait>",
    "mount /dev/sr1 /media<enter>",
    "<leftAltOn><f1><leftAltOff>",
    "<down><down><down><down><enter>"
  ]

I can not use the http content source in my project due to firewall segmentation, so my common_data_source variable is set to disk in my common variable file common_pkrvars.hcl.

common_data_source      = "disk"

And it works like this.

@tenthirtyam
Copy link
Collaborator Author

Excellent, thank you for the feedback in confirming that this works.

If you'd like to make a contribution to the project based on the discover and your testing, please let me know.

If not, that's okay, I plan to address it for the next release.

Ryan Johnson
Senior Staff Solutions Architect | Product Engineering @ VMware, Inc.

@ukushisanet
Copy link
Contributor

I forgot the magic trick, the d-i early_command in the preseed file to unmount the cdrom2

d-i preseed/early_command string \
    umount /media && echo 1 > /sys/block/sr1/device/delete ;

I have modify a lot of things to fit my needs so it's difficult to commit my work directly but yes I can do the contribution.

Let me some minutes.

Regards

@tenthirtyam
Copy link
Collaborator Author

Thanks, I suspected that this would be the path.

For the contribution, you'll need to ensure that the boot_command and the preseed/early_command is determined based on the configuration in the common_data_source variable.

Ryan

@ukushisanet
Copy link
Contributor

ukushisanet commented Sep 20, 2022

The PR #272 is open for review.

By the way, I can't reproduce the problem with the vm_guest_os_type explain in this comment.

Everything is working fine for me, Cloud-init and Guest OS Customization.

With vm_guest_os_type variable set to debian11_64Guest I can do this with Guest OS Customization:

  • Set the root password
  • Set IP from an IP POOL (on VCD)
  • Execute a custom script
  • Set the hostname (with the computer name field in VCD)

This is off-topic but since the issue is closed and I saw that vm_guest_os_type is still set toother4xLinux64Guest I just want to notice it. If you want I can do more tests if you have a special use-case.

Regards

@tenthirtyam
Copy link
Collaborator Author

The issue in that comment is in regards to when the virtual machine is copied to a content library as an OVF Template.

In this scenario, when Guest OS customizations are run using VM Tools the guest OS will be deterred and set to debian11_64Guest and the customization will fail.

There is an override in the Ansible playbook that will enforce the setting needed in the VMware Tools configuration. This setting was added after root causing this with the engineer responsible for guest OS and customization.

Ryan Johnson
Senior Staff Solutions Architect | Product Engineering @ VMware, Inc.

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
priority/medium Priority Medium sev/low Low type/enhancement Enhancement
Projects
None yet
2 participants