I guess I'm not understanding what a "unique version" of a file is.If I modify file 'foo', and put it in my cookbook, then the checksum will differ from the in-place file on the target node, and be placed on disk with `action :create`.If I then modify the file on disk, then I've changed the checksum locally, and Chef will clobber my change.You may want to adopt a flow where you on-server modifications (which is an interesting use-case, please elaborate) are done to a copy of your Chef-goverend file.-MOn Thu, Aug 15, 2013 at 1:42 PM, Damien Roche < " target="_blank" href="mailto: "> > wrote:
The file only needs to be placed once per unique version of the file and is moved modified outside chef control.On 15 Aug 2013 18:39, "Mike" < " target="_blank" href="mailto: "> > wrote:Even better:cookbook_file "foo" doaction :create_if_missingendBoom.-MOn Thu, Aug 15, 2013 at 1:23 PM, Andrew Gross < " target="_blank" href="mailto: "> > wrote:
Whats wrong withcookbook_file "foo" doaction :createnot_if { ::File.exists?("foo") }end
On Thu, Aug 15, 2013 at 12:44 PM, Ranjib Dey < " target="_blank" href="mailto: "> > wrote:oops , forgot share the reference
[1] https://github.com/opscode/chef/blob/master/lib/chef/mixin/checksum.rb
On Thu, Aug 15, 2013 at 9:43 AM, Ranjib Dey < " target="_blank" href="mailto: "> > wrote:well, you can do that using ruby stdlib, as well as low level chef api (that chef uses to make file/template/cookbookfile/remote_file [1] idempotent). But why you want to do it? If you are doing it
inside a recipe, probably its a bad idea, consider pushing them inside providers or libraries
On Thu, Aug 15, 2013 at 9:24 AM, < " target="_blank" href="mailto: "> > wrote:
Is it possible to get a checksum of a cookbook file and store this in the attribute?require 'Digest'cb_filename = ? if node.attribute['staged_checksum'] == Digest::SHA2.file(File.new(cb_filename)) Chef::Log.info("Already been staged") else Chef::Log.info("Update staging")
node.attribute['staged_checksum'] = Digest::SHA2.file(File.new(cb_filename))end
On 15 Aug 2013, at 11:40, Ranjib Dey < " target="_blank" href="mailto: "> > wrote:
inside a recipeif node.attribute?('bar')Chef::Log.info('already run')elseruby_block 'set_attribute' doblock donod.set['foo']='bar'endendfile '/foo/bar' doend
content "foobar"
end
On Thu, Aug 15, 2013 at 3:20 AM, < " target="_blank" href="mailto: "> > wrote:Hello,
Would would be the best way to only place a file once per cookbook version. It's modified and removed outside chef.
Regards
D.
Archive powered by MHonArc 2.6.16.