The Puppet Labs Issue Tracker has Moved: https://tickets.puppetlabs.com

This issue tracker is now in read-only archive mode and automatic ticket export has been disabled. Redmine users will need to create a new JIRA account to file tickets using https://tickets.puppetlabs.com. See the following page for information on filing tickets with JIRA:

Bug #1128

interface errors on centos / redhat

Added by Andrew Otto about 8 years ago. Updated about 6 years ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:James Turnbull% Done:

0%

Category:-
Target version:0.24.5
Affected Puppet version: Branch:
Keywords:interface redhat network-scripts sunos Sun ifconfig ifcfg

We've Moved!

Ticket tracking is now hosted in JIRA: https://tickets.puppetlabs.com


Description

I’m trying to use the ‘interface’ type resource for setting up interface aliases. I’m using Puppet version 0.24.2, CentOS 5.

My interface declaration:

node "dev1" {
  interface { "192.168.10.229":
    interface_type => "alias",
    interface => "eth0",
    ensure => "present",
    netmask => "255.255.255.0",
  }
}

puppetd reports the following error:

err: Could not prefetch interface provider 'redhat': undefined method @bootproto=' for #
err: //Node[dev2]/Interface[10.0.1.201]: Failed to retrieve current state of resource: undefined method @[]' for #

I removed the BOOTPROTO line from /etc/sysconfig/network-scripts/icfg-eth0, but then it complains about the HWADDR. If I take out HWADDR (which is probably is not a good idea), it complains about NETWORK. If I take out NETWORK, it complains about GATEWAY. If I take out GATEWAY, it complains about BROADCAST. Finally, I take out BROADCAST, and it complains about ‘[]’.

I’ve even tried removing both my ifcfg-eth0 and ifcfg-lo files to see what puppet does. I get no errors about

"Could not prefetch interface provider 'redhat'... "

but I still get the same

"Failed to retrieve current state of resource: undefined method @[]'..."

at the bottom of the output.

I see that there was a ticket submitted for what looks like a similar problem, but it was marked as fixed back in November 2007: http://reductivelabs.com/trac/puppet/ticket/762

Below is the puppet output and trace for when my ifcfg* files are in place, but with the mentioned properties commented out in ifcfg-eth0.

My current eth0 interface file (with lots of commenting out):

[root@dev1 network-scripts]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
cat /etc/sysconfig/network-scripts/ifcfg-eth0
# Realtek Semiconductor Co., Ltd. RTL-8029(AS)
DEVICE=eth0
ONBOOT=yes
#HWADDR=00:1c:42:af:2b:83
IPADDR=192.168.10.228
NETMASK=255.255.255.0
#NETWORK=192.168.10.0
ONBOOT=yes
#GATEWAY=192.168.10.1
#BROADCAST=192.168.10.255

The output and stacktrace from puppetd —test:

