hashicorp / packer-plugin-hyperv

Packer plugin for Hyper-V Builder
https://www.packer.io/docs/builders/hyperv
Mozilla Public License 2.0
19 stars 23 forks source link

Allow multiple nics #86

Open domoran opened 1 year ago

domoran commented 1 year ago

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):

Potential References

Other plugins also feature the addition of multiple network adapters, e.g. proxmox or amazon.

Emanuele94 commented 1 year ago

Hi, is there a way at this day to add multiple nic with Hyper-v Provider ? I can't find anything in the documentatio.