I was having some related issues to Bonded interfaces and VLANs which were
mostly template related, i looked over a server which has a lot of Virtual
devices attached and discovered that Foreman import the networking facts
wrong.
eth1 - a trunk without a native VLAN, MAC: 00:51:52:8f:1d:bc, no IP is
configured, interface is UP
eth1.501 - a Virtual device, attached to eth1, has VLAN, IP configured,
interface is UP, MAC address is automatically inherited from eth1 ("ip -o
link" shows the same MAC)
eth1.502 - a Virtual device, attached to eth1, has VLAN, IP configured,
interface is UP, MAC address is the same…
eth1.50n - …
and about 10 interfaces like this.
What happens is that Foreman creates eth1, eth1.501.501 (attached to
eth1.501 which does not exist), eth1.501.502 (attached to eth1.501),
eth1.501.50n (attached to eth1.501).
All the virtual devices are attached to eth1.501 but they should be
attached to eth1, they all show up with the same MAC address (No problem
here), it manages to attach them to the correct related Subnets as well.
I assume eth1.501 is the first interface foreman go over, and then relates
by MAC address the rest of the Interfaces.
The other issue i was having (which i could fix easily as a workaround) is
related to the "kickstart_networking_setup", I have 2 interfaces, eth2 and
eth3, i created bond1 which those interfaces are attached to, the template
is doing well when creating eth2, eth3 and bond1, the problem starts when i
create a virtual device over bond1.
<%= interface.identifier %> interface
real=ip -o link | grep <%= interface.inheriting_mac -%> | awk '{print $2;}' | sed s/:$//
<% if virtual -%>
real=echo <%= interface.identifier -%> | sed s/<%= interface.attached_to -%>/$real/
<% end -%>
As example, i created bond1.502, attached to bond1, If i don't define a MAC
address for bond1 (which is not needed as it's not a provisioning
interface), i get the following:
bond1.502 interface
real=ip -o link | grep | awk '{print $2;}' | sed s/:$//
real=echo bond1.502 | sed s/bond1/$real/
The results is $real being ".502"
If i do add a MAC address to bond1 (which is eth2's MAC), the result is
"eth2.502".
I changed the template to check if it attached_to is a a bond or not
<% bond_interfaces = [] -%>
<% @host.bond_interfaces.each do |bond| %>
<% bond_interfaces.push(bond.identifier) -%>
<% end -%>
<%= interface.identifier %> interface
<% if !bond_interfaces.include?(interface.attached_to) -%>
real=ip -o link | grep <%= interface.inheriting_mac -%> | awk '{print $2;}' | sed s/:$//
<% if virtual -%>
real=echo <%= interface.identifier -%> | sed s/<%= interface.attached_to -%>/$real/
<% end -%>
<% else -%>
real=<%= interface.identifier %>
<% end -%>