What I actually would like it to create a kind of dependency.

I would like that a parameter X of any instance of  type 'b' *depends* on 
the path param of the 'a' resource instance namely passed as a parameter.

file {'test' :
>  ensure => present,
>  name => 'test.txt',
>  *within* => dir,
> }
>
> file {'dir' :
>  ensure => directory,
>  name => 'dir',
>  path => '/tmp'
> }
>

This is not the best example since file does not work this way but its the 
closest one to what I would like.

Imagine file was a custom type, so I know in the *within *param I am 
expecting a File[] resource insance. I'd like to know if there is any way I 
can get the parameters of this resource instance (dir)? (Something like 
extrapolating it, or accessing it through catalog)

In the previous case File['test'] will end up being located at 
'/tmp/text.txt', appending dir.path + test.name, without specifying the 
path in File['test'] but just the directory it depends on.

I hope I could explain myself a bit better,




On Tuesday, June 26, 2012 9:40:32 PM UTC+2, jcbollinger wrote:
>
>
>
> On Tuesday, June 26, 2012 6:07:41 AM UTC-5, Yanis Guenane wrote:
>>
>> Hey guys,
>>
>> I was wondering if it was possible to access type params within another 
>> type.
>>
>> Here is an example of what I would like to do.
>>
>> Puppet::Type.newtype(:a) do
>>>
>>      newparam(:name) do
>>>       isnamevar
>>>      end
>>>
>>       newparam(:path) do
>>>       end
>>> end
>>>
>>
>> Puppet::Type.newtype(:b) do
>>>
>>    newparam(:name) do
>>>     isnamevar
>>>    end 
>>>
>>    newparam(:needs) do
>>>   
>>>    /* I want to access path param from 'a' type here 
>>
>>       something like resource[:needs].path */
>>>
>>
>>>    end
>>> end
>>>
>>
>> And the manifest calling that would be 
>>
>>  a {'test-a' :
>>> path => '/usr',
>>> }
>>>
>>>  b {'test-b' :
>>> needs => a
>>> }
>>>  
>>>
>>
>>
>> Is it possible ? 
>>
>
>
> What is the example supposed to mean?  It doesn't make sense.  As a best 
> guess, what you actually want to do is access the parameter values of a 
> resource *instance*, not (as you wrote) the parameter[ definition]s of a 
> resource *type*.  It might be possible to do that (involving somewhat 
> different manifest syntax), but it would be decidedly non-idiomatic.
>
> Why do you want this?  Your example is too abstract to tell me much.
>
>
> John
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/puppet-users/-/D25xHdkiLnMJ.
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.

Reply via email to