Merhaba Chef ve Ruby'de yeniyim. Chef 'da bir yemek tarifi yapmaya çalışıyorum Bir Ruby on (Benim) rubyum kodunun içine girdiğim bir değere bağlı olarak bir sunucuda bir cron işi oluşturmak için.Şef'te crontab işini ruby kodundan değişken değerlere göre oluşturma
Gem.clear_paths
node.default["value"] = "nil"
require 'net/http'
ruby_block "do-http-request-with-cutom-header" do
block do
Net::HTTP.get('example.com', '/index.html') # => String
uri = URI('http://example.com/index.html')
params = { :limit => 10, :page => 3 }
uri.query = URI.encode_www_form(params)
res = Net::HTTP.get_response(uri)
puts res.body if res.is_a?(Net::HTTPSuccess)
value= res.code
node["value"] = value
end
end
if node["value"] == "nil" then
cron "cassandra repair job" do
action :delete
end
else
cron "cassandra repair job" do
hour "0"
minute "55"
weekday node["value"]
mailto "[email protected]"
user "root"
command "/opt/cassandra/bin/nodetool repair -par -inc -pr"
end
end
O şef Tembel Değerlendirilmesi değişken yöntemi olduğunu biliyoruz ve yakut kodu yakınsama faz üzerinde yürütülüyor, ama benim kodunu değiştirmek yolunu olamaz.
Tembel değerlendirmeyi kodumda nasıl kullanabilirim?
https://github.com/chef-cookbooks/cron –
@RajarshiDas Q, cron kaynağı hakkında değil, tembel değerlendirmeyle ilgili değildir ve bir gönderiyi düzenlediğinizde, bir bütün olarak düzeltmeye çalışmalısınız. bölüm :) – Tensibai
[çoğaltılmamışsa ilgili] (http://stackoverflow.com/questions/30424244/using-a-ruby-block-to-assign-variables-in-chef-recipe?rq=1). – Tensibai