On Friday, February 6, 2015 at 3:45:30 PM UTC-6, guymatz wrote:
>
> Hello!  Is there a way to set the dependency for a resource that is a 
> subclass?  I have an accounts module, and "within" that is 
> accounts::account which contains declarations to create user, group, etc. . 
> . .  I would like to do something like:
>
> file {'sdfdsf':
>  contents => 'sdkfjdsf',
>  owner    => 'username',
>  *requires Accounts::account['username'] * 
> }
>
> But that doesn't work.  (Error 400 on SERVER: Syntax error at '::account'; 
> expected ']')
>


It doesn't make sense.

   1. If accounts::account is a (sub)*class* then its name is 
   "accounts::account", and no 'username' has anything to do with it.  In that 
   case, a reference to it would be spelled Class['accounts::account'], as 
   Thomas said.
   2. Whether it is a subclass (of another class) or not has nothing to do 
   with it, but anyway, nothing in what you presented is related to whether or 
   not it actually is a subclass.
   3. Except, if the 'username' part is in fact relevant in any way, it can 
   only be because accounts::account is a defined type, not a class at all 
   (sub- or otherwise).  If it is a defined type, then a reference to an 
   instance of it would be spelled "Accounts::Account['username']" (every 
   name segment capitalized).
   
 

>
> I also thought I should be able to say:
>
> file {'sdfdsf':
>  contents => 'sdkfjdsf',
>  owner    => 'username',
>  *requires User['username'] *
> }
>
> since it's really the user resource that's at the heart of the matter, but 
> that didn't work either!  Puppet still complains that it "Could not find 
> dependency User[username]"
>


If Puppet even gets to the point of determining whether it can find the 
dependency, then what you in fact tried was different from what you wrote 
above, as the declaration above misspells the 'require' metaparameter and 
omits the association arrow (=>) between that parameter name and its 
value.  We can help you better when you post the code that you are actually 
using, so cut&paste is your friend.

Anyway, if you use a syntactically correct variation on the above, and 
Puppet complains that it could not find the dependency, then the problem is 
that you did not declare the dependency.  The 'require' metaparameter does 
not (indeed cannot) do that for you.  Puppet doesn't need to have *already* 
processed the declaration of User['username'] (or 
Account::Accounts['username']) when it processes the File declaration, but 
it needs to see such a declaration somewhere among the resources declared 
for the target node before it finishes building the catalog.


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/73a1d4ec-6ad0-481a-b6ab-2381c3308a18%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to