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 super key (vmware builder) #5681

Merged
merged 2 commits into from
Feb 2, 2018
Merged

Conversation

mcandre
Copy link

@mcandre mcandre commented Dec 8, 2017

Add the critical Super key as a boot_command term. This key works for Linux guests as the Super key, macOS guests as the Command key, and should work for Windows guests as the Windows key, though Windows deserves additional testing.

Note that other builders should also be upgraded to recognize the super key, like VirtualBox. This is just a quick proof of concept based on the current structure of the packer codebase.

Example usage: Raising the music menu in Ubuntu 16.04.

{
  "builders": [
    {
      "type": "vmware-iso",
      "boot_command": [
        "<enter><wait10><wait10><wait10><wait10>",
        "<tab><spacebar><wait10><wait10><wait10>",
        "<leftSuperOn>m<leftSuperOff><wait10>",
        "<rightSuperOn>m<rightSuperOff>"
      ],
      "boot_wait": "10s",
      "disk_size": 81920,
      "guest_os_type": "ubuntu-64",
      "iso_url": "http://releases.ubuntu.com/16.04/ubuntu-16.04.3-desktop-amd64.iso",
      "iso_checksum_type": "sha256",
      "iso_checksum": "1384ac8f2c2a6479ba2a9cbe90a585618834560c477a699a4a7ebe7b5345ddc1",
      "ssh_username": "vagrant",
      "ssh_password": "vagrant",
      "ssh_wait_timeout": "1800s",
      "shutdown_command": "echo 'vagrant' | sudo -S shutdown -P now",
      "vm_name": "packer-super-test",
      "vmx_data": {
        "memsize": "1024"
      }
    }
  ]
}

I also tested this PR with macOS guest, using ISO's generated from Apple hardware with https://github.com/mcandre/macos-isos . I'll be publishing my work in progress packer JSON configuration soon from a "macos" branch of my packer-templates.

Closes #5633

@mcandre
Copy link
Author

mcandre commented Dec 9, 2017

I also added proper handling of holding down the A-Z keys, such as for selecting boot options like holding Command+R for Rescue Mode in macOS guests.

Example packer.json demonstrating holding down A-Z keys:

{
  "builders": [
    {
      "type": "vmware-iso",
      "boot_command": [
        "<enter><wait10><wait10><wait10><wait10>",
        "<tab><spacebar><wait10><wait10><wait10>",
        "<leftCtrlOn><leftAltOn>t<leftAltOff><leftCtrlOff><wait10>",
        "echo '<rOn><wait5><rOff>'<enter><wait>",
        "echo '<ROn><wait5><ROff>'<enter>"
      ],
      "boot_wait": "10s",
      "disk_size": 81920,
      "guest_os_type": "ubuntu-64",
      "iso_url": "http://releases.ubuntu.com/16.04/ubuntu-16.04.3-desktop-amd64.iso",
      "iso_checksum_type": "sha256",
      "iso_checksum": "1384ac8f2c2a6479ba2a9cbe90a585618834560c477a699a4a7ebe7b5345ddc1",
      "ssh_username": "vagrant",
      "ssh_password": "vagrant",
      "ssh_wait_timeout": "1800s",
      "shutdown_command": "echo 'vagrant' | sudo -S shutdown -P now",
      "vm_name": "packer-hold-az-test",
      "vmx_data": {
        "memsize": "1024"
      }
    }
  ]
}

@mcandre
Copy link
Author

mcandre commented Dec 10, 2017

Updated PR to add logging for <[a-zA-Z](On|Off)>

@rickard-von-essen
Copy link
Collaborator

Did you look into how macOS is built in https://github.com/timsutton/osx-vm-templates ?

@mcandre
Copy link
Author

mcandre commented Dec 14, 2017

@rickard-von-essen I have been using Tim Sutton's excellent project there as a basis! Actually, I prefer not to build a VM manually and then import that into packer, but rather stretch boot_command as far as possible to fully automate the packing process from scratch.

macOS happens to make heavy use of Super hotkeys, but this PR would actually be helpful for managing other OS's as well :)

@mcandre
Copy link
Author

mcandre commented Dec 16, 2017

Wow, after playing with specifically macOS 10.13 High Sierra guest VMs it is now apparent that VMware Tools can no longer be installed without temporarily disabling SIP. This requires Recovery Mode, which requires sending Command+R during boot, which requires being able to send Super and to hold R in boot_command. Without these keys for entering Recovery mode to disable SIP, the macOS Vagrant box fails to vagrant up during the shared folder capability step.

Example packer configuration:

https://github.com/mcandre/packer-templates/tree/bd89279ea7ba06f3ab6aa17961acb20613d38131/macos

@mwhooker
Copy link
Contributor

mwhooker commented Jan 4, 2018

This seems good. the question I have is if we should add this to the other boot command steps now, or wait for support to be added to those with future PRs. I would like the consistency, but it's not something I would hold this up on

@mwhooker mwhooker added this to the v1.1.4 milestone Jan 4, 2018
@rickard-von-essen
Copy link
Collaborator

@mwhooker someday someone have to take on the boring task of deduplicating the code for the boot_command implementations.

@mcandre
Copy link
Author

mcandre commented Jan 9, 2018

someday someone have to take on the boring task of deduplicating the code for the boot_command implementations.

Yes, a thousand times yes.

@mwhooker mwhooker modified the milestones: v1.1.4, v1.2.0 Jan 26, 2018
Copy link
Contributor

@SwampDragons SwampDragons left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as advertised. thanks.

@SwampDragons SwampDragons merged commit 8ae8f31 into hashicorp:master Feb 2, 2018
@ghost
Copy link

ghost commented Apr 2, 2020

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.

@ghost ghost locked and limited conversation to collaborators Apr 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add <leftCmdOn>, <leftCmdOff> keys for macOS guests
4 participants