Thanks Tensibai!
Regards
From: Tensibai [mailto:tensibai@iabis.net]
Sent: Friday, October 09, 2015 4:42 PM
To: chef@lists.opscode.com
Subject: [chef] Re: RE: How to invoke another recipe with notifies
What Lamon is saying is do a LWRP (resource/provider) which does what is in your deploy.rb file, let’s call it “cookbook_deploy”, this mean it will be in a cookbook named “cookbook” and defined by a resources/deploy.rb to describe the resource and providers/deploy.rb for the code run when the resource is called.
Now in your check_out recipe you will be able to define this deploy resource with an action :nothing and notify it from the git resource.
Documentation on LWRP is here: https://docs.chef.io/release/12-4/custom_resources.html
With the 12.5 versions this is simplified with the custom resources documented here: https://docs.chef.io/custom_resources.html
Le 2015-10-09 07:23, jeffty a écrit :
Thanks Lamont.
Then is it possible to modify an attribute in the chef resource then?
Regards
From: Lamont Granquist [mailto:lamont@chef.io]
Sent: Friday, October 09, 2015 6:18 AM
To: chef@lists.opscode.com mailto:chef@lists.opscode.com
Cc: jeffty <wantwatering@gmail.com mailto:wantwatering@gmail.com >
Subject: Re: [chef] How to invoke another recipe with notifies
You can’t notify a recipe, you can only notify resources. It may be worthwhile to package your recipe up as an LWRP so that the recipe itself is just a call to the LWRP, then notify the LWRP from the other code.
On 10/08/2015 09:59 AM, jeffty wrote:
Hi All,
I have two recipe check_out_code.rb and deploy.rb and want to sync code from git, and them deploy the code to server if the sync successfully (which means that some code in this git project has been changed).
In check_out_code.rb:
git node[‘git_project_directory’] do
repository git_url
action :sync
notifies :run, "how to call the deploy recipe here?", :immediately
end
And in deploy.rb the updated file in the git project directory will be deployed to server once a synchronization is performed successfully.
Is it possible? If not maybe we need to define a global variable like:
synced = false
And change it to true if git sync succeeded. Then
if synced then
include_recipe “mytest::deploy”
end
But this seems not work either in the git resource.
Thanks & Regards
Jason