hashicorp / packer-plugin-vsphere

Packer plugin for VMware vSphere Builder
https://www.packer.io/docs/builders/vsphere
Mozilla Public License 2.0
100 stars 95 forks source link

Unable to use `http_ip` when running in a container #474

Closed AndrewSav closed 1 month ago

AndrewSav commented 1 month ago

Reposting from https://discuss.hashicorp.com/t/1-4-0-breaks-my-workflow/70407since no answer.

Overview of the Issue

There were changes in 1.4.0 that introduced http_interface and http_bind_address. I’m running packer in a container and using vsphere_iso. I use http_ip so that vSphere can talk back to packer. This IP is not available inside the container and is not the bind IP. It’s the IP of the VM the container is running on. This was working before, on 1.3.0

In 1.4.0 I’m getting:

error using IP address 192.168.6.10: 192.168.6.10 is not assigned to an interface

I do not want packer to use this address for binding, so the fact that it is not assigned to an interface is irrelevant. How do I fix my configuration to work with 1.4.0 as it used with 1.3.0?

Reproduction Steps

Run packer inside a container. Use http_ip setting and provide the IP of the host.

Packer Version

1.11.2

Plugin Version and Builders

1.4.0

Please select the builder.

VMware vSphere Version

7.0.3.01900

Guest Operating System

Simplified Packer Buildfile

N/A - all builds using http_ip are failing

Operating System and Environment Details

Run inside a container produced with this Dockerfile:

FROM jetbrains/teamcity-agent:2024.07.1

USER root

RUN bash -c "curl -sSLO https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb" && \
    dpkg -i packages-microsoft-prod.deb && \
    apt-get update && apt-get install -y dotnet-sdk-7.0 dotnet-sdk-8.0 powershell jq

RUN bash -c "curl -fsSL https://apt.releases.hashicorp.com/gpg | apt-key add -" && \
    apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" && \
    apt-get update && apt-get install -y packer

RUN pwsh -Command 'Set-PSRepository -Name PSGallery -InstallationPolicy Trusted'
RUN pwsh -Command 'Install-Module -Name VMware.PowerCLI -scope AllUsers'
RUN pwsh -Command 'Set-PowerCLIConfiguration -Scope AllUsers -ParticipateInCEIP $false -Confirm:$false'
RUN pwsh -Command 'Set-PowerCLIConfiguration -Scope AllUsers -InvalidCertificateAction Ignore -Confirm:$false'
RUN pwsh -Command 'Set-PowerCLIConfiguration -Scope AllUsers -DefaultVIServerMode Single -Confirm:$false'

USER buildagent

Log Fragments and crash.log Files

It is difficult to get this log from the environment, and it appears that the cause of the issue is the recent changes. Let me know if you still want me to try and get the logs.

tenthirtyam commented 1 month ago

In #431 the following was added:

Adds support for http_interface and http_bind_interface from the SDK.

  • The options http_bind_address and http_interface are mutually exclusive, per the SDK.
  • Both http_bind_address and http_interface have higher priority than http_ip.
  • The http_bind_address is matched against the IP addresses of the host's network interfaces. If no match is found, the plugin will terminate.
  • Similarly, http_interface is compared with the host's network interfaces. If there's no corresponding network interface, the plugin will also terminate.
  • If neither http_bind_address, http_interface, and http_ip are provided, the plugin will automatically find and use the IP address of the first non-loopback interface for http_ip.
  • If http_ip is provided and the IP address does not exist on any interface, the build will exit.

For now, use v1.3.0 and I'll take a look at resolving this for v1.4.1 or a subsequent patch release whilst I have availability. Essentially, the error handling may simply need to log this as a warning instead of an error and exit.

Ryan

AndrewSav commented 1 month ago

Thank you, it's working again!