Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Malformed debian interfaces file - duplicated iface lines? #44

Open
nzhook opened this issue Jun 26, 2013 · 5 comments
Open

Malformed debian interfaces file - duplicated iface lines? #44

nzhook opened this issue Jun 26, 2013 · 5 comments
Labels
bug Something isn't working

Comments

@nzhook
Copy link

nzhook commented Jun 26, 2013

We have an issue where the network_config is giving a malformed debian interfaces file when reading the interfaces file.

Ive added some additional debugging into the code and narrowed it down to the code thinking it has seen an interface line twice

 (
        if match = line.match(/^iface\s+(\S+)\s+(\S+)\s+(\S+)/)
...
          raise_malformed if Instance[name] and Instance[name].family
)

However, the line only occurs once in the file but seems to be seen twice.

It also does not happen on a regular basis, running it manually using puppet agent --test seems to work every time, but automated runs will fail.

puppet config:

        network_config { 'lo:park':
                ensure    => 'present',
                family    => 'inet',
                ipaddress => 'x.x.x.x',
                method    => 'static',
                netmask   => '255.255.255.255',
                onboot    => 'true',
        }

        network_config { 'lo:mta':
                ensure    => 'present',
                family    => 'inet',
                ipaddress => 'x.x.x.x',
                method    => 'static',
                netmask   => '255.255.255.255',
                onboot    => 'true',
        }

        network_config { 'lo:inbound':
                ensure    => 'present',
                family    => 'inet',
                ipaddress => 'x.x.x.x',
                method    => 'static',
                netmask   => '255.255.255.255',
                onboot    => 'true',
        }

Note, however that these add fine, and the error is related to the eth0 line which is configured on the server rather than puppet:

iface eth0 inet static
address x.x.x.x
netmask 255.255.255.0
gateway x.x.x.x

As I mentioned this does work some of the time, so the file has been modified to look like this:

# HEADER: This file is is being managed by puppet. Changes to
# HEADER: interfaces that are not being managed by puppet will persist;
# HEADER: however changes to interfaces that are being managed by puppet will
# HEADER: be overwritten. In addition, file order is NOT guaranteed.
# HEADER: Last generated at: Thu Jun 13 10:48:50 +1200 2013


auto eth0 lo:park lo:inbound lo:mta

allow-hotplug lo:park lo:inbound lo:mta

iface eth0 inet static
address x.x.x.x
netmask 255.255.255.0
gateway x.x.x.x

iface lo inet loopback

iface lo:park inet static
address x.x.x.x
netmask 255.255.255.255


iface lo:inbound inet static
address x.x.x.x
netmask 255.255.255.255

iface lo:mta inet static
address x.x.x.x
netmask 255.255.255.255

My extra debugging determined that the line which originally set Instance[name] and Instance[name].family was:
iface eth0 inet static
and the line being processed when the if statement is tripped is:
iface eth0 inet static

@adrienthebo
Copy link
Member

@nzhook sorry for the delay in responding to this, I've been busy and got bad about responding to issues in a timely manner. With respect to this issue, could you clarify what's happening with eth0? I don't quite understand what you mean by "error is related to the eth0 line which is configured on the server rather than puppet". (I think my parser is faulty)

@nzhook
Copy link
Author

nzhook commented Oct 3, 2013

After commenting out the 'check raise_malformed if Instance[name] and Instance[name].family' and running for a while, puppet will continue as normal. However after a while it starts duplicating lines and or stanzas, eg. it will end up doing this to the file:

auto eth0 eth0 eth0 eth0 eth0
iface eth0 inet static
  address x.x.x.x
  netmask 255.255.255.0
  gateway x.x.x.x

iface eth0 inet static
  address x.x.x.x
  netmask 255.255.255.0
  gateway x.x.x.x

iface eth0 inet static
  address x.x.x.x
  netmask 255.255.255.0
  gateway x.x.x.x

iface eth0 inet static
  address x.x.x.x
  netmask 255.255.255.0
  gateway x.x.x.x

iface eth0 inet static
  address x.x.x.x
  netmask 255.255.255.0
  gateway x.x.x.x

iface eth0 inet static
  address x.x.x.x
  netmask 255.255.255.0
  gateway x.x.x.x

So while I initially thought it maybe related to the stanza which was configured manually and not by puppet (which is the answer you were looking for), it looks like the parser is seing the line twice and then duplicates it somehow.

NOTE: The file above does not happen if the line is still enabled, it will just error as described.

@darkpixel
Copy link

I'm running into this too. Here is my interfaces file:

root@kvmtest:~# cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
auto br0
iface br0 inet static
   address 192.168.7.100
   gateway 192.168.7.254
   bridge_ports eth0
   bridge_stp on
   bridge_fd 0
root@kvmtest:~# 

Here is the output of puppet:

root@kvmtest:~# puppet agent --test
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Caching catalog for kvmtest.<snip>.com
Info: Applying configuration version '1436818363'
Error: Could not prefetch network_config provider 'interfaces': Malformed debian interfaces file; cannot instantiate network_config resources
Error: Puppet::Type::Network_config::ProviderInterfaces is in an error state
Error: /Stage[main]/Main/Node[kvmtest.<snip>.com]/Network_config[br0]/ensure: change from absent to present failed: Puppet::Type::Network_config::ProviderInterfaces is in an error state
Notice: Finished catalog run in 3.09 seconds
root@kvmtest:~# 

The interfaces file seems valid to me, and the system boots properly with networking.

@jcharaoui
Copy link

I think the problem is with the parser not recognizing the source /etc/network/interfaces.d/* directive.

@bzed
Copy link

bzed commented May 19, 2016

not sure if @jcharaoui's case is the same the bug reporter is having, but it is definitely an issue we always run into.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants