zachfi / puppet-bsd

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

gre interfaces does not appear to work on freebsd 11.1 #109

Closed remkolodder closed 6 years ago

remkolodder commented 6 years ago

Hi,

Using puppet4 it does not seem to work when using gre interfaces;

For example I have this code in my node manifest :

bsd::network::interface { 'gre2': ensure => 'up', description => "Tunnel interface ${hostname} to XXX", parents => [ 'vtnet0' ], raw_values => [ "${tunneladdress_gre2} netmask 255.255.255.252 tunnel ${ipaddresses_v4} ${tunnel_destination_gre2} up" ], }

If the cloned_interfaces= already exists in rc.conf it doesn't do anything. If the gre2 interface is not available there yet, it will get added. The code also creates gre2, but there is no rc.conf information for it, so the interface remains empty..

How can I investigate what is going on and see what I am doing wrong? :-)

Thanks for all your hard work though, I do really appreciate it and I am leveraging it more and more!

zachfi commented 6 years ago

Thanks for the note. If you take that manifest by itself, copy it to a host that you want to apply that to, and run puppet apply -v --debug gre2.pp, that should give enough detail about what is being called for us to dig.

remkolodder commented 6 years ago

Hi,

Thanks.. and being new to this... how does that work?

I took the bsd::interfaces:gre { ... } part and it complaints on the machine that it cannot find that. So I included 'include bsd' in the mini-manifest, but that doesn't work either. also not on the puppet-master where the stuff should be known. Obviously I am not entirely sure that I am doing the right thing.. so if you have some additional pointers.. please :)

remkolodder commented 6 years ago

Oh right I needed a modulepath:

Debug: Creating default schedules Debug: Loaded state in 0.12 seconds Debug: Loaded state in 0.15 seconds Debug: Loaded transaction store file in 0.06 seconds Info: Applying configuration version '1518077097' Debug: /Stage[main]/Main/Bsd::Network::Interface[gre2]/Bsd::Network::Interface::Cloned[gre2]/Shellvar[cloned_interfaces_gre2]/notify: subscribes to Bsd_interface[gre2] Notice: /Stage[main]/Main/Bsd::Network::Interface[gre2]/Bsd::Network::Interface::Cloned[gre2]/Shellvar[cloned_interfaces_gre2]/value: value changed ['lo1 gre0 gre1'] to 'gre2' Info: /Stage[main]/Main/Bsd::Network::Interface[gre2]/Bsd::Network::Interface::Cloned[gre2]/Shellvar[cloned_interfaces_gre2]: Scheduling refresh of Bsd_interface[gre2] Debug: /Stage[main]/Main/Bsd::Network::Interface[gre2]/Bsd::Network::Interface::Cloned[gre2]/Shellvar[cloned_interfaces_gre2]: The container Bsd::Network::Interface::Cloned[gre2] will propagate my refresh event Debug: Prefetching freebsd resources for bsd_interface Debug: Executing: '/sbin/ifconfig -C' Debug: Executing: '/sbin/ifconfig' Debug: Executing: '/usr/sbin/service netif restart gre2' Notice: /Stage[main]/Main/Bsd::Network::Interface[gre2]/Bsd_interface[gre2]: Triggered 'refresh' from 1 events Debug: /Stage[main]/Main/Bsd::Network::Interface[gre2]/Bsd_interface[gre2]: The container Bsd::Network::Interface[gre2] will propagate my refresh event Debug: Bsd::Network::Interface::Cloned[gre2]: The container Bsd::Network::Interface[gre2] will propagate my refresh event Debug: Bsd::Network::Interface[gre2]: The container Class[Main] will propagate my refresh event Debug: Class[Main]: The container Stage[main] will propagate my refresh event Debug: Finishing transaction 17249234480 Debug: Storing state Debug: Stored state in 0.14 seconds Notice: Applied catalog in 1.43 seconds Debug: Applying settings catalog for sections reporting, metrics Debug: Finishing transaction 17255420860

remkolodder commented 6 years ago

