michaelrigart / ansible-role-interfaces

An ansible role for configuring different network interfaces
GNU General Public License v3.0
83 stars 61 forks source link

Create a manual or non-IP interface? #96

Open sjwk opened 3 years ago

sjwk commented 3 years ago

Is there a recommended way to create an interface with neither static nor DHCP address? In my use case, I want to create a bonded parent interface, which won't have any IP address of its own, but act purely as a parent to multiple VLAN interfaces, which will have their own addresses.

On a [Debian] host that is already set up this way, the parent interface is simply configured as:

iface bond1 inet manual bond-mode 802.3ad bond-slaves enp1s0f2 enp1s0f3

If I set bootproto to static but don't give it any address, the role completes but fails to bring the interface up due to missing address. If I set bootproto to static and set the address to 0.0.0.0 it works (although it's probably not a good config) but the 'Check active bond interface state' handler fails.

Thanks!

purplesrl commented 3 years ago

bootproto manual does not seem supported, it should be, i need it for tap0 (i set some routes when i connect to the vpn)

for me adding:

{% if item.bootproto == 'manual' %}
{{ item.allowclass | default('auto') }} {{ item.device }}
iface {{ item.device }} inet manual
{% endif %}

To ethernet_Debian.j2 worked, of course this is just a workaround.

markgoddard commented 3 years ago

Looking at man interfaces, what you are describing is the 'method' in Debian/Ubuntu. The bootproto terminology I think comes from CentOS/RHEL.

Currently for Debian/Ubuntu we support static or dhcp methods, but others are supported, including manual. Perhaps the simplest option would be to set the method to manual if item.bootproto is static, but no IP address is configured?

sjwk commented 3 years ago

Currently for Debian/Ubuntu we support static or dhcp methods, but others are supported, including manual. Perhaps the simplest option would be to set the method to manual if item.bootproto is static, but no IP address is configured?

That sounds like it would work.