Including classes from defined types
The example_app_config
type that was defined in the previous example is supposed to serve a very specific purpose. Therefore, it assumes that the base directory, /etc/example_app
, and its subdirectories were managed independently, outside the defined type. This was a sound design, but many defined types are meant to be used from lots of independent classes or other defined types. Such defines need to be self-contained.
In our example, the defined type needs to make sure that the following resources are part of the manifest:
file { [ '/etc/example_app', '/etc/example_app/config.d.enabled' ]: ensure => 'directory', }
Just putting this declaration into the body of the define will lead to duplicate resource errors. Each instance of example_app_config
will try to declare the directories by itself. However, we already discussed a pattern to avoid just that issue—we called it the component class.
To make sure that any instance of the example_app_config
type is self-contained and works on its own, wrap the preceding declaration in a class (for example, class example_app_config_directories
) and make sure to include this class right in the body of the define:
define example_app_config(Array $regions = []) { include example_app_config_directories ... }
- Learning RxJava
- 精通Scrapy網絡爬蟲
- 差分進化算法及其高維多目標優化應用
- Hands-On RESTful Web Services with Go
- 編譯系統透視:圖解編譯原理
- JavaCAPS基礎、應用與案例
- 持續輕量級Java EE開發:編寫可測試的代碼
- Kotlin Programming By Example
- JQuery風暴:完美用戶體驗
- 寫給大家看的Midjourney設計書
- IPython Interactive Computing and Visualization Cookbook
- Java Web開發教程:基于Struts2+Hibernate+Spring
- 讀故事學編程:Python王國歷險記
- Visual C#(學習筆記)
- Spring MVC Blueprints