问题
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