On Jan 5, 12:25 pm, Antidot SAS <antidot...@gmail.com> wrote:
> Hi everyone,
>
> I have a quick question for everybody, does the class inheritance work for
> realizing ressource?
>
> Because I have the following class:
> # user_system.pp
> #
> # Realize the system users
>
> class user::user_system inherits user::virtual {
>         # Realize system members
>         Group <| tag == 'user_system' |> -> User <| tag == 'user_system' |>
>
> }
>
> And the class:
> # unixadmins.pp
> #
> # Realize the members of the Unix team and include any contractors
>
> class user::user_sysadmin inherits user::user_system {
>         # Realize our team members
>         Group <| tag == 'user_sysadmin' |> -> User <| tag ==
> 'user_sysadmin' |>
>
> }
>
> each time a node uses the class 'user::user_sysadmin' the realisation of
> the class 'user::user_system' doesn't work, did I misunderstand the class
> inheritance?


I think you understood correctly, to a point.  Given the classes you
specified, if your manifest includes class user::user_sysadmin then I
would expect both Group collections and both User collections to be
realized, with dependencies set up per the chaining operators you
used.  You didn't say how you determined that this was not happening,
and without knowing the contents of class user::virtual I cannot
venture a guess.

HOWEVER, what you have shown is not an appropriate use case for class
inheritance.  Inheritance can get the job done here (or should be able
to do), but it should be reserved for cases where the subclass
overrides properties of a superclass's resources.  Otherwise, it works
as well or better, and is more flexible, to 'include' the erstwhile
parent class instead of inheriting from it:

class user::user_system {
        include 'user::virtual '
        Group <| tag == 'user_system' |> -> User <| tag ==
'user_system' |>
}

class user::user_sysadmin {
        include 'user::user_system'
        Group <| tag == 'user_sysadmin' |> -> User <| tag ==
'user_sysadmin' |>
}

It is possible that rewriting your classes that way will solve the
problem, but I can hardly be confident without understanding the
nature of the problem in the first place.


John

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to