Hi guys,
I have met an issue and can't overcome it so far.
Will be grateful to you for any advises...Here what I have in my recipe:
ruby_block "Backing up old application folders" do
block do
backup *apps
end
action :nothing
end.run_action(:run)
This is needed to run that block not during convergence phase but during compilation phase. So that it's done before other resources start its run...
“backup” method is called from library.rb file in …/libraries/ folder within my cookbook:
def backup *apps
apps.each do |app|
windows_zipfile archive_path(app) do
source "#{zilliant_folder}\\#{app}"
action :zip
only_if { !::File.exists?(archive_path(app)) }
end
end
end
So what I expect is to do folders backup during compilation phase... But...
During run (compilation phase) it finds “backup” method but it fails with finding “windows_zipfile” method.
Even though I have put dependency on "windows" cookbook in my "metadata.rb" file of my cookbook.
If I call that method “backup” out of “ruby_block” it works fine.
But I need to call it during compile phase (so that it done its job before any other resources).
Why ruby_block doesn’t work for finding “windows_zipfile” method?
How can I implement what I am looking for?
I tried to use "windows_zipfile" by itself outside of ruby_block. But it doesn't have possibility to be run during compile phase. Or I have not figured it out at least. :(
Here is chef-client run-example:
At the very beginning chef-client loads all needed cookbooks dependencies and then fails with that resource from windows cookbook:
PS C:\Users\tklym> chef-client
Starting Chef Client, version 12.3.0
resolving cookbooks for run list: ["zFilesUpdate::Spring15-5_UP_mx"]
Synchronizing Cookbooks:
- artifact
- windows
- chef_handler
- zFilesUpdate
Compiling Cookbooks...
Recipe: zFilesUpdate::Spring15-5_UP_mx
* directory[c:\chef\cache\artifact_file] action delete
- delete existing directory c:\chef\cache\artifact_file
* ruby_block[Backing up old application folders] action run
================================================================================
Error executing action `run` on resource 'ruby_block[Backing up old application folders]'
================================================================================
NoMethodError
-------------
undefined method `windows_zipfile' for Chef::Resource::RubyBlock
Thank you in advance for any of your help or advises.
Regards,
Taras.
Archive powered by MHonArc 2.6.16.