That is the output of the debug command for the gre interface. It does a cloned gre2 interface, but it doesn't seem to call anything for writing the config to /etc/rc.conf for gre2 (before the netif restart gre2 part).

zachfi commented 6 years ago

What does the fact cloned_interfaces contain on your system?

zachfi commented 6 years ago

Just to confirm also, are you running the latest tag of this repo?

zachfi commented 6 years ago

https://github.com/xaque208/puppet-bsd/blob/master/manifests/network/interface.pp#L123 https://github.com/xaque208/puppet-bsd/blob/master/manifests/network/interface/cloned.pp#L21

remkolodder commented 6 years ago

yes. I manually adopted the latest version for cloned_interfaces.rb to include the confine part.

remkolodder commented 6 years ago

is this what you are looking for?

facter -p cloned_interfaces

["bridge", "vmnet", "tap", "pflog", "gre", "ipsec", "gif", "tun", "lo", "vlan", "usbus", "wlan"]

zachfi commented 6 years ago

I'm not able to reproduce this issue. I'm running 5.3.3 on 11.1-RELEASE-p4, and with the original manifest that you provided, I get a gre2 interface with my existing cloned_interfaces= appended to include the gre2 interface. Do you have other interfaces that are being cloned? Have you met the dependencies in the metadata.json? I'm wondering if there might be a missing augeas provider in your environment.

Looking at this issue though, I do notice that puppet complains about a dependency that is not actually required, so I'll update the metadata for that.

remkolodder commented 6 years ago

Hi,

I have other interfaces being cloned, gre1, which is not in puppet (yet). What I said, it adds gre2 to the cloned_interfaces line, which is fine. But for some reason it does not add an ifconfig_gre2="" line with the proper configuration. What module is required for that ifconfig line part? I can ofcourse check to see whether I have that or not, but I Do not recall seeing that it is missing ;-)

Cheers, Remko

zachfi commented 6 years ago

Oh, you're right. I misread. I'll run a test again and check the right thing this time. :)

remkolodder commented 6 years ago

no problemo ofcourse :-) I am already happy that you want to share your time by looking into it!

zachfi commented 6 years ago

This is totally a bug in the rc_conf processing not handling the raw_configs and we've not been testing for this. I only ever used the raw_values on OpenBSD, so I've added a test for FreeBSD that points out my errors. I'll come back.

zachfi commented 6 years ago

112 should fix this. Currently, if multiple values are passed to raw_values, the get joined with a space. I'm not sure what to do with the description.

If you are in a position to test that code, I'd appreciate it. It worked for me here, but I'm not actually constructing the tunnel with another box, so you tell me if the config ends up correct.

remkolodder commented 6 years ago

Hi,

I will add it to my configuration and test it :)

I'll get back asap!

remkolodder commented 6 years ago

That did not solve it.. I removed all gre configurations from the host, without removing gre0 (which is an interface that actively use to get the configuration on the machine ;-)). I renamed gre2 to gre1 so that it gets next to gre0.

Notice: /Stage[main]/Main/Node[mx2.jr-hosting.org]/Bsd::Network::Interface[gre1]/Bsd::Network::Interface::Cloned[gre1]/Shellvar[cloned_interfaces_gre1]/value: value changed ['lo1 gre0'] to 'gre1' Info: /Stage[main]/Main/Node[mx2.jr-hosting.org]/Bsd::Network::Interface[gre1]/Bsd::Network::Interface::Cloned[gre1]/Shellvar[cloned_interfaces_gre1]: Scheduling refresh of Bsd_interface[gre1] Notice: /Stage[main]/Main/Node[mx2.jr-hosting.org]/Bsd::Network::Interface[gre1]/Bsd_interface[gre1]: Triggered 'refresh' from 1 events

cloned_interfaces="lo1 gre0 gre1"

but no ifconfig_gre1.. :)

zachfi commented 6 years ago

May I see the debug output for the latest code version please? There is a debug line I'm curious about in the new code.

remkolodder commented 6 years ago

could it be that my shell_config module interferes with the shell_config/shell_var?

