# Notifies on resource not notifying

**URL:** <https://discourse.chef.io/t/notifies-on-resource-not-notifying/3446>\
**Category:** Chef Infra (archive)\
**Created:** [December 27, 2012, 3:43pm UTC](https://discourse.chef.io/t/notifies-on-resource-not-notifying/3446 "2012-12-27T15:43:20Z")\
**Posts on this page:** 8\
**Page:** 2

<div class="post-metadata">

**Author:** ![kallistec](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/kallistec/32/23_2.png) [@kallistec](https://discourse.chef.io/u/kallistec)\
**Post date:** [January 2, 2013, 7:33pm UTC](https://discourse.chef.io/t/notifies-on-resource-not-notifying/3446/21 "2013-01-02T19:33:40Z")

</div>

On Wednesday, January 2, 2013 at 10:02 AM, Seif Attar wrote:

> On 2 January 2013 16:43, Daniel DeLeo \<[dan@kallistec.com](mailto:dan@kallistec.com) ([mailto:dan@kallistec.com](mailto:dan@kallistec.com))\> wrote:
> 
> > For sanity's sake can you copy the debug code you have in the ruby block to outside of the ruby block (so it runs during compile time)?  
> > Sure, updated gist:
> 
> [template resource not notifying · GitHub](https://gist.github.com/4400257/76f38c860447315a26844521955633283807290c#file-log-txt-L12-L13)
> 
> So you don't think it has anything to do with [https://github.com/opscode/chef/blob/master/lib/chef/provider/file.rb#L148-L153](https://github.com/opscode/chef/blob/master/lib/chef/provider/file.rb#L148-L153) as the comment says that reporting won't work.  
> That's correct, the reporting stuff has to do with explicitly recording before and after state for resources for the purpose of storing that information elsewhere.

I'll need to look at it more in-depth, but at the moment I'm seeing something odd with the names of the resources and the path separators:

localhost [2013-01-02T17:48:42+00:00] INFO: Processing template[C:\Temp\bt97\1.8.9-alpha-01133\Deployment\Settings\CHEF.js] action nothing (Wiggle\_Billing::default line /chef/cache/cookbooks/Wiggle\_Billing/recipes/default.rb)  
localhost [2013-01-02T17:49:36+00:00] INFO: windows\_zipfile[unzip\_artefacts] sending create action to template[C:/Temp/bt97/1.8.9-alpha-01133/Deployment/Settings/CHEF.js] (immediate)

localhost [2013-01-02T17:49:36+00:00] INFO: Processing template[C:/Temp/bt97/1.8.9-alpha-01133/Deployment/Settings/CHEF.js] action create (Wiggle\_Billing::default line /chef/cache/cookbooks/Wiggle\_Billing/recipes/default.rb)

localhost [2013-01-02T17:49:37+00:00] INFO: template[C:/Temp/bt97/1.8.9-alpha-01133/Deployment/Settings/CHEF.js] backed up to c:/chef/backup/Temp/bt97/1.8.9-alpha-01133/Deployment/Settings/CHEF.js.chef-20130102174937

localhost [2013-01-02T17:49:37+00:00] INFO: template[C:/Temp/bt97/1.8.9-alpha-01133/Deployment/Settings/CHEF.js] updated content

Note the forward slash vs. backward slash. It may be a red herring, I'll have to do more investigation.

--  
Daniel DeLeo

---

<div class="post-metadata">

**Author:** ![Seif\_Attar](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/seif_attar/32/630_2.png) [@Seif\_Attar](https://discourse.chef.io/u/Seif_Attar)\
**Post date:** [January 2, 2013, 9:40pm UTC](https://discourse.chef.io/t/notifies-on-resource-not-notifying/3446/22 "2013-01-02T21:40:57Z")

</div>

Thanks for looking into this, let me know if I can help with anything.

I tried to work around the problem by putting all the resources in an if  
statement instead of having and not\_if and notifies (is this even allowed?)

I am getting an error in the template now that I need to set username or  
group, updated recipe and log:

> <https://gist.github.com/seif/4400257/a96b9810e4b67c488663db8aedb9e2fcca637e91>

Is there a better way to work around the problem, so that no changes occur  
if the file exists?

Thanks again,  
Seif

---

<div class="post-metadata">

**Author:** ![kallistec](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/kallistec/32/23_2.png) [@kallistec](https://discourse.chef.io/u/kallistec)\
**Post date:** [January 2, 2013, 10:20pm UTC](https://discourse.chef.io/t/notifies-on-resource-not-notifying/3446/23 "2013-01-02T22:20:08Z")

</div>

On Wednesday, January 2, 2013 at 1:40 PM, Seif Attar wrote:

> Thanks for looking into this, let me know if I can help with anything.
> 
> I tried to work around the problem by putting all the resources in an if statement instead of having and not\_if and notifies (is this even allowed?)
> 
> I am getting an error in the template now that I need to set username or group, updated recipe and log:
> 
> [template resource not notifying · GitHub](https://gist.github.com/4400257/a96b9810e4b67c488663db8aedb9e2fcca637e91)  
> Is this with a pristine copy of Chef? I'm curious as to how you're ending up with owner, group, and mode set on that resource. The code you were looking at before would do that (File#load\_current\_resource\_attrs), but it should be skipped on windows.

> Is there a better way to work around the problem, so that no changes occur if the file exists?
> 
> Thanks again,  
> Seif

--  
Daniel DeLeo

---

<div class="post-metadata">

**Author:** ![Seif\_Attar](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/seif_attar/32/630_2.png) [@Seif\_Attar](https://discourse.chef.io/u/Seif_Attar)\
**Post date:** [January 2, 2013, 11:24pm UTC](https://discourse.chef.io/t/notifies-on-resource-not-notifying/3446/24 "2013-01-02T23:24:25Z")

</div>

On 2 January 2013 22:20, Daniel DeLeo [dan@kallistec.com](mailto:dan@kallistec.com) wrote:

> Is this with a pristine copy of Chef? I'm curious as to how you're ending  
> up with owner, group, and mode set on that resource. The code you were  
> looking at before would do that (File#load\_current\_resource\_attrs), but it  
> should be skipped on windows.

I installed chef on the vm using the msi installer and haven't modified the  
code in anyway if that is what you mean by pristine.

It is all mind boggling to me, because it install and executes fine when I  
remove the if statement that checks if the file exists in the workaround,  
which is why I assumed what I am doing with the if statement is wrong :S

I have added the stack trace to

> <https://gist.github.com/seif/4400257/29facfab54f90ee0cf81a9ab0730436bdaa53b2d>

Maybe it helps unravel the mystery

---

<div class="post-metadata">

**Author:** ![kallistec](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/kallistec/32/23_2.png) [@kallistec](https://discourse.chef.io/u/kallistec)\
**Post date:** [January 3, 2013, 6:25pm UTC](https://discourse.chef.io/t/notifies-on-resource-not-notifying/3446/25 "2013-01-03T18:25:14Z")

</div>

On Wednesday, January 2, 2013 at 3:24 PM, Seif Attar wrote:

> On 2 January 2013 22:20, Daniel DeLeo \<[dan@kallistec.com](mailto:dan@kallistec.com) ([mailto:dan@kallistec.com](mailto:dan@kallistec.com))\> wrote:
> 
> > Is this with a pristine copy of Chef? I'm curious as to how you're ending up with owner, group, and mode set on that resource. The code you were looking at before would do that (File#load\_current\_resource\_attrs), but it should be skipped on windows.  
> > I installed chef on the vm using the msi installer and haven't modified the code in anyway if that is what you mean by pristine.  
> > Then can you try commenting out that method? That's the only place I can think of where you'd be getting unix-style permissions attributes getting set on your resource.

> It is all mind boggling to me, because it install and executes fine when I remove the if statement that checks if the file exists in the workaround, which is why I assumed what I am doing with the if statement is wrong :S
> 
> I have added the stack trace to  
> [template resource not notifying · GitHub](https://gist.github.com/4400257/29facfab54f90ee0cf81a9ab0730436bdaa53b2d)
> 
> Maybe it helps unravel the mystery

--  
Daniel DeLeo

---

<div class="post-metadata">

**Author:** ![Seif\_Attar](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/seif_attar/32/630_2.png) [@Seif\_Attar](https://discourse.chef.io/u/Seif_Attar)\
**Post date:** [January 3, 2013, 7:39pm UTC](https://discourse.chef.io/t/notifies-on-resource-not-notifying/3446/26 "2013-01-03T19:39:55Z")

</div>

On 3 January 2013 18:25, Daniel DeLeo [dan@kallistec.com](mailto:dan@kallistec.com) wrote:

> Then can you try commenting out that method? That's the only place I can  
> think of where you'd be getting unix-style permissions attributes getting  
> set on your resource.

I commented out all lines inside File#load\_current\_resource\_attrs and added

```
    Chef::Log.info("current_resource '#{@current_resource.inspect}'")
    Chef::Log.info("new_resource '#{@new_resource.inspect}'")

```

Resulting in (sorry about the messy layout):

localhost [2013-01-03T19:20:25+00:00] INFO: current\_resource  
'\<template[C:/Temp/bt97/1.8.9-alpha-01133/Deployment/Settings/CHEF.js]  
@name: "C:/Temp/bt97/1.8.9-alpha-01133/Deployment/Settings/CHEF.js" @noop:  
nil @before: nil @params: {} @provider: Chef::Provider::Template  
@allowed\_actions: [:nothing, :create, :delete, :touch, :create\_if\_missing]  
@action: "create" @updated: false @updated\_by\_last\_action: false @supports:  
{} @ignore\_failure: false @retries: 0 @retry\_delay: 2 @source\_line: nil  
@elapsed\_time: 0 @resource\_name: :template @path:  
"C:/Temp/bt97/1.8.9-alpha-01133/Deployment/Settings/CHEF.js" @backup: 5  
@diff: nil @source: "CHEF.js.erb" @cookbook: nil @local: false @variables:  
{} @checksum:  
"fe6bed989662a2d206442d5fa143ce9976ccafd802947c68e5f1f2ee6d19d6eb"\>'  
localhost [2013-01-03T19:20:25+00:00] INFO: new\_resource  
'\<template[C:/Temp/bt97/1.8.9-alpha-01133/Deployment/Settings/CHEF.js]  
@name: "C:/Temp/bt97/1.8.9-alpha-01133/Deployment/Settings/CHEF.js" @noop:  
nil @before: nil @params: {} @provider: Chef::Provider::Template  
@allowed\_actions: [:nothing, :create, :delete, :touch, :create\_if\_missing]  
@action: [:create] @updated: true @updated\_by\_last\_action: false @supports:  
{} @ignore\_failure: false @retries: 0 @retry\_delay: 2 @source\_line:  
"c:/chef/cache/cookbooks/Wiggle\_Billing/recipes/default.rb:32:in  
`from\_file'" @elapsed\_time: 0 @resource\_name: :template @path:  
"C:/Temp/bt97/1.8.9-alpha-01133/Deployment/Settings/CHEF.js" @backup: 5  
@diff: "--- " @source: "CHEF.js.erb" @cookbook: nil @local: false  
@variables: {} @cookbook\_name: "Wiggle\_Billing" @recipe\_name: "default"  
@checksum:  
"fe6bed989662a2d206442d5fa143ce9976ccafd802947c68e5f1f2ee6d19d6eb" @owner:  
0 @group: 0 @mode: 420 @rights: nil @deny\_rights: nil @inherits: nil\>'

And then I get the same exception Must specify username, group or SID: 0

---

<div class="post-metadata">

**Author:** ![kallistec](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/kallistec/32/23_2.png) [@kallistec](https://discourse.chef.io/u/kallistec)\
**Post date:** [January 3, 2013, 11:57pm UTC](https://discourse.chef.io/t/notifies-on-resource-not-notifying/3446/27 "2013-01-03T23:57:36Z")

</div>

On Thursday, January 3, 2013 at 11:39 AM, Seif Attar wrote:

> On 3 January 2013 18:25, Daniel DeLeo \<[dan@kallistec.com](mailto:dan@kallistec.com) ([mailto:dan@kallistec.com](mailto:dan@kallistec.com))\> wrote:
> 
> > Then can you try commenting out that method? That's the only place I can think of where you'd be getting unix-style permissions attributes getting set on your resource.  
> > I commented out all lines inside File#load\_current\_resource\_attrs and added
> 
> ```
> Chef::Log.info (http://Log.info)("current_resource '#{@current_resource.inspect}'")
> Chef::Log.info (http://Log.info)("new_resource '#{@new_resource.inspect}'")
> 
> ```
> 
> Resulting in (sorry about the messy layout):
> 
> localhost [2013-01-03T19:20:25+00:00] INFO: current\_resource '\<template[C:/Temp/bt97/1.8.9-alpha-01133/Deployment/Settings/CHEF.js] @name: "C:/Temp/bt97/1.8.9-alpha-01133/Deployment/Settings/CHEF.js" @noop: nil @before: nil @params: {} @provider: Chef::Provider::Template @allowed\_actions: [:nothing, :create, :delete, :touch, :create\_if\_missing] @action: "create" @updated: false @updated\_by\_last\_action: false @supports: {} @ignore\_failure: false @retries: 0 @retry\_delay: 2 @source\_line: nil @elapsed\_time: 0 @resource\_name: :template @path: "C:/Temp/bt97/1.8.9-alpha-01133/Deployment/Settings/CHEF.js" @backup: 5 @diff: nil @source: "CHEF.js.erb" @cookbook: nil @local: false @variables: {} @checksum: "fe6bed989662a2d206442d5fa143ce9976ccafd802947c68e5f1f2ee6d19d6eb"\>'  
> localhost [2013-01-03T19:20:25+00:00] INFO: new\_resource '\<template[C:/Temp/bt97/1.8.9-alpha-01133/Deployment/Settings/CHEF.js] @name: "C:/Temp/bt97/1.8.9-alpha-01133/Deployment/Settings/CHEF.js" @noop: nil @before: nil @params: {} @provider: Chef::Provider::Template @allowed\_actions: [:nothing, :create, :delete, :touch, :create\_if\_missing] @action: [:create] @updated: true @updated\_by\_last\_action: false @supports: {} @ignore\_failure: false @retries: 0 @retry\_delay: 2 @source\_line: "c:/chef/cache/cookbooks/Wiggle\_Billing/recipes/default.rb:32:in `from\_file'" @elapsed\_time: 0 @resource\_name: :template @path: "C:/Temp/bt97/1.8.9-alpha-01133/Deployment/Settings/CHEF.js" @backup: 5 @diff: "--- " @source: "CHEF.js.erb" @cookbook: nil @local: false @variables: {} @cookbook\_name: "Wiggle\_Billing" @recipe\_name: "default" @checksum: "fe6bed989662a2d206442d5fa143ce9976ccafd802947c68e5f1f2ee6d19d6eb" @owner: 0 @group: 0 @mode: 420 @rights: nil @deny\_rights: nil @inherits: nil\>'
> 
> And then I get the same exception Must specify username, group or SID: 0

Okay, then we need to track down where these values are being set. Try this:

class Chef  
class Resource  
class Template  
def mode(\*args)  
unless args.empty?  
Chef::Log.warn("Template mode being set to '#{args.inspect}' from:")  
Chef::Log.warn(caller.join("\n"))  
end  
super  
end  
end  
end  
end

--  
Daniel DeLeo

---

<div class="post-metadata">

**Author:** ![Seif\_Attar](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/seif_attar/32/630_2.png) [@Seif\_Attar](https://discourse.chef.io/u/Seif_Attar)\
**Post date:** [January 4, 2013, 12:07pm UTC](https://discourse.chef.io/t/notifies-on-resource-not-notifying/3446/28 "2013-01-04T12:07:35Z")

</div>

On 3 January 2013 23:57, Daniel DeLeo [dan@kallistec.com](mailto:dan@kallistec.com) wrote:

> Okay, then we need to track down where these values are being set. Try  
> this:
> 
> class Chef  
> class Resource  
> class Template  
> def mode(\*args)  
> unless args.empty?  
> Chef::Log.warn("Template mode being set to '#{args.inspect}'  
> from:")  
> Chef::Log.warn(caller.join("\n"))  
> end  
> super  
> end  
> end  
> end  
> end

Wasn't sure where to add this, but managed to crowbar it into the template  
mixin. output:

> <https://gist.github.com/seif/4452128>

I modified the template.rb and added

```
          if Chef::Platform.windows?
            return
          end

```

on line 66 after access\_control.set\_all!

And I am no longer getting that exception now.

[Previous page](https://discourse.chef.io/t/notifies-on-resource-not-notifying/3446.md?page=1)
