2

I wrote my own provider which runs ok, for example:

my_custom_provider "#{node['ipaddress']}" do
    my_attribute_1 node['ipaddress']
    action :create
end

template '/opt/app/something.conf' do
  mode '0664'
  owner 'someuser'
  group 'someuser'
  notyfies :restart, "my_custom_provider[#{node['ipaddress']}]", :delayed
end

I receiving error (under chef-solo in Vagrant):

ERROR: resource template[/opt/app/something.conf] is configured to notify
resource my_custom_provider[10.0.2.15] with action restart, but 
my_custom_provider[10.0.2.15] cannot be found in the resource collection.
template[/opt/app/something.conf] is defined in 
/tmp/vagrant-chef/2a59b2477390af49acec413909d80cf5/cookbooks/project/recipes/default.rb:76:in `from_file'

But when I reverse direction of notification it works fine:

my_custom_provider "#{node['ipaddress']}" do
    my_attribute_1 node['ipaddress']
    action :create
    subscribes :restart, 'template[/opt/app/something.conf]', :delayed
end

template '/opt/app/something.conf' do
  mode '0664'
  owner 'someuser'
  group 'someuser'
end

I think this is a bug in chef-solo run under vagrant or maybe I can't add my custom providers as notification target ?

WBAR
  • 4,924
  • 7
  • 47
  • 81

1 Answers1

0

To get notifications working on your custom LWRPs, you might want to look at the example here in chef docs https://docs.chef.io/lwrp_custom_provider.html#updated-by-last-action

jssnirmal
  • 78
  • 4