On May 8, 3:47 pm, Jake - USPS <[email protected]> wrote:
> Should I be able to override a parameter in a define? I've been searching
> the group and found answers both saying you can and can't
>
> CAN:https://groups.google.com/forum/?fromgroups#!searchin/puppet-users/ov...
>
> CANT:https://groups.google.com/forum/?fromgroups#!searchin/puppet-users/ov...
Those two threads look consistent to me, though one of the responses
to the second is wrong. The cases are similar: a class declares an
instance of a defined type, and that defined type instance declares a
resource of a built-in type. It is possible for a subclass to
override the properties of the defined type instance, but not
(directly) the properties of the resources declared by the defined
type.
That showcases the fact that defined type instances are bona fide
resources. People sometimes mistake type definitions to be a Puppet
variation on macros. That kind of thinking leads to all kinds of
wrong expectations, among them that a class should be able to override
properties of resources declared by a defined type instance, as the
OPs in those threads supposed. That does not appear to be what you
are doing.
> So here is what I have ...
>
> Defined in a class:
> class oracle_db {
> etc_sysctl_conf { 'kernel.shmall':
> value => '1',
> }
>
> }
>
> define oracle_db::etc_sysctl_conf ( $attr = $name, $value ) {
> notify{"${attr}:${value}": }
>
> }
>
> Then override with another class:
> class oracle_db::hugepages inherits oracle_db {
> Etc_sysctl_conf['kernel.shmall'] {
> value => '2',
> }
> etc_sysctl_conf { "vm.nr_hugepages":
> value => '3';
> }
>
> }
That should be fine. In addition, however -- and forgive me for
stating the obvious -- you do need to be sure to actually declare the
subclass on the target node.
> And get:
> hostA:~ # puppet agent --test | grep -e shmall -e hugepage
> notice: kernel.shmall:1
> notice:
> /Stage[main]/Oracle_db/Oracle_db::Etc_sysctl_conf[kernel.shmall]/Notify[kernel.shmall:1]/message:
> defined 'message' as 'kernel.shmall:1'
> notice: vm.nr_hugepages:3
> notice:
> /Stage[main]/Oracle_db::Hugepages/Oracle_db::Etc_sysctl_conf[vm.nr_hugepages]/Notify[vm.nr_hugepages:3]/message:
> defined 'message' as 'vm.nr_hugepages:3'
>
> I am using 2.7.9
Puppet should issue a catalog compilation error if one of the classes
for the node attempts to perform a resource property override that is
not permitted. I can't speak to the Notifies in your output, because
they're not represented in the manifest fragments you posted. Also,
although the debug log output by 'puppet agent --test' will indicate,
I think, whether class oracle_db::hugepages is included on the node, I
can't tell from the filtered log output above whether it has been.
John
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.