On Wednesday, January 14, 2015 at 8:08:25 PM UTC-6, Felix.Frank wrote:
>
> On 01/14/2015 03:47 PM, Jason Wever wrote: 
> > Hi All, 
> > 
> > I having a problem in where I'm defining a File Type and setting the 
> > requires parameter to use a variable name (e.g. requires => $foo). 
> > However, when I do this, the Puppet run doesn't act like it's 
> > translating the variable into what it should be set to.  $foo should 
> > resolve to either Class['a'] or Class['b'] depending on a particular 
> > fact, but the File Type is being processed by Puppet before Class['a'] 
> > or Class['b'] has been processed. 
> > 
> > Is it possible to use a variable as the value for the requires 
> > parameter in a File Type? 
> > 
> > I've tried this with Puppet versions 3.5.1 and 3.6.1 but no change in 
> > behavior.  Haven't tried a 3.7.x. 
> > 
> > Thanks, 
>
> Hi, 
>
> this is not an ordering issue. 
>


Perhaps not.

 

>
> $foo = 'Class["a"]' 
>
> The above string is not blessed into a class reference when used as the 
> value for an ensure parameter (apparently). Not quoting it makes no 
> difference. 
>
>

Are you sure that quoting vs. not quoting doesn't make a difference?  At 
least with the future parser, the unquoted version ought to be a bona fide 
class reference in any context, and I didn't think that was new.  Or are 
you suggesting that the reference gets stringified upon assignment to a 
variable?  I've never done much along these lines, but that sounds 
surprising and a bit inconsistent to me.

Or what about this:

$foo = [ Class['a'] ]

In any case, if $foo does not resolve to a class or resource reference, 
then why does catalog building succeed?  (Or perhaps the problem actually 
manifests as catalog building failure....)

 

> This should work: 
>
> $foo = "a" 
>
> File["/path/to/file"] { require => Class[$foo] } 
>
>

Yes, that should certainly work (provided that Class['a'] is declared for 
the node).  Depending on the availability of $foo, that approach might also 
be taken in the original File declaration instead of being performed as an 
override.  In fact, if it cannot be performed in the initial declaration, 
then it would be better to use the appropriate chain operator, to avoid the 
possibility of overriding other relationships set via 'require':

Class[$foo] -> File['/path/to/file']


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/a5de7851-1369-43e1-a7dc-d21ddc46ab6f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to