remkolodder commented 6 years ago

for the record that is: csail-shell_config

zachfi commented 6 years ago

Maybe, but I'd have to look under the hood to know why. I switched to the augeas providers a few years ago and haven't looked back, as they've been quite stable. If you wouldn't mind testing with the dependencies listed in the metadata that would at least rule it out.

remkolodder commented 6 years ago

OK, let me see what I can do tonight. I See that the augeasproviders_shellvar might replace the shell_config part. Will be experimenting with it since I only use it to toggle /etc/rc.conf values at the moment.

remkolodder commented 6 years ago

So I removed shell_Config and replaced it with shellvar. I managed to get it 1:1. Does not matter for the gre interface though.

Is #112 actually doing writing the rc.conf data ? or is it just modelling it? (I do not understand enough of it to know for sure) :)

zachfi commented 6 years ago

In #112 the to_create_resources method is being extended to include the raw_values data. This data structure matches what is required by the create_resources function. You can see the call here:

https://github.com/xaque208/puppet-bsd/blob/master/manifests/network/interface.pp#L109

The debug output should have the data structure printing out so we know what at least is going on in that function.

remkolodder commented 6 years ago

OK, I will produce the debug output, because it doesn't print anything int he config. The same goes for gif, which I just tested as well :-)

Also one minor nit for the documentation, there is a parents => 'interface', mentioned but it should be parents => [ 'interface' ], instead, it expects either an undef or Array instead of a string (as reported by puppet to me moments ago ;)).

remkolodder commented 6 years ago

OK from the puppetmaster it does something now;

(Which I didn't expect given that the configuration is not send to the host itself. Could that mean that there are missing dependencies or something? I cannot run it from the host itself because I need to point to the modulespath and if I point it to /var/puppet/lib it doesn't contain the bsd module.

Error: Evaluation Error: Error while evaluating a Function Call, Could not find class ::bsd for host at /usr/home/remko/gre2.pp:1:2 on node host

Debug: /Stage[main]/Main/Bsd::Network::Interface[gre2]/Bsd::Network::Interface::Cloned[gre2]/Shellvar[cloned_interfaces_gre2]/notify: subscribes to Bsd_interface[gre2] Notice: /Stage[main]/Main/Bsd::Network::Interface[gre2]/Shellvar[ifconfig_gre2]/value: value changed ['A.A.A.A B.B.B.A netmask 255.255.255.252 tunnel HOST_A HOST_B up'] to '3.3.3.2 3.3.3.1 netmask 255.255.255.252 tunnel 2.2.2.2 1.1.1.1 up' Info: /Stage[main]/Main/Bsd::Network::Interface[gre2]/Shellvar[ifconfig_gre2]: Scheduling refresh of Bsd_interface[gre2] Debug: /Stage[main]/Main/Bsd::Network::Interface[gre2]/Shellvar[ifconfig_gre2]: The container Bsd::Network::Interface[gre2] will propagate my refresh event

remkolodder commented 6 years ago

restarting puppetserver seems to have assisted with this so that it does something now ...

zachfi commented 6 years ago

Oh good, that looks like progress. For my testing, I rsynced my production/ code deploy to the host and copied in the file I changed to verify with puppet apply and some --environmentdir or some thing sprinkled in. I can get specifics when I'm back on my other machine. In any case, that looks right. Is this resolved with the merge of #112 then? If so I'll get that merged now. As mentioned, I'm not sure what to do with the description, as in where in rc.conf to put it, but I think we can solve that after merge.

remkolodder commented 6 years ago

Hi,

Yes it seems to work now, please merge it. I copied your versions verbatim so they are the same and it gets applied now.. (it didn't even on the master before your changes).

We can add that to the interface as well:

ifconfig gif0 description "test interface to"

ifconfig gif0

gif0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> metric 0 mtu 1280 description: test interface to

remkolodder commented 6 years ago

scratch that, it isn't so simple to add it as 'description "description test"', to the raw_values array.

zachfi commented 6 years ago

Thanks for the testing and reporting the issue. #112 has been merged.