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

Bug #13537

Overriding class parameters doesn't actually pass new parameters.

Added by Marek Kroemeke over 2 years ago. Updated almost 2 years ago.

Status:DuplicateStart date:03/30/2012
Priority:NormalDue date:
Assignee:Nigel Kersten% Done:

0%

Category:-
Target version:-
Affected Puppet version: Branch:
Keywords:

We've Moved!

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

This issue is currently not available for export. If you are experiencing the issue described below, please file a new ticket in JIRA. Once a new ticket has been created, please add a link to it that points back to this Redmine ticket.


Description

Hello,

OS: RHEL 5.8, RHEL 5.7 Puppet: 2.7.11, 2.7.12*

I’m not 100% certain if this a design decision or simply a bug – but because puppet doesn’t complain about the syntax I suspect this is a bug.

 class nodetype::foo {
  class { network:
    default_gateway => '172.23.1.1',
    routes => {
      multicast   => {
        comment => 'multicast over eth0',
        address => '224.0.0.0',
        netmask => '240.0.0.0',
      },
    }
  }
}

class nodetype::foo::egg inherits nodetype::foo {
  Class["network"] {
    default_gateway => '172.23.1.2',
  }
}

This does not work – i.e. parameter passes is still 172.23.1.1.

Best regards, Marek

  • daysman@#puppet

inherit-param-class.pp (456 Bytes) Anonymous, 04/05/2012 12:36 pm

History

#1 Updated by Anonymous over 2 years ago

  • File inherit-param-class.pp added
  • Status changed from Unreviewed to Needs Decision
  • Assignee set to Nigel Kersten

It seems that the documented feature of class inheritance (see http://docs.puppetlabs.com/guides/language_guide.html#resource-collections) works for basic resource types, but fails for parameterized classes. The attatched manifest shows this problem. The Notify inside “foo” has a different message because of bar inheriting and overriding the message parameter, but the same thing doesn’t seem to work for overriding the parameter to the parameterized class “params” used by “foo”.

Marek, what you are trying to do would probably be better achieved by making nodetype::foo parameterized instead of trying to use inheritance and overriding resource settings.

#2 Updated by Nigel Kersten over 2 years ago

  • Status changed from Needs Decision to Needs More Information

That’s my suspicion too.

In many ways class inheritance was there to fill in some of the gaps that parameterized classes provided later.

Before we prioritized this, I’d like to see some more details from users on where class inheritance for parameterized classes provides functionality that can’t be more easily provided using parameterized classes directly.

#3 Updated by Dustin Mitchell about 2 years ago

Reduced test case:

class takes_param($param=purple) {
        notify {
                "param is $param": ;
        }   
}   

class parent {
        class {
                'takes_param':
                        param => true;
        }   
}   

class child inherits parent {
        Class['takes_param'] { param => false }
}   

include child

This is useful to me because my toplevel classes need to be something I could specify from an ENC, which means only node-scope variables (yuck) and class names.

#4 Updated by Dustin Mitchell about 2 years ago

At the very least, this should give an error, rather than just ignoring the arguments to Class[‘takes_param’]. In fact, you can pass whatever you want — { foo => bar } — without error.

#5 Updated by Paul Canham almost 2 years ago

This looks like a duplicate of 5517

#6 Updated by Dustin Mitchell almost 2 years ago

  • Status changed from Needs More Information to Duplicate

Also available in: Atom PDF