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

Error getting SSH address: No ip address from HyperV builder #4352

Closed
w9n opened this issue Jan 3, 2017 · 12 comments
Closed

Error getting SSH address: No ip address from HyperV builder #4352

w9n opened this issue Jan 3, 2017 · 12 comments

Comments

@w9n
Copy link

w9n commented Jan 3, 2017

Hello,

im running the following config on a windows host(MINGW32_NT-6.2 1.0.17(0.48/3/2) 2011-04-24 23:39 i686 Msys) with Packer (version: 0.12.2.dev) and receive "[DEBUG] Error getting SSH address: No ip address." in my debug log while the builder dies after 20m waiting for ssh. The VM is manually available via ssh from the host.

Log -> https://gist.github.com/w9n/52d922049682760927f63ecc758fd93a

The Driver gets a valid mac but fails to receive the ip from the vm. Its probably a bug in hyperv.go but i wasn't able to figure it out yet.

after figuring out the ps script, i guess its arch specific, because the vm does not expose its ip to hyper-v manager.

final thought: Script is fine, but its necessary to have Linux Integration Services (rpm only) running in vm to receive ip-address from Get-Vm. Ill stop my arch experiments on hyperv here :/

{
 "variables": {
        "iso_url": "https://mirrors.kernel.org/archlinux/iso/2016.11.01/archlinux-2016.11.01-dual.iso",
        "iso_checksum_url": "https://mirrors.kernel.org/archlinux/iso/2016.11.01/sha1sums.txt",
        "iso_checksum_type": "sha1",
        "ssh_timeout": "20m",
        "country": "US"
    },
   "builders": [
   {
            "type": "hyperv-iso",
            "iso_url": "{{ user `iso_url` }}",
            "iso_checksum_url": "{{ user `iso_checksum_url` }}",
            "iso_checksum_type": "{{ user `iso_checksum_type` }}",
            "http_directory": "srv",
            "boot_wait": "5s",
            "boot_command": [
                "<enter><wait10><wait10><wait10>",
                "/usr/bin/curl -s http://{{ .HTTPIP }}:{{ .HTTPPort }}/enable-ssh.sh | tr -d '\\r' | cat > enable-ssh.sh<enter><wait5>",
                "/usr/bin/bash ./enable-ssh.sh<enter>"
            ],
            "disk_size": 10480,
            "ssh_username": "vagrant",
            "ssh_password": "vagrant",
            "ssh_port": 22,
            "ssh_timeout": "{{ user `ssh_timeout` }}",
        }
   ]
}

enable-ssh.sh

#!/usr/bin/env bash

PASSWORD=$(/usr/bin/openssl passwd -crypt 'vagrant')

echo "==> Enabling SSH"
# Vagrant-specific configuration
/usr/bin/useradd --password ${PASSWORD} --comment 'Vagrant User' --create-home --user-group vagrant
echo 'Defaults env_keep += "SSH_AUTH_SOCK"' > /etc/sudoers.d/10_vagrant
echo 'vagrant ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers.d/10_vagrant
/usr/bin/chmod 0440 /etc/sudoers.d/10_vagrant
/usr/bin/systemctl start sshd.service

@rickard-von-essen
Copy link
Collaborator

rickard-von-essen commented Jan 3, 2017

Please supply the information requested in the issue template:

  • Packer version (packer version)
  • Host platform (uname -a etc.)
  • Debug log output from PACKER_LOG=1 packer build template.json.
    Please paste this in a gist.
  • Include the scripts referenced in boot_command

@w9n
Copy link
Author

w9n commented Jan 3, 2017

updated, sorry for inconvenience

@rmustard
Copy link

rmustard commented Jan 4, 2017

I see the same problem with Windows7 Guest on Hyper-V. (Windows 8 and above work fine).
In Hyper-V Manager there is no IP listed and the process timed out (although it tries to use 127.0.0.1).
Also, using Powershell to query the Network Information of the Hyper-V VMs showed the same thing. No IP.

FYI: After manually doing windows update for Windows7, the guest OS reported it's IP in Windows Manager.

@w9n
Copy link
Author

w9n commented Jan 4, 2017

yes, i guess the windows update installs the guest tools which enable hyperv manager to determine the vms ip, do memory ballooning and all the other good stuff. It would be nice if packer does not depend on these "Integration Services" or at least notices the user of the necessity of them.

@taliesins
Copy link
Collaborator

Hi guys,

What would help to make it more obvious that guest tools are required to be installed on the guest os? This problem is probably builder wide.

The real headaches happen when you are stuck with exotic oses that do not have guest tools. Then you are stuck. They are more common then you think.

I have considered doing crazy stuff like arp pings to guess the ip address associated with the mac. But it would probably not be that reliable, depending on your network configuration.

The other option is to add the ability to specify a static ip. This would be polled until a connection is established. This is the approach Vagrant takes. Being a base box image I would advocate using dhcp with mac reservations, so we would also have to add ability to specify mac address as well.

@w9n
Copy link
Author

w9n commented Jan 5, 2017

@taliesins An optional functionality for static ip and mac for provisioners would be great! I might dig deeper into vagrant soon, but i didnt see any option in hyperv yet that enables this.

Maybe some switch magic with build in dhcp and routing or a little proxy vm with guest tools and a private network to the actual vm could solve that, but i dont know if that is out of scoop :)

@taliesins
Copy link
Collaborator

@w9n I use a PfSense VM for my dhcp, dns, gateway, firewall etc

Great UI. I even run my home router in modem mode and use a PfSense VM as my router.

@w9n
Copy link
Author

w9n commented Jan 6, 2017

@taliesins PfSense is good, but i think if its only purpose would be to dhcp a static ip to the guest vm and ssh proxy for packer, something like alpine or even smaller would be enough. Compatibility with all guest tools is probably the biggest concern.

@rmustard
Copy link

If anyone is looking for a workaround for windows 7, I was able to get a fully automated hyper-v build working by SlipStreaming a Windows 7 ISO with the guest integration update.
https://support.microsoft.com/en-us/kb/3071740
I'm assuming you could run windows updating during OS install, but that seems to take forever or never complete.

@taliesins
Copy link
Collaborator

@w9n can we close this issue and perhaps add a feature request? Maybe one along the lines of specifying mac address and ip address. We would want to do this in multiple builders.

@JoelBCarter
Copy link

@rmustard That's an excellent workaround. Sadly, 6 days later, every one of those links to the Integration Tools that MS supplies is currently broken for me.

@rmustard
Copy link

@JoelBCarter I had similar problems when working on this before. Just now, using chrome, I clicked on the link for "All supported x64-based versions of Windows 7" and in the same browser tab it gave me a broken link page. If I right click and open in a new tab, it sent me to the download page.

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

No branches or pull requests

5 participants