lavabit / robox

The tools needed to robotically create/configure/provision a large number of operating systems, for a variety of hypervisors, using packer.
620 stars 139 forks source link

instructions for how to build hyperv box? #249

Closed TonyApuzzo closed 2 years ago

TonyApuzzo commented 2 years ago

Hi,

Please, I need instructions for box building with hyperv. I haven't been able to figure out how to build hyperv boxes.

I played around with a few different options, noticed that the robox.sh script is WSL aware, so I installed Oracle Linux 7.9 to be the closest thing to RHEL available for WSL on the Microsoft Store and then

sudo yum -y install git
sudo ./res/providers/providers.sh setup
sudo ./res/providers/providers.sh packer
 ./robox.sh box generic-opensuse-hyperv

But it just takes a second and then exits with 0

I tried sudo ./res/providers/providers.sh hyperv but that gives an error since hyperv seems to be special.

What am I missing?

Thank you!

JGillam commented 2 years ago

I'm not an expert on this but I have been running Vagrant boxes with hyperv providers so maybe this will help. I usually run vagrant up from a powershell console when doing this with no problems. Unfortunately it must be running as admin to interact with Hyperv. I'm not sure how running it from within WSL (if even possible) provides any advantages since HyperV will be outside of WSL anyway.

TonyApuzzo commented 2 years ago

I can use the published boxes (although the latest OpenSUSE v4.0.2 box has a broken sshd) but what I can't figure out is how to use packer to build a box from scratch. I have no idea if WSL is needed or not for building, I am just basing that on deduction since all the other hypervisors seem to need linux.

ladar commented 2 years ago

Hi @TonyApuzzo .... @peyton005 is supposed to be working on an update to the README file, so it includes some of the info you need.

The easiest way to build a box from scratch is launch a DOS shell, and assuming the packer.exe is in your search path, Hyper-V is installed correctly, and the permissions are setup, you can run the following:

SET VERSION=1.0.0
packer build -only=generic-opensuse15-hyperv generic-hyperv.json

If you get a permissions error, you can try launching the DOS shell with admin privileges.

With regards to WSL, it is required to use the various bash management scripts in the project repo. Like ./robox.sh links or ./robox.sh cleanup for example. It's also required to use various other scripts, like the box uploaders in res/scripts ... that said, I don't believe you can use ./robox.sh box generic-opensuse15-hyperv to build the box. That's because you need to install the Windows version of Packer on your host, and, at least when I gave it a cursory attempt, I couldn't run that executable from within the WSL environment.

I will also offer congrats on using the providers.sh script correctly, but alas, it only knows how to setup the Linux hypervisors (docker/vmware/virtualbox/libvirt), and does NOT have any logic for Hyper-V or Parallels.

i would welcome a BAT or PS providers script, which automates the setup on Windows.

Finally, you said there was an issue with the OpenSUSE sshd config. Can you elaborate?

ladar commented 2 years ago

I don't use/test the Hyper-V boxes very often, so I depend on the community to let me know if things break. So I did a quick test of the latest OpenSUSE box and it seems to working just fine on Hyper-V.

Microsoft Windows [Version 10.0.17763.2989]
(c) 2018 Microsoft Corporation. All rights reserved.

C:\Users\ladar>cd Desktop

C:\Users\ladar\Desktop>mkdir opensuse

C:\Users\ladar\Desktop>cd opensuse

C:\Users\ladar\Desktop\opensuse>vagrant init generic/oepnsuse15
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

C:\Users\ladar\Desktop\opensuse>vagrant up --provider=hyperv
Bringing machine 'default' up with 'hyperv' provider...
==> default: Verifying Hyper-V is enabled...
==> default: Verifying Hyper-V is accessible...
==> default: Box 'generic/opensuse15' could not be found. Attempting to find and install...
    default: Box Provider: hyperv
    default: Box Version: >= 0
==> default: Loading metadata for box 'generic/opensuse15'
    default: URL: https://vagrantcloud.com/generic/opensuse15
==> default: Adding box 'generic/opensuse15' (v4.1.0) for provider: hyperv
    default: Downloading: https://vagrantcloud.com/generic/boxes/opensuse15/versions/4.1.0/providers/hyperv.box
    default:
    default: Calculating and comparing box checksum...
==> default: Successfully added box 'generic/opensuse15' (v4.1.0) for 'hyperv'!
==> default: Importing a Hyper-V instance
    default: Creating and registering the VM...
    default: Successfully imported VM
    default: Configuring the VM...
    default: Setting VM Enhanced session transport type to disabled/default (VMBus)
==> default: Starting the machine...
==> default: Waiting for the machine to report its IP address...
    default: Timeout: 120 seconds
    default: IP: 10.10.10.224
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 10.10.10.224:22
    default: SSH username: vagrant
    default: SSH auth method: private key
    default:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!

C:\Users\ladar\Desktop\opensuse>vagrant ssh
vagrant@opensuse15:~> cat /etc/os-release
NAME="openSUSE Leap"
VERSION="15.4"
ID="opensuse-leap"
ID_LIKE="suse opensuse"
VERSION_ID="15.4"
PRETTY_NAME="openSUSE Leap 15.4"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:opensuse:leap:15.4"
BUG_REPORT_URL="https://bugs.opensuse.org"
HOME_URL="https://www.opensuse.org/"
DOCUMENTATION_URL="https://en.opensuse.org/Portal:Leap"
LOGO="distributor-logo-Leap"
vagrant@opensuse15:~> cat /etc/vagrant_box_build_time
Wed Jul 13 06:26:09 UTC 2022
vagrant@opensuse15:~> exit
logout
Connection to 10.10.10.224 closed.
Hilljackcantspell commented 2 years ago

Hi,

Please, I need instructions for box building with hyperv. I haven't been able to figure out how to build hyperv boxes.

I played around with a few different options, noticed that the robox.sh script is WSL aware, so I installed Oracle Linux 7.9 to be the closest thing to RHEL available for WSL on the Microsoft Store and then

sudo yum -y install git
sudo ./res/providers/providers.sh setup
sudo ./res/providers/providers.sh packer
 ./robox.sh box generic-opensuse-hyperv

But it just takes a second and then exits with 0

I tried sudo ./res/providers/providers.sh hyperv but that gives an error since hyperv seems to be special.

What am I missing?

Thank you!

Hilljackcantspell commented 2 years ago

static let three : [Float] = [0, 1, 1, 1, 1, 0, //

Hilljackcantspell commented 2 years ago

Training a Neural Network to Recognize Digits

TonyApuzzo commented 2 years ago

The HyperV box for OpenSuse is working again, thank you!