dresden-weekly / ansible-network-interfaces

Ansible roles to manage Ubuntu network interface configuration
MIT License
86 stars 62 forks source link

Respect iproute2 method for multiple IPs #12

Closed lieutdan13 closed 8 years ago

lieutdan13 commented 8 years ago

According to the Network Configuration for Debian documentation, you can have multiple IPs assigned to the same interface name without using virtual or aliased interface names. The file name for devices is as follows device-{{ item.device }}-{{ item.family | default('inet') }}, which is not unique if you use this method of multiple IPs.

For example:

auto eth0
allow-hotplug eth0
iface eth0 inet static
    address 192.168.1.42
    netmask 255.255.255.0
    gateway 192.168.1.1

iface eth0 inet static
    address 192.168.1.43
    netmask 255.255.255.0

iface eth0 inet static
    address 192.168.1.44
    netmask 255.255.255.0

You could have an optional unique identifier to append to the config filenames. i.e.

network_interfaces:
- id: '42'
  device: eth0
  auto: true
  family: inet
  method: static
  address: 192.168.1.42
  ...
- id: '43'
  device: eth0
  auto: true
  family: inet
  method: static
  address: 192.168.1.43
  ...

then device-{{ item.device }}-{{ item.family | default('inet') }}{{ '-' + item.id if item.id | default('') else '' }} for the file name.

arBmind commented 8 years ago

@lieutdan13 thank you for your ticket. Your are absolutely right. I always used the manual method, which is supported with the addresses array.

It would be cool to support the other option as well. But I don't like the id approach... It feels like we added more than necessary. Ideally we would join all elements into one file. I guess this requires some variable hacking with Ansible.

arBmind commented 8 years ago

implemented.