Execute only if file updated?


#1

All,

Is there a way to make chef run an execute ONLY IF a file is updated?
Otherwise, never?

Doug


#2

You can give it action :nothing, then make it subscribe :run to the
file block, or have the file block notify :run the execute block.

On Thu, Dec 4, 2014 at 12:17 PM, Douglas Garstang doug.garstang@gmail.com
wrote:

All,

Is there a way to make chef run an execute ONLY IF a file is updated?
Otherwise, never?

Doug


#3

Sure - make its action :none, and notify it from the execute resource.

Adam

On Thu, Dec 4, 2014 at 9:17 AM, Douglas Garstang doug.garstang@gmail.com
wrote:

All,

Is there a way to make chef run an execute ONLY IF a file is updated?
Otherwise, never?

Doug


#4

file ‘/tmp/foo.txt’ do

content ‘foo’

notifies :run, ‘execute[bar]’

end

execute ‘bar’ do

command ‘echo bar’

action :nothing

end

On Thu, Dec 4, 2014 at 9:18 AM, Douglas Garstang doug.garstang@gmail.com
wrote:

All,
Is there a way to make chef run an execute ONLY IF a file is updated?
Otherwise, never?
Doug


#5

You can extrapolate the idea in the accepted answer here

Chris

From: Douglas Garstang [mailto:doug.garstang@gmail.com]
Sent: Thursday, December 04, 2014 12:18 PM
To: chef@lists.opscode.com
Subject: [chef] Execute only if file updated?

All,
Is there a way to make chef run an execute ONLY IF a file is updated? Otherwise, never?

Doug


#6

Thanks folks.

On Thu, Dec 4, 2014 at 11:41 AM, Fouts, Chris Chris.Fouts@sensus.com
wrote:

You can extrapolate the idea in the accepted answer here

http://stackoverflow.com/questions/6974057/what-is-the-best-way-in-ruby-to-check-if-a-file-was-actually-modified

Chris

From: Douglas Garstang [mailto:doug.garstang@gmail.com]
Sent: Thursday, December 04, 2014 12:18 PM
To: chef@lists.opscode.com
Subject: [chef] Execute only if file updated?

All,

Is there a way to make chef run an execute ONLY IF a file is updated?
Otherwise, never?

Doug


Regards,

Douglas Garstang
http://www.linkedin.com/in/garstang
Email: doug.garstang@gmail.com
Cell: +1-805-340-5627