[root@dev1 network-scripts]# puppetd --test --trace
notice: Ignoring cache
info: Caching catalog at /var/puppet/state/localconfig.yaml
notice: Starting catalog run
/usr/lib/ruby/site_ruby/1.8/puppet/provider/interface/redhat.rb:63:in @instances'
/usr/lib/ruby/site_ruby/1.8/puppet/provider/interface/redhat.rb:59:in @collect'
/usr/lib/ruby/site_ruby/1.8/puppet/provider/interface/redhat.rb:59:in @instances'
/usr/lib/ruby/site_ruby/1.8/puppet/provider/interface/redhat.rb:112:in @prefetch'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction.rb:492:in @prefetch'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction.rb:489:in @each'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction.rb:489:in @prefetch'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction.rb:504:in @prepare'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction.rb:301:in @evaluate'
/usr/lib/ruby/site_ruby/1.8/puppet/node/catalog.rb:102:in @apply'
/usr/lib/ruby/site_ruby/1.8/puppet/network/client/master.rb:260:in @run'
/usr/lib/ruby/site_ruby/1.8/puppet/util.rb:212:in @benchmark'
/usr/lib/ruby/1.8/benchmark.rb:293:in @measure'
/usr/lib/ruby/1.8/benchmark.rb:307:in @realtime'
/usr/lib/ruby/site_ruby/1.8/puppet/util.rb:211:in @benchmark'
/usr/lib/ruby/site_ruby/1.8/puppet/network/client/master.rb:259:in @run'
/usr/lib/ruby/1.8/sync.rb:229:in @synchronize'
/usr/lib/ruby/site_ruby/1.8/puppet/network/client/master.rb:241:in @run'
/usr/sbin/puppetd:429
err: Could not prefetch interface provider 'redhat': undefined method @[]' for #
info: /Schedule[weekly]: Evaluated in 0.00 seconds
info: /Schedule[puppet]: Evaluated in 0.00 seconds
/usr/lib/ruby/site_ruby/1.8/puppet/provider.rb:359:in @name'
/usr/lib/ruby/site_ruby/1.8/puppet/provider/interface/redhat.rb:154:in @file_path'
/usr/lib/ruby/site_ruby/1.8/puppet/provider/interface/redhat.rb:135:in @exists?'
/usr/lib/ruby/site_ruby/1.8/puppet/property.rb:517:in @retrieve'
/usr/lib/ruby/site_ruby/1.8/puppet/metatype/evaluation.rb:103:in @currentpropvalues'
/usr/lib/ruby/site_ruby/1.8/puppet/external/gratr/search.rb:325:in @inject'
/usr/lib/ruby/site_ruby/1.8/puppet/metatype/evaluation.rb:101:in @each'
/usr/lib/ruby/site_ruby/1.8/puppet/metatype/evaluation.rb:101:in @inject'
/usr/lib/ruby/site_ruby/1.8/puppet/metatype/evaluation.rb:101:in @currentpropvalues'
/usr/lib/ruby/site_ruby/1.8/puppet/metatype/evaluation.rb:94:in @retrieve'
/usr/lib/ruby/site_ruby/1.8/puppet/metatype/evaluation.rb:23:in @evaluate'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction.rb:60:in @apply'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction.rb:240:in @eval_resource'
/usr/lib/ruby/site_ruby/1.8/puppet/util.rb:444:in @thinmark'
/usr/lib/ruby/1.8/benchmark.rb:293:in @measure'
/usr/lib/ruby/1.8/benchmark.rb:307:in @realtime'
/usr/lib/ruby/site_ruby/1.8/puppet/util.rb:443:in @thinmark'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction.rb:239:in @eval_resource'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction.rb:311:in @evaluate'
/usr/lib/ruby/site_ruby/1.8/puppet/util.rb:444:in @thinmark'
/usr/lib/ruby/1.8/benchmark.rb:293:in @measure'
/usr/lib/ruby/1.8/benchmark.rb:307:in @realtime'
/usr/lib/ruby/site_ruby/1.8/puppet/util.rb:443:in @thinmark'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction.rb:310:in @evaluate'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction.rb:304:in @collect'
/usr/lib/ruby/site_ruby/1.8/puppet/transaction.rb:304:in @evaluate'
/usr/lib/ruby/site_ruby/1.8/puppet/node/catalog.rb:102:in @apply'
/usr/lib/ruby/site_ruby/1.8/puppet/network/client/master.rb:260:in @run'
/usr/lib/ruby/site_ruby/1.8/puppet/util.rb:212:in @benchmark'
/usr/lib/ruby/1.8/benchmark.rb:293:in @measure'
/usr/lib/ruby/1.8/benchmark.rb:307:in @realtime'
/usr/lib/ruby/site_ruby/1.8/puppet/util.rb:211:in @benchmark'
/usr/lib/ruby/site_ruby/1.8/puppet/network/client/master.rb:259:in @run'
/usr/lib/ruby/1.8/sync.rb:229:in @synchronize'
/usr/lib/ruby/site_ruby/1.8/puppet/network/client/master.rb:241:in @run'
/usr/sbin/puppetd:429
err: //Node[dev1]/Interface[192.168.10.229]: Failed to retrieve current state of resource: undefined method @[]' for #
info: //Node[dev1]/Interface[192.168.10.229]: Evaluated in 0.01 seconds
info: /Schedule[monthly]: Evaluated in 0.00 seconds
info: /Schedule[hourly]: Evaluated in 0.00 seconds
info: /Schedule[never]: Evaluated in 0.00 seconds
info: /Schedule[daily]: Evaluated in 0.00 seconds
info: /Filebucket[puppet]: Evaluated in 0.00 seconds
Changes:
Resources:
          Failed: 1
       Scheduled: 8
           Total: 10
