Overriding inheritance variables. How to make a redefinition of variable inheritance class?

23 views
Skip to first unread message

Олег Сиденко

unread,
Oct 5, 2014, 12:01:48 PM10/5/14
to puppe...@googlegroups.com
I want to write the following structure: 

class CLASSA {
$ = "AAA" 
notify {$:} 
class ClassB inherits CLASSA {
$ = "BBB" 



Summoning of nodes 
class {ClassB:} 

expect to see a BBB notifah but Puppet hard shoves 
Note: AAA 
Note: / Stage [main] / Classa / Notify [AAA] / message: defined by 'message' as 'AAA' 


What am I doing wrong?

Felix Frank

unread,
Oct 5, 2014, 3:30:33 PM10/5/14
to puppe...@googlegroups.com
Hi,

this type of question would be better suited for the puppet-users list.

The problem is that variable values *cannot* be overridden. You just
replace its value in the scope of the inheriting class. Only resources
can be overridden, so that is what you must do.

class generic {
$message = 'generic'
notify { 'test': message = $message }
}

class specific inherits generic {
$message = 'specific'
Notify['test'] { message => $message } # <- override
}

Replacing the variable locally is fairly pointless.

class specific inherits generic {
Notify['test'] { message => 'specific' } # <- exact same result
}

HTH,
Felix

Олег Сиденко

unread,
Oct 6, 2014, 6:33:14 AM10/6/14
to puppe...@googlegroups.com
Thank you very much!

воскресенье, 5 октября 2014 г., 23:30:33 UTC+4 пользователь Felix Frank написал:
Reply all
Reply to author
Forward
0 new messages