Closed metmajer closed 9 years ago
Yes, that pattern never worked. Use use_inline_resources
or similar if you want this kind of behavior.
Using use_inline_resources
in providers/configure_init_scripts.rb
, such as:
# providers/configure_init_scripts.rb
use_inline_resources
action :run do
...
does not solve the problem. @coderanger can you be more specific? Thanks.
use_inline_resources
automatically sets the updated flag on the LWResource if any resource used in the action method is updated.
Specifically, using use_inline_resources
, the following should correctly set the updated flag on the resource if any of your script resource executed.
use_inline_resources
action :run do
new_resource.scripts.each do |script|
template "Configure and copy the #{new_resource.name}'s '#{script}' init script" do
source "init.d/#{script}.erb"
path "#{new_resource.installer_prefix_dir}/dynatrace/init.d/#{script}"
...
action :create
end
end
end
Version:
Chef: 12.4.1 (not tested in other versions)
Environment:
I am using a Dockerized Debian 7.4 to test our custom Dynatrace Cookbook via Test Kitchen.
Scenario:
I wrote an LWRP to configure and deploy a set of init scripts (templates) for each of our system services. What I would like to achieve is that our services should only get restarted if a template has changed in a Chef run:
The problem here is that
t.updated_by_last_action
is alwaysfalse
, even if:path
did not existSteps to Reproduce:
Please find a temporary branch here: https://github.com/dynaTrace/Dynatrace-Chef/tree/bugfix/restartIfRequired.
In order to reproduce:
1)
git clone https://github.com/dynaTrace/Dynatrace-Chef.git -b bugfix/restartIfRequired
2) Download the installer artifact from http://bit.ly/1hfKlte and place the file asdynatrace-wsagent.tar
in the Cookbook'sfiles
directory 3)bundle install && kitchen converge wsagent-package-debian