voxpupuli / puppet-network

Types and providers to manage network interfaces
https://forge.puppet.com/puppet/network
Apache License 2.0
66 stars 108 forks source link

Problem with routes in ubuntu #189

Open amateo opened 7 years ago

amateo commented 7 years ago

Hi,

I'm trying to use this module to configure my network routes. I'm running ubuntu servers (12.04, 14.04 and 16.04). My problem is that although network_route is creating entries in /etc/network/routes the route is not actually added in the system after a restart or manually add.

To solve this, I have add an exec to run /etc/init.d/networking restart but this doesn't work in all ubuntu servers (networking configuration changed since 14.04).

I have also tried to use the /etc/init.d/networking-routes script provided with ifupdown-extra package. The problem in this case is that network_route is adding blank spaces (I guess that spaces for options) at the end of every line so that script didn't parse them.

Would it be possible that network_route implements the actual command to add/remove the route in a running system?

rski commented 7 years ago

It puts extra spaces that make the file unparsable by ifupdown-extra? that sounds bad, can you post an example manifest and resulting networking-routes script?

amateo commented 7 years ago

This is a sample manifests:

network_route {'192.168.1.0/24':
    ensure => 'present',
    network => '192.168.1.0',
    gateway => '155.54.212.126',
    netmask => '255.255.255.0',
    interface => $facts['networking']['primary'],
}

With this manifest, you can see the route file produced in this gist, where you can see spaces at the end of line 6. The problem is that in some ubuntu distributions (I have checked it in 12.04 and 14.04) the /etc/init.d/networking-routes provided with ifupdown-extra package to reload routes has this line:

...
add_global_routes() {
        ret=0
    cat $ROUTEFILE | egrep "^[^#].*any$" | 
    while read network netmask gateway interface ; do
...

and because of the final espaces the routes are ignored. The route file created is valid for the ifupdown script run in the system boot (when the interface is initialized). The problem is with the script provided to reload routes without shutting down interfaces. I have also checked that the script provided with the package for ubuntu 16.04 uses a different grep, so the file produced is compatible.