packer-plugin-hyperv
packer-plugin-hyperv copied to clipboard
Allow multiple nics
Description
For my network project, I need to generate a packer template for a firewall. To pre-configure it correctly, I need two NICs inside the packer template. Currently it is only possible to use one.
I am in the process of extending the hyperv plugin to support multiple nics. Feedback is welcome. Pull request will come.
Use Case(s)
Provisioning hyperv images for servers that require multiple nics, e.g. firewalls, routers, etc.
Potential configuration
I want to add the following block to the configuration:
network_adapter {
name = "Adapter 1" // optional, name of the network card
mac_address = "00dd12ed11dd" // optional, mac address of the network card
enable_mac_spoofing = true // optional, allow the guest os to spoof the mac address for the network card
vlan_id = "1" // optional, vlan id for the network card
switch_name = "wan" // optional, name of the switch
switch_vlan_id = "1" // optional, VLan ID for the switch if generated
}
The old (embedded) settings will still be available to keep compatibility with old configurations. If old and new options are used at the same time a warning will be issued. In this case, old (embedded) options will be inherited to new defined adapters, e.g.
mac_address = "001122334455"
enable_mac_spoofing = true
network_adapter {
name = "wan"
}
network_adapter {
name = "lan"
mac_address = "112233445566"
}
In this case both network adapters will inherit the enable_mac_spoofing value. The mac_address will be inherited to the adapter named "wan" but not to the one named "lan", since it defines mac_address itself.
Instead of inheriting the embedded settings the following behaviours would also be possible (please give feedback):
- stop with an error "Use either the new network_adapter block or the embedded settings"
- issue a warning and ignore the embedded settings
- make the first network adapter from the embedded settings, make additional ones using the network_adapter block.
Potential References
Other plugins also feature the addition of multiple network adapters, e.g. proxmox or amazon.