Templates VS static files

492 views
Skip to first unread message

Alaric

unread,
Oct 25, 2010, 11:12:36 AM10/25/10
to puppet...@googlegroups.com
Hi folks,

This may be a totally dumb question, but hey.. sometimes I'm dumb....

recently I've been rocking template's like a crazy person.. and I'm wondering, is there any reason why I shouldn't use templates for *all* files I want to  manage, rather then have some files defined under files directory some in templates, and some content defined in the manifest itself..   I'm thinking that as I train our team to use puppet, having two possible source of content to look at would be easier then three.  Are there any pro/cons to using templates exclusively?   

Thanks!

-a

Nigel Kersten

unread,
Oct 25, 2010, 12:50:08 PM10/25/10
to puppet...@googlegroups.com
You may end up with files that have template expansion syntax inside them that you weren't expecting?

Have you looked at the file() function? It's very similar to template, but without the templating. Unfortunately it's not quite consistent with the template function, but we are going to fix that. It takes absolute paths, not module-based.


is the ticket to watch for us adding the "~" syntax and making the file/template functions consistent.
 

Thanks!

-a

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.



--
Nigel Kersten
Product Manager, Puppet Labs
Twitter: @nigelkersten

Patrick

unread,
Oct 25, 2010, 12:52:05 PM10/25/10
to puppet...@googlegroups.com

Sure, it's slower. That being said, I'm not sure if the performance difference will be big enough it matter.

Nigel Kersten

unread,
Oct 25, 2010, 12:59:13 PM10/25/10
to puppet...@googlegroups.com
Also, in case it wasn't clear, there are fundamental differences between file/template and a source specified file like puppet:///foo/bar

The former will:

* be shipped as part of the catalog
* always be shipped to the client in the catalog regardless of client state
* can be applied offline


The latter will:

* not be shipped as part of the catalog
* fetched at catalog application time, but only if the client requires it
* cannot be applied offline


 

R.I.Pienaar

unread,
Oct 25, 2010, 2:13:44 PM10/25/10
to puppet...@googlegroups.com

----- "Nigel Kersten" <ni...@puppetlabs.com> wrote:


> Also, in case it wasn't clear, there are fundamental differences
> between file/template and a source specified file like
> puppet:///foo/bar
>
>
> The former will:
>
>
> * be shipped as part of the catalog
> * always be shipped to the client in the catalog regardless of client
> state
> * can be applied offline
>


There is an often overlooked reason to use content and not source.

If you're deploying manifests and code that are sensitive to being the
right combination of config files vs source you absolutely want to avoid
using source and favor content.

Puppet has a catalog cache and will use the cache if anything went wrong
during compilation of your new catalog. The 'something goes wrong' can
literally be anything like syntax errors but also software crashes, being
out of memory, write errors to disk or any of a 100 other factors.

In this scenario puppetd will use the old catalog BUT it will still fetch
files with source from the master. Should a file fetch pass it will apply
the just downloaded file. In this scenario its conceivable that you
end up with a scenario where your manifests are out of sync with the files
being installed on your servers and this could render your servers broken.

If you have very sensitive combo's of software, config and supporting files
all being copied out and applied with puppet, or even if you are using packages
to deploy software but puppet to deploy the configs you want to be very very
careful of the cache.

I recommend either avoiding source in these cases or disabling the feature
that let puppet use the cache on compile failure. I also monitor my compiles
for success.

I've often campaigned for a catalog that combines files and everything else
into one artifact but I think we're some way off from realising that still.


donavan

unread,
Oct 25, 2010, 4:55:49 PM10/25/10
to Puppet Users
On Oct 25, 11:13 am, "R.I.Pienaar" <r...@devco.net> wrote:
> In this scenario puppetd will use the old catalog BUT it will still fetch
> files with source from the master.

This is also possible during your VCSs 'update' if /etc/puppet is a
workdir. This came up at puppet camp, and I think two groups mentioned
seeing this actually happen in production. In both cases puppetd just
corrected it on the next run.

> I've often campaigned for a catalog that combines files and everything else
> into one artifact but I think we're some way off from realising that still.

From the description I think #4817 implements this? I haven't even
looked at the code though, so reality may vary.

donavan

unread,
Oct 25, 2010, 5:01:40 PM10/25/10
to Puppet Users
On Oct 25, 8:12 am, Alaric <paxindust...@gmail.com> wrote:
>  Are there any pro/cons to using templates exclusively?
>

Besides the already mentioned there are some security issues with
using the file server from puppet. Richard Crowley covered this a bit
in his puppetcamp talk[1]. He also distributes all of his configs in
the catalog, so there's an example of production. On the downside your
catalog will get pretty big. I can say that you shouldn't have any
problems at 300Kb, at least. I'd be wary of getting too much bigger
than that.

[1] http://rcrowley.org/talks/puppet-camp-2010/#1

Patrick

unread,
Oct 26, 2010, 12:38:11 AM10/26/10
to puppet...@googlegroups.com

You also might want to watch http://projects.puppetlabs.com/issues/4837

That looks more like what you want to me although it isn't finished. #4817 seems to have working code though.

alaric

unread,
Oct 26, 2010, 9:17:11 AM10/26/10
to Puppet Users
Wow,

This has all been great information! Thanks to everyone who posted!

-a


On Oct 26, 12:38 am, Patrick <kc7...@gmail.com> wrote:
> On Oct 25, 2010, at 1:55 PM, donavan wrote:
>
> > On Oct 25, 11:13 am, "R.I.Pienaar" <r...@devco.net> wrote:
> >> In this scenario puppetd will use the old catalog BUT it will still fetch
> >> files with source from the master.
>
> > This is also possible during your VCSs 'update' if /etc/puppet is a
> > workdir. This came up at puppet camp, and I think two groups mentioned
> > seeing this actually happen in production. In both cases puppetd just
> > corrected it on the next run.
>
> >> I've often campaigned for a catalog that combines files and everything else
> >> into one artifact but I think we're some way off from realising that still.
>
> > From the description I think #4817 implements this? I haven't even
> > looked at the code though, so reality may vary.
>
> You also might want to watchhttp://projects.puppetlabs.com/issues/4837
Reply all
Reply to author
Forward
0 new messages