Ho to restart service if aws_s3_file file changes

Hi,

I am using aws s3 to download a file and if the file changes then restart a
service

execute “restart-rexster” do
command "supervisorctl restart rexster_server:"
action :nothing
end

aws_s3_file
"/var/titan-#{feature}-#{version}/rexhome/scripts/VersionControl.groovy" do
bucket "testbucket"
remote_path “#{node.chef_environment}/VersionControl.groovy"
aws_access_key_id aws[‘AWS_ACCESS_KEY_ID’]
aws_secret_access_key aws[‘AWS_SECRET_ACCESS_KEY’]
notifies :run, 'execute[restart-rexster]'
creates
”/var/titan-#{feature}-#{version}/rexhome/scripts/VersionControl.groovy"
end

So…with the above…does the aws_s3 resource support ‘creates’? And…is
it not the case that if the file checksum changes then
’execute[restart-rexster]’ will be executed?

Thanks

looking at the code[1] i am not sure if it supports :creates, you can
simulate the same using not_if{::File.exist?('/path.')} . creates is only
available with certain resources (execute ..etc) its not a meta attribute
(like only_if / ignore_failure),

ps. by default the notification is delayed, i.e it will be triggered at the
end of the chef run, you can use :immediately to alter that.

[1]https://github.com/adamsb6/s3_file/blob/master/providers/default.rb

On Wed, Jul 9, 2014 at 8:09 PM, David Montgomery davidmontgomery@gmail.com
wrote:

Hi,

I am using aws s3 to download a file and if the file changes then restart
a service

execute "restart-rexster" do
command "supervisorctl restart rexster_server:"
action :nothing
end

aws_s3_file
"/var/titan-#{feature}-#{version}/rexhome/scripts/VersionControl.groovy" do
bucket "testbucket"
remote_path "#{node.chef_environment}/VersionControl.groovy"
aws_access_key_id aws['AWS_ACCESS_KEY_ID']
aws_secret_access_key aws['AWS_SECRET_ACCESS_KEY']
notifies :run, 'execute[restart-rexster]'
creates
"/var/titan-#{feature}-#{version}/rexhome/scripts/VersionControl.groovy"
end

So..with the above....does the aws_s3 resource support 'creates'?
And...is it not the case that if the file checksum changes then
'execute[restart-rexster]' will be executed?

Thanks

On Wed Jul 9 22:57:40 2014, Ranjib Dey wrote:

looking at the code[1] i am not sure if it supports :creates, you can
simulate the same using not_if{::File.exist?('/path.')} . creates is
only available with certain resources (execute ..etc) its not a meta
attribute (like only_if / ignore_failure),

ps. by default the notification is delayed, i.e it will be triggered
at the end of the chef run, you can use :immediately to alter that.

[1]https://github.com/adamsb6/s3_file/blob/master/providers/default.rb

wrong s3_file code:
https://github.com/opscode-cookbooks/aws/blob/master/providers/s3_file.rb

it uses the remote_file code so in >= 11.6.0 it will use
etags+last_modified headers to prevent re-downloading the file, and
shouldn't kick off notifies if it doesn't re-download.