- From: Jonathan Matthews <
>
- To: chef <
>
- Subject: [chef] Re: Template's "cookbook" attribute being ignored [WORKAROUND DISCOVERED]
- Date: Wed, 6 Apr 2011 17:56:19 +0100
- Domainkey-signature: a=rsa-sha1; c=nofws; d=jpluscplusm.com; s=google; h=mime-version:sender:x-originating-ip:date:x-google-sender-auth :message-id:subject:from:to:content-type; b=ZrmyKdRsuZRCMjZJ9FJ5WV+zxGdjgf3yC7fXR7ELBw3jRuDt3RFEkJE359A9Qdym9l vQb6aPPNP5AQ1I4FjfSe+UZOHAqsSthQaWpcMYrJ8vDzvwdKwqWQ6CTAIYoTeYli9Lid 95CC1PCfyBQh/srKI9C8wMwQqZak9KQoBv3Ig=
On 5 April 2011 15:56, Jonathan Matthews
<
>
wrote:
>
On 4 April 2011 21:55, Jonathan Matthews
>
<
>
>
wrote:
>
> I'm running 0.9.12 on Ubuntu Lucid (server) and Debian Squeeze (client).
>
>
Correction: 0.9.14 on the Debian client.
>
>
> [Mon, 04 Apr 2011 21:42:29 +0100] DEBUG: looking for template
>
> etc-default-tftpd-hpa.erb in cookbook "filesystem"
>
>
I think this last line is a *lie*. It comes from
>
https://github.com/opscode/chef/blob/master/chef/lib/chef/provider/template.rb#L63
>
and is directly contradicted by the contents of "cookbook" at
>
https://github.com/opscode/chef/blob/master/chef/lib/chef/provider/template.rb#L68.
>
Popping a debug log in between L68/69, I can see that "cookbook"
>
contains the correct setting from the recipe/resource interaction.
I still think this is the case. It wasn't anything to do with my
problem, however.
The problem is that not all legal ruby hashes may be passed to a
template's variables() attribute/method. Specifically, this example
breaks with very unhelpful, unspecific error messages:
template "foobar" do
path "/tmp/foobar"
source "whatever"
variables ( :"-foo" => "bar" )
end
I suppose the problem here is that the method of instantiating each
key as an instance variable breaks when the key isn't a legal variable
name.
Whilst this may not be a problem when choosing the variable names
individually, it is a problem when trying to pass a subtree of node
through to the template and the particular branch one starts at (a)
may contain -, +, or other characters invalid in variable names and
(b) is editable by users via the WebUI. (FWIW I'm trying to avoid
just referencing node directly so as to decouple the "view" from the
"model" - one of the fundamental concepts behind the "think of it like
an MVC" idea, IIRC).
Any ideas? I'm going to gsub anything not matching [a-zA-Z0-9] to
underscores for now and update their templates, but that's hardly
ideal - especially in a multi-admin environment.
Jonathan
--
Jonathan Matthews
London, UK
http://www.jpluscplusm.com/contact.html
- [chef] Re: Template's "cookbook" attribute being ignored [WORKAROUND DISCOVERED], Jonathan Matthews, 04/06/2011
Archive powered by MHonArc 2.6.16.