- From: Daniel DeLeo <
>
- To:
- Subject: [chef] Re: testing a file for check sums
- Date: Sat, 2 Mar 2013 12:56:35 -0800
On Saturday, March 2, 2013 at 6:34 AM, David Montgomery wrote:
Hi,
I have code that checkout a repo from git.
I need to file if a file has changed and if so the restart a service. How can use chef to create a check for a file from a git repo and find out if the file has changed?
Note: the is a private repo and I use a python script to manage the checkout since I have to pass a username and password for each chef run. I do not use the git resource.
So after I checkout the repo, I have a file called /path/to/foo. If that file changed on the next pull, how do I notify a service to restart?
Thanks
If possible, I'd recommend fixing whatever issue is preventing you from using the git resource. If that's not possible for firewall/policy/whatever reasons, then your next best bet is to make a LWRP that works the same way (compare `git ls-remote REMOTE REF` to `git rev-parse HEAD`, git fetch if needed, then mark the resource updated).
If you really can't do either of those, then you can use Chef's built-in checksumming code. In Chef 11 the code is here:
https://github.com/opscode/chef/blob/master/lib/chef/digester.rb
In Chef 10 and previous, similar logic was implemented in ChecksumCache.
Archive powered by MHonArc 2.6.16.