zachfi / puppet-bsd

A Puppet module for BSD
Apache License 2.0
9 stars 11 forks source link

FreeBSD VLAN support appears to be broken #59

Closed Thracky closed 9 years ago

Thracky commented 9 years ago

Currently the vlan support for FreeBSD appears to be broken when going to instantiate the standard interface class for two reasons.

1. How the values array is treated.

In lib/puppet/parser/functions/get_freebsd_rc_conf_shellconfig.rb line 12:

 c[:address] = config["values"] if config["values"]

And in lib/puppet_x/bsd/rc_conf.rb the address array is explicitly treated as an array of addresses and process_addresses() is called on each of the array items, which includes vlan id and vlandev values.

This results in the following error:

Error: addr is vlan 1 of class String: Invalid IP "vlan 1" at /etc/puppet/modules/bsd/manifests/network/interface.pp:93 on node xxxxxxxxx
/var/lib/puppet/lib/puppet_x/bsd/rc_conf.rb:189:in `rescue in block in process_addresses'
/var/lib/puppet/lib/puppet_x/bsd/rc_conf.rb:174:in `block in process_addresses'
/var/lib/puppet/lib/puppet_x/bsd/rc_conf.rb:170:in `each'
/var/lib/puppet/lib/puppet_x/bsd/rc_conf.rb:170:in `process_addresses'
/var/lib/puppet/lib/puppet_x/bsd/rc_conf.rb:127:in `load_hash'
/var/lib/puppet/lib/puppet_x/bsd/rc_conf.rb:16:in `initialize'
/etc/puppet/modules/bsd/lib/puppet/parser/functions/get_freebsd_rc_conf_shellconfig.rb:15:in `new'

A potential solution is to pass $vlan_values to options and $address to values in vlan.pp.

2. No cloned_interfaces in rc.conf

In order for the VLAN interface to function, there needs to be a cloned_interfaces line in rc.conf as per http://people.freebsd.org/~arved/vlan/vlan_en.html

For example:

cloned_interfaces="vlan101"
ifconfig_vlan101="inet 10.0.5.1/24 vlan 1 vlandev em0"

I imagine at least the first issue may affect other interface types, but I have not tested any of them yet.

zachfi commented 9 years ago

May I see the manifest that you are using? If you are trying to go in through bsd::network::interface, than I think I'm expecting this. If you are using bsd::network::interface::vlan, the values passed to the bsd::network::interface class should already be 'processed' and formatted correctly.

Thracky commented 9 years ago

Here's how I was attempting to create VLAN interfaces:

        class { 'bsd::network':
          v4forwarding      => true,
        }

        bsd::network::interface { 'em0':
          description => 'Primary Interface',
          values      => [ '10.0.0.1/24' ],
        }

        bsd::network::interface::vlan { 'vlan101':
          id => '101',
          device => 'em0',
          address => '10.0.101.1/24',
        }

        bsd::network::interface::vlan { 'vlan102':
          id => '102',
          device => 'em0',
          address => '10.0.102.1/24',
        }
zachfi commented 9 years ago

Yep, that manifest is the expected approach. I'll try to give some evening time this week to get a test this out. I've been neglecting tests for FreeBSD and plan to rectify this soon once I get my test lab online.

zachfi commented 9 years ago

https://github.com/xaque208/puppet-bsd/pull/63

This should be in a better state now, though I need to add a test to make sure I've not broken OpenBSD in the process. I'll come back.

In the meantime, if you'd like to test this out, I'd appreciate it. I've also modified the interface refreshing so when the values in rc.conf change, the interface is restarted. I'd like feedback on this approach if you have it.

I'm not yet handling cloned interfaces, and I'm not quite sure how to model that in Puppet.

zachfi commented 9 years ago

63 has been merged. 0.2.7 has been cut for this.

Thracky commented 9 years ago

Much appreciated Zach. I'll be testing it out in the next couple days.

Regarding the cloned interfaces, for my hacked together solution I just added another variable in the network class that takes an array of interface names then added a shell_config item for adding it into rc.conf. Maybe it's not the most elegant solution but it works for the time being.

zachfi commented 9 years ago

@Thracky How'd the testing go? I'll close this out if its working for you.

Thracky commented 9 years ago

Everything worked great. The cloned_interfaces still had to be done separately but the actual interface configuration worked flawlessly otherwise.

Thanks again!