Time:
  Config retrieval: 0.84
      Filebucket: 0.00
       Interface: 0.01
        Schedule: 0.00
           Total: 0.85
info: Sent transaction report in 0.11 seconds
notice: Finished catalog run in 0.38 seconds

Related issues

Related to Puppet - Feature #3153: Network interface type Accepted 02/05/2010

History

#1 Updated by Andrew Otto about 8 years ago

Edit: I accidentally copy-pasted the original error message from a different dev machine:

To avoid confusion, the error should read:

err: //Node[dev1]/Interface[192.168.10.229]: Failed to retrieve current state of resource: undefined method @[]' for #

#2 Updated by Redmine Admin almost 8 years ago

  • Status changed from 1 to Accepted

#3 Updated by Luke Kanies almost 8 years ago

Marking #1152 as a duplicate; note that it has code in it that fix some of the problems.

#4 Updated by Luke Kanies almost 8 years ago

  • Target version set to 0.24.5

Something needs to be done about this for 0.24.5.

#5 Updated by James Turnbull almost 8 years ago

I’d love to fix it personally. I’ll take a look.

#6 Updated by James Turnbull almost 8 years ago

jamtur01 wrote:

I’d love to fix it personally. I’ll take a look.

  1. Okay firstly the provider is wrong. The namevar of the interface type (the IP address) is used to retrieve the network script name. It should be the name of the interface. This is in method file_patch.

  2. Secondly the other problem seems to be this method:

     def self.parse(file)
     instance = new()
     instance unless FileTest.exist?(file)
     File.readlines(file).each do |line|
         if line =~ /^(\w+)=(.+)$/
             instance.send($1.downcase + "=", $2)
         end
     end 
     return instance
    

    end

I suspect pre-fetching the entire directory is sucking in bad data.

That’s the extend of my debugging for the moment.

#7 Updated by James Turnbull almost 8 years ago

I don’t see how instance.send can work. Maybe it’s my lack of Ruby-fu but surely parsing a file and getting, for example @network=@, will result in the @network=@ method being called and the value on the other side of the @=@ passed to it. Anyone shed some light here?

#8 Updated by James Turnbull almost 8 years ago

Okay – it’s prefetch. If I comment out the prefetch it works.

#9 Updated by Luke Kanies almost 8 years ago

  • Status changed from Accepted to Ready For Checkin
  • Assignee changed from Puppet Community to James Turnbull

I’ve committed some changes that make the problems with this type clear, but I could not fix them all. The changes are in my tickets/0.24.x/1128 branch.

In particular, the name of interfaces between redhat and solaris nodes is braindead — solaris uses the hostname but redhat uses the ip address, if it’s there, else it uses something else silly.

As a result, I’ve decided to remove the type for now. The last commit in that branch removes all of the interface-related code (in commit be169da98d34f7305019d9e3be2a7da2bcb3e28c). If you want to make this work, just apply that as a reverse patch and hack away. The failing tests aren’t a bad place to start, but a better place to start is to remove everything you don’t understand and only add back when you know you need it.

#10 Updated by James Turnbull almost 8 years ago

  • Status changed from Ready For Checkin to Closed
  • Keywords set to interface redhat network-scripts sunos Sun ifconfig ifcfg

Pushed in commit:be169da98d34f7305019d9e3be2a7da2bcb3e28c in branch 0.24.x.

Also available in: Atom PDF