# Definition question

**URL:** <https://discourse.chef.io/t/definition-question/5068>\
**Category:** Chef Infra (archive)\
**Created:** [February 25, 2014, 11:01pm UTC](https://discourse.chef.io/t/definition-question/5068 "2014-02-25T23:01:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bytheway](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/bytheway/32/123_2.png) [@bytheway](https://discourse.chef.io/u/bytheway)\
**Post date:** [February 25, 2014, 11:01pm UTC](https://discourse.chef.io/t/definition-question/5068/1 "2014-02-25T23:01:41Z")

</div>

In the documentation for definitions (  
[http://docs.opscode.com/essentials\_cookbook\_definitions.html](http://docs.opscode.com/essentials_cookbook_definitions.html)), I notice it  
says:

“resource notifications will not work normally when the resource to be  
notified is located in a definition”

I was curious why this is the case, since it looked to me by reading the  
code that definitions just loaded any defined resources into the  
resource\_collection, just as the recipe DSL would do, which should mean  
notifications should work.

I’ve done a test and a resource outside a definition notifying a resource  
inside a definition seems to work for me. A resource inside a definition  
also seems to be able to send notifications to resources outside the  
definition just fine.

Has the functionality changed so that the warning in the documentation is  
no longer valid, or am I missing a subtlety?

-Ben

---

<div class="post-metadata">

**Author:** ![dennybaa](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/dennybaa/32/286_2.png) [@dennybaa](https://discourse.chef.io/u/dennybaa)\
**Post date:** [February 26, 2014, 6:01am UTC](https://discourse.chef.io/t/definition-question/5068/2 "2014-02-26T06:01:36Z")

</div>

Hi Ben,

I've got the same view on the matter as you. Notifying resources outside  
of a definition works just fine, though I think I haven't tried to  
notify resources inside the definition.  
Actually there's nothing in the chef-client architecture that can  
prevent notifications to work in this case.

Regards,  
Dennis

On 26/02/14 06:01, Benjamin Bytheway wrote:

> In the documentation for definitions  
> ([http://docs.opscode.com/essentials\_cookbook\_definitions.html](http://docs.opscode.com/essentials_cookbook_definitions.html)), I  
> notice it says:
> 
> "resource notifications will not work normally when the resource to be  
> notified is located in a definition"
> 
> I was curious why this is the case, since it looked to me by reading  
> the code that definitions just loaded any defined resources into the  
> resource\_collection, just as the recipe DSL would do, which should  
> mean notifications should work.
> 
> I've done a test and a resource outside a definition notifying a  
> resource inside a definition seems to work for me. A resource inside a  
> definition also seems to be able to send notifications to resources  
> outside the definition just fine.
> 
> Has the functionality changed so that the warning in the documentation  
> is no longer valid, or am I missing a subtlety?
> 
> -Ben

---

<div class="post-metadata">

**Author:** ![Sean\_OMeara1](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/sean_omeara1/32/207_2.png) [@Sean\_OMeara1](https://discourse.chef.io/u/Sean_OMeara1)\
**Post date:** [February 26, 2014, 11:40am UTC](https://discourse.chef.io/t/definition-question/5068/3 "2014-02-26T11:40:29Z")

</div>

I think this is a documentation bug.

It's meant to say that while definitions often "look" like resources in a  
chef recipe (apache\_site "mysite" do..), they don't behave like them. You  
cant notify/subscribe to an apache\_site, for example. Its just a macro that  
yields a set of resources on the resource\_collection. This is contrasted  
with a custom type implemented with the LWRP DSL, where you can..

-s

On Tue, Feb 25, 2014 at 6:01 PM, Benjamin Bytheway [bbytheway@gmail.com](mailto:bbytheway@gmail.com)wrote:

> In the documentation for definitions (  
> [http://docs.opscode.com/essentials\_cookbook\_definitions.html](http://docs.opscode.com/essentials_cookbook_definitions.html)), I notice  
> it says:
> 
> "resource notifications will not work normally when the resource to be  
> notified is located in a definition"
> 
> I was curious why this is the case, since it looked to me by reading the  
> code that definitions just loaded any defined resources into the  
> resource\_collection, just as the recipe DSL would do, which should mean  
> notifications should work.
> 
> I've done a test and a resource outside a definition notifying a resource  
> inside a definition seems to work for me. A resource inside a definition  
> also seems to be able to send notifications to resources outside the  
> definition just fine.
> 
> Has the functionality changed so that the warning in the documentation is  
> no longer valid, or am I missing a subtlety?
> 
> -Ben

---

<div class="post-metadata">

**Author:** ![James\_Scott](https://avatars.discourse-cdn.com/v4/letter/j/f14d63/32.png) [@James\_Scott](https://discourse.chef.io/u/James_Scott)\
**Post date:** [February 26, 2014, 5:31pm UTC](https://discourse.chef.io/t/definition-question/5068/4 "2014-02-26T17:31:24Z")

</div>

Yes, this is a documentation bug. Or was. That page is now updated. Thanks  
for catching this!

On Wed, Feb 26, 2014 at 3:40 AM, Sean OMeara [someara@opscode.com](mailto:someara@opscode.com) wrote:

> I think this is a documentation bug.
> 
> It's meant to say that while definitions often "look" like resources in a  
> chef recipe (apache\_site "mysite" do..), they don't behave like them. You  
> cant notify/subscribe to an apache\_site, for example. Its just a macro that  
> yields a set of resources on the resource\_collection. This is contrasted  
> with a custom type implemented with the LWRP DSL, where you can..
> 
> -s
> 
> On Tue, Feb 25, 2014 at 6:01 PM, Benjamin Bytheway [bbytheway@gmail.com](mailto:bbytheway@gmail.com)wrote:
> 
> > In the documentation for definitions (  
> > [http://docs.opscode.com/essentials\_cookbook\_definitions.html](http://docs.opscode.com/essentials_cookbook_definitions.html)), I notice  
> > it says:
> > 
> > "resource notifications will not work normally when the resource to be  
> > notified is located in a definition"
> > 
> > I was curious why this is the case, since it looked to me by reading the  
> > code that definitions just loaded any defined resources into the  
> > resource\_collection, just as the recipe DSL would do, which should mean  
> > notifications should work.
> > 
> > I've done a test and a resource outside a definition notifying a resource  
> > inside a definition seems to work for me. A resource inside a definition  
> > also seems to be able to send notifications to resources outside the  
> > definition just fine.
> > 
> > Has the functionality changed so that the warning in the documentation is  
> > no longer valid, or am I missing a subtlety?
> > 
> > -Ben
