templates as static files

15 views
Skip to first unread message

Fabio Sangiovanni

unread,
Dec 4, 2013, 1:33:13 PM12/4/13
to puppet...@googlegroups.com
hi everyone,

are there any side effects in using only templates in a module, even when they have just static content? It would be helpful in having less direcories around to look into when dealing with file contents, especially when using hiera as storage for 'source' and 'content' values for file resources. It just seems more tidy to me not to have a mix of static files and templates in a module, comsidering that templates can be a "superset" of the former.
thanks!

jcbollinger

unread,
Dec 4, 2013, 3:59:52 PM12/4/13
to puppet...@googlegroups.com


On Wednesday, December 4, 2013 12:33:13 PM UTC-6, Fabio Sangiovanni wrote:
hi everyone,

are there any side effects in using only templates in a module, even when they have just static content? It would be helpful in having less direcories around to look into when dealing with file contents, especially when using hiera as storage for 'source' and 'content' values for file resources. It just seems more tidy to me not to have a mix of static files and templates in a module, comsidering that templates can be a "superset" of the former.


The value of a File resource's 'content' property (by which the templated output is delivered) is the actual file content, whereas the 'source' parameter just contains a URL pointing to the desired content.  Each format has both advantages and disadvantages in that area.

Also, templates put far more load on your master for catalog compilation than the alternative, even when the template is all-static.  That will tend to reduce the catalog-serving capacity of your master, though it may be partially offset by the time required later to serve up 'source'd Files.

The 'source' parameter can reference other files available via the target node's filesystem (including network shares); there is no analog for templates.

Templates do not support 'recursive' File resources.

The template() function will concatenate the output of multiple templates, if given, whereas multiple File 'source's constitute prioritized alternatives.

The template() function is not a good choice for binary files.

Overall, I think it would be best to say that although specifying File 'content', possibly via a template, and specifying a File 'source' can ultimately produce the same plain file on the target node, 'content' +- template() is not a superset of 'source'.  Even where the two have overlapping applicability, it is not immediately clear to me that a policy of always choosing 'content' is wise.  I think that as a module developer, you should make an informed decision on a case-by-case basis as to which to use.  I do not find the tidiness argument persuasive.


John

Fabio Sangiovanni

unread,
Dec 4, 2013, 4:10:01 PM12/4/13
to puppet...@googlegroups.com
hi john,
thank you very much for your exaustive answer. I'll meditate a little more on the matter, but I think the differences between the two parameters are more than clear to me now.

thanks again!

Reply all
Reply to author
Forward
0 new messages