-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I think that the issue is that the define isn't actually scoped under
the class, so the inherit doesn't pick up that the file is actually
under that class at all.  Does that make sense?

Try writing the same statement but move the defines outside of the
classes and I think you'll see exactly what I'm talking about.

Basically, you can't inherit defines (I think) because they actually
aren't derived from the Puppet Class object.

I.e. a Node is a subset of a Class, but a Define isn't.

Trevor

On 01/08/2010 03:50 PM, John T. Guthrie wrote:
> Hello all,
> 
> First, I would like to thank you for your suggestion about an 'if/case'
> statement.  I think that should do what I want.  However, I would think
> that even if defines are scoped separately from classes, that wouldn't
> necessarily apply in the case that I outlined below since I used a
> different define name in the subclass as opposed to the name for the
> define in the parent class.  I was trying to get a resource override
> into a define.  Is that not possible; i.e., can defines only handle
> resource definitions, but not overrides?
> 
> Thanks.
> 
> John Guthrie
> 
> On 01/08/2010 03:29 PM, Trevor Vaughan wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> So, I believe (someone please correct me if I'm wrong) that defines are
>> actually separately scoped from the classes that contain them and cannot
>> currently be overridden.
>>
>> The nesting that you have below is merely a convenience for writing:
>>
>> define test::myfile () { ... }
>>
>> I would suggest either using a template or an inline 'if/case' statement
>> to apply the logic you require.
>>
>> Trevor
>>
>> On 01/08/2010 03:06 PM, John T. Guthrie wrote:
>>   
>>> Hello all,
>>>
>>> Suppose you have a resource that is created with a define such as the
>>> following:
>>>
>>> class test {
>>>      define myfile () {
>>>          file {
>>>              "/tmp/$name":
>>>                  content =>  generate("/bin/echo","$name");
>>>          }
>>>      }
>>>
>>>      myfile {
>>>          "foo":
>>>      }
>>> }
>>>
>>> And it turns out that I want to create a subclass that overrides a
>>> property of "/tmp/foo", how would I go about doing that?  When I try to
>>> add the following subclass:
>>>
>>> class test::override inherits test {
>>>      define myfileover () {
>>>          File["/tmp/$name"] {
>>>              content =>  generate("/bin/echo","$name","$name")
>>>          }
>>>      }
>>>
>>>      myfileover {
>>>          "blah":
>>>      }
>>> }
>>>
>>> I get the following error:
>>>
>>> Could not retrieve catalog: Only subclasses can override parameters at
>>> /etc/puppet/network/prod/modules/test/manifests/init.pp:20 on node
>>> xxxx.  Does anyone have any suggestions?
>>>
>>> Thanks.
>>>
>>> John Guthrie
> 

- -- 
Trevor Vaughan
 Vice President, Onyx Point, Inc.
 email: tvaug...@onyxpoint.com
 phone: 410-541-ONYX (6699)

- -- This account not approved for unencrypted sensitive information --
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAktHnOUACgkQyWMIJmxwHpR/ZACbB3V9Sduw6jAiJb0P4CJkhviF
chAAoIfKFoH3PTU+cmFyltdWdC9xpodR
=5j7s
-----END PGP SIGNATURE-----
-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-us...@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