Allow operating systems to report IP address via HTTP
- Dominant language
- Go
- Stars
- 15.8k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
#### Community Note
* Please vote on this issue by adding a 👍 [reaction](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to the original issue to help the community and maintainers prioritize this request
* Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
* If you are interested in working on this issue or have submitted a pull request, please leave a comment
#### Description
Some operating systems don't integrate with hypervisors very well. An example would be Alma Linux (i386) (or any i386 operating system using MUSL) which doesn't support `open-vm-tools` due to incompatibility between `time_t`. Another is NetBSD, which at times doesn't report its IP address. Sometimes there are additional steps for this to work, but that is too complicated and unreliable to do so via boot commands.
Since Packer can expose an HTTP endpoint and we can already download response files, an approach to supporting these operating systems would be for the operating system to do an HTTP POST to the endpoint to report its IP addresses. This is relatively simple considering that the output of `ifconfig` is relatively standard across the UNIX flavored operating systems.
It may be easier for the boot commands to include steps to reboot after installation, login, and then do an HTTP POST with the IPv4 or IPv6 address of the operating system. At that point, Packer behaves as if the hypervisor reported the address. We can run complicated scripts via SSH or Ansible, which is probably much easier to track and monitor than waiting an arbitrary time during boot commands.
#### Use Case(s)
For some reason, the operating system has challenges reporting its IP address via the hypervisor but can be successfully installed using boot commands. If the IP address can be reported via an HTTP POST, we can use Packer to run more complex scripts to address the hypervisor integration.
For these operating systems, the goal is to minimize the boot commands to a minimum since they can be unreliable, but instead use shell scripts and other means to address any issues.
#### Potential configuration
This example assumes that we can install the operating system on vSphere, but due to some reason, it doesn't reliably report its IP address to vSphere. It also assumes that `hostname -I` will return the IP address, but this can be different for each OS. It then performs a POST using an HTTP Token (generated by Packer) and the respective IP address.
```
source "vsphere-iso" "main" {
// omitted for clarity
boot_command = [
// omitted for clarity
"reboot",
"root",
"${var.ssh_password}",
"clear",
# Notify Packer of the IP address
"IP=`hostname -I`",
"curl -d \"token={{ .HTTPTOKEN }}&ip=$IP\" -X POST http://{{ .HTTPIP }}:{{ .HTTPPort }}/"
// omitted for clarity
]
// omitted for clarity
}
```
#### Potential References
Contributor guide
Assessment
This issue has not been assessed yet.