Resource dependency for running bash


#1

Hi All,

I have a recipe which copies a remote file and then run a shell script,

The issue is that even if there is no new file added in the remote location
, when i run chef client it runs the bash script.

How do i add the dependency on that file resource for that bash script , so
that the script is not run if the file copied is not a new one.

Thanks
Manoj


#2

Manoj,

You should use Resource Notifications (
http://docs.opscode.com/resource_common.html#notifications) so the bash
block resource gets executed only if the content of the remote file is
changed. You can see samples in the page I mentioned above.

Kannan.

On Tue, Sep 10, 2013 at 9:35 PM, Manoj Thakkar manoj.thakkar@gmail.comwrote:

Hi All,

I have a recipe which copies a remote file and then run a shell script,

The issue is that even if there is no new file added in the remote
location , when i run chef client it runs the bash script.

How do i add the dependency on that file resource for that bash script ,
so that the script is not run if the file copied is not a new one.

Thanks
Manoj


#3

On Sep 10, 2013, at 11:35 PM, Manoj Thakkar manoj.thakkar@gmail.com wrote:

How do i add the dependency on that file resource for that bash script , so that the script is not run if the file copied is not a new one.

Do an “action :nothing” in the bash resource. Then, either do a notify from the file resource to the bash resource, or a subscribe from the bash resource to the file resource.

See http://docs.opscode.com/chef/resources.html#notifications for more info.


Brad Knowles brad@shub-internet.org
LinkedIn Profile: http://tinyurl.com/y8kpxu