On Tuesday, January 7, 2014 4:12:37 AM UTC-6, Klavs Klavsen wrote:
>
> I'm trying to modify certain users, created with by calling the define 
> users::local.
>
> I tried to do it, by calling users::local::modify - but then puppet 
> complains that only subclasses may modify.. :(
>
> What am I doing wrong here?
>


You are attempting to modify a declared resource.  Although there are 
sometimes valid reasons to do so, it is always at least a bit dodgy.  I 
certainly think it's questionable to establish a general-purpose mechanism 
for such, as seems to be the intent here.

As far as the Puppet language goes, the resource override syntax you are 
trying to use may only be used in a subclass of the class that originally 
declared the target resource.  The ability to perform such overrides is the 
signature characteristic of Puppet subclasses, though it is rarely 
highlighted any more.  The concept there is that the subclass refines / 
modulates the meaning of its parent class.

And no, defined types are not classes, and thus cannot be subclassed.

You would use that form of override more like so:

class myusers::alice {
  users::local { 'alice':
    uid => 501,
    gid => 'users',
    realname => 'Alice A. Anderson'
  }
}

class myusers::admin_alice 
    inherits myusers::alice {
  Users::Local['alice'] {
    groups => [ 'admin' ]
  }
}


Note, too, the conceptual distinction here: in the proposed override via a 
defined type, the defined type is named as and serves as a *verb*("modify"), 
whereas in the class-based example the classes represent 
characteristics of the target node: that 'alice' is among the users, or 
more specifically that 'alice' is an administrator.


With all that said, it *is* possible to override a resource declaration 
made by an unrelated class via a resource collector.  That it's possible 
doesn't necessarily make it a good idea, but there are some valid 
applications.  In your specific case, the syntax would look like this:

User<| title == $title |> { groups => $groups }

Do not overuse.


John

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/4aea1c89-de5f-4012-bf25-716124dbcdfe%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to