アクションcookbook_file内に作成する必要があるLWRPがありますcreate
resource_name :vuy
property :vu_name, String, name_property :true
actions :create
action :create do
log "vuy:@new_resource.vu_name-#{@new_resource.vu_name}"
cookbook_file "c:/temp/test.xml" do
source "#{@new_resource.vu_name}"
end
end
そしてテストレシピ
vuy 'text.txt'
chef-client実行はエラーで失敗しますNoMethodError: undefined method 'vu_name' for nil:NilClass
cookbook_fileメソッドから削除するcreateと、ログが正しく表示されます:INFO: vu:@new_resource.vu_name-text.txt
次のステップでは、置き換えました
source "#{@new_resource.vu_name}"
テストレシピで指定された値と同じ
source "text.txt"
ファイルが取得されました。私には、cookbook_file内側のルビブロックがコピーされていないように見えnew_resource、 になりnilます。
アクション内で宣言されたリソースの引数として LWRP のプロパティを使用する方法は?