How to iterate over instances of defined types in Puppet

妖精的绣舞 提交于 2019-12-11 10:21:19

问题


I want to iterate over all instances of defined types (ex. Apache::Vhost). However this loop only list my resources under the scope.

<% scope.catalog.vertices.each do |resource| -%>
<%# if resource.type == "Apache::Vhost" -%>
#Include <%= resource.title %>
<% end -%>

回答1:


Walking the catalog durig at compile time ("catalog building") is a Bad Idea.

If you really want this functionality, think about moving the iteration code to a custom provider that will generate the file content akin to what your master side template tries at the moment.

At the sync stage, you can safely access the complete catalog via self.resource.catalog.



来源:https://stackoverflow.com/questions/23054661/how-to-iterate-over-instances-of-defined-types-in-puppet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!