- Puppet:Mastering Infrastructure Automation
- Felix Frank Martin Alfke Alessandro Franceschi Jaime Soriano Pastor Thomas Uphillis
- 218字
- 2021-07-09 18:59:04
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 ... }
- Angular UI Development with PrimeNG
- 前端跨界開發指南:JavaScript工具庫原理解析與實戰
- SpringMVC+MyBatis快速開發與項目實戰
- PHP 從入門到項目實踐(超值版)
- C++面向對象程序設計(微課版)
- Software Testing using Visual Studio 2012
- Java從入門到精通(第5版)
- 精通搜索分析
- C語言從入門到精通(第4版)
- MINECRAFT編程:使用Python語言玩轉我的世界
- Visual Studio Code 權威指南
- Extending Unity with Editor Scripting
- HTML5移動Web開發
- JSP大學實用教程
- Unity3D游戲開發標準教程