2015-11-07 200 views

回答

3

a great blog post談論廚師提供的分辨率。我強烈建議你先閱讀。從歷史上看,廚師有多種不同的方式來確定應該爲特定資源加載哪個提供商 - 通過使用a map of resource to provider,使用a class name matching algorithm,以及最近使用的provides:

provides的意思是signal that the class provides a particular DSL object。從該法的意見特別有啓發:

資源根據他們的RESOURCE_NAME自動DSL, 相當於provides :resource_name(提供所有 OS的資源)。如果您使用給定的resource_name聲明provides,則其 將取代所提供的(因此您可以在某些OS上爲您的資源DSL提供僅 )。

如果您在單個資源類和單個提供者類中使用提供,Chef(Chef 12.5.x)會每次將該資源映射到該提供者。如果你省略了provides,你將會依賴上面博客文章中提到的其他匹配機制之一。幾乎所有其他方法都被棄用或正在被棄用。我想推薦the Q&A from this blog post。它討論了較舊的方式,棄用,並涵蓋了提供商對資源解決方案的一些細微差別。

+0

謝謝。它確實有幫助。 – chenxin

0

請參考這篇文章https://docs.chef.io/custom_resources.html

這是資源的新的和當前的模式,從廚師客戶端12.5開始。在此版本之前,您在您的問題中提到了老式的資源。新模型沒有提供者,但廚師有很大的向後兼容性,所以仍然可以使用舊式的資源。