reserved words

181 views
Skip to first unread message

Uwe Bartels

unread,
Jan 11, 2011, 4:36:05 AM1/11/11
to Puppet Users
Hi,

are there any reserved words i'm not allowed to use in the puppet manifests?
I have some strange errors that came up using puppet manifests with variables like
- $string
- $type
- $label

After changing these variable names everything worked as expected.

Best...
Uwe

Dan Bode

unread,
Jan 11, 2011, 11:57:32 AM1/11/11
to puppet...@googlegroups.com
On Tue, Jan 11, 2011 at 1:36 AM, Uwe Bartels <uwe.b...@gmail.com> wrote:
Hi,

are there any reserved words i'm not allowed to use in the puppet manifests?
I have some strange errors that came up using puppet manifests with variables like
- $string
- $type
- $label

The are special variables, not reserved words:

also $module_name, $title, $name, $caller_module_name
 
After changing these variable names everything worked as expected.

Best...
Uwe

--
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.

Daniel Pittman

unread,
Jan 11, 2011, 12:59:37 PM1/11/11
to puppet...@googlegroups.com

On Jan 11, 2011 8:58 AM, "Dan Bode" <d...@puppetlabs.com> wrote:
> On Tue, Jan 11, 2011 at 1:36 AM, Uwe Bartels <uwe.b...@gmail.com> wrote:

>> are there any reserved words i'm not allowed to use in the puppet manifests?
>> I have some strange errors that came up using puppet manifests with variables like
>> - $string
>> - $type
>> - $label
>
> The are special variables, not reserved words:
> also $module_name, $title, $name, $caller_module_name

However, watch out that any name exported by the Ruby "Kernel" module is unavailable in an erb template - they invoke the Ruby method instead.  (This is nasty for, say, the 'fork' variable in the template.)

While it doesn't sound like that was your problem, it has caught me out more than once.

Regards,
    Daniel

Dan Bode

unread,
Jan 11, 2011, 1:15:24 PM1/11/11
to puppet...@googlegroups.com
On Tue, Jan 11, 2011 at 9:59 AM, Daniel Pittman <dan...@rimspace.net> wrote:

On Jan 11, 2011 8:58 AM, "Dan Bode" <d...@puppetlabs.com> wrote:
> On Tue, Jan 11, 2011 at 1:36 AM, Uwe Bartels <uwe.b...@gmail.com> wrote:

>> are there any reserved words i'm not allowed to use in the puppet manifests?
>> I have some strange errors that came up using puppet manifests with variables like
>> - $string
>> - $type
>> - $label
>
> The are special variables, not reserved words:
> also $module_name, $title, $name, $caller_module_name

However, watch out that any name exported by the Ruby "Kernel" module is unavailable in an erb template - they invoke the Ruby method instead.  (This is nasty for, say, the 'fork' variable in the template.)

feel free to vote on http://projects.puppetlabs.com/issues/5489, I had the same problem, but with a function called y
 

While it doesn't sound like that was your problem, it has caught me out more than once.

Regards,
    Daniel

--

Ohad Levy

unread,
Jan 11, 2011, 1:44:20 PM1/11/11
to puppet...@googlegroups.com
Why not simple render templates with puppet with safemode templating [1]?

this will avoid things like <%= File.read "/etc/shadow" %> and such, additionally, it can whitelist which params are allowed to be accessed within the template.

I started using it within Foreman recently, and I find it very useful.

Daniel Pittman

unread,
Jan 11, 2011, 2:55:01 PM1/11/11
to puppet...@googlegroups.com
On Tue, Jan 11, 2011 at 10:44, Ohad Levy <ohad...@gmail.com> wrote:

> Why not simple render templates with puppet with safemode templating [1]?

Last time I looked I didn't find this, if it was available. That was
several major versions back though.

> this will avoid things like <%= File.read "/etc/shadow" %> and such,
> additionally, it can whitelist which params are allowed to
> be accessed within the template.

Hrm. One of the ... useful by coincidence features of templates is
that they can do a lot more than native code, for better or worse. I
don't object, but I suspect there is a design decision in there.

It would be nice if you could add that suggestion to the ticket,
though; if you don't I will get to it some time.... :)

Regards,
Daniel
--
✉ Daniel Pittman <dan...@rimspace.net>
dan...@rimspace.net (XMPP)
+1 503 893 2285
♻ made with 100 percent post-consumer electrons

Naresh V

unread,
Jan 11, 2011, 10:47:20 PM1/11/11
to puppet...@googlegroups.com
On 11 January 2011 22:27, Dan Bode <d...@puppetlabs.com> wrote:
>
>
> On Tue, Jan 11, 2011 at 1:36 AM, Uwe Bartels <uwe.b...@gmail.com> wrote:
[...]

>
> The are special variables, not reserved words:
>
> also $module_name, $title, $name, $caller_module_name

Hi Dan,

(sorry for the minor thread-hijack)

What's the difference between $module_name and $caller_module_name?
When I was attempting to use a parser function[1] I wrote to simplify
my argument to the source param in file resources, I tried to assign
$module_name to the name of the module and use
lookupfile($module_name, "cluebringer.conf") and got:

> err: Could not retrieve catalog from remote server: Error 400 on SERVER: Cannot reassign variable module_name at /etc/puppet/modules/cbpolicyd/manifests/init.pp:15 on node outbound-us2

I didn't know/follow that it was due to $module_name being a special
variable. I had this in my module:

class cbpolicyd {
$module_name = "cbpolicyd"

file {
"/etc/policyd/cluebringer.conf":
group => root,
mode => 0644,
source => lookupfile($module_name, "cluebringer.conf"),
require => Package["cluebringer"],
notify => Service["cbpolicyd"];
}
... multiple file resources ...
}

Now I think I might be able to simplify lookupfile() by assuming
$module_name (or $caller_module_name) as an implicit argument within
lookupfile.rb[1] and thereby having to just use:

> source => lookupfile("cluebringer.conf")


-Naresh

[1]: http://dpaste.com/hold/308475/

Dan Bode

unread,
Jan 11, 2011, 10:56:44 PM1/11/11
to puppet...@googlegroups.com
On Tue, Jan 11, 2011 at 7:47 PM, Naresh V <nare...@gmail.com> wrote:
On 11 January 2011 22:27, Dan Bode <d...@puppetlabs.com> wrote:
>
>
> On Tue, Jan 11, 2011 at 1:36 AM, Uwe Bartels <uwe.b...@gmail.com> wrote:
[...]
>
> The are special variables, not reserved words:
>
> also $module_name, $title, $name, $caller_module_name

Hi Dan,

(sorry for the minor thread-hijack)

What's the difference between $module_name and $caller_module_name?
When I was attempting to use a parser function[1] I wrote to simplify
my argument to the source param in file resources, I tried to assign
$module_name to the name of the module and use
lookupfile($module_name, "cluebringer.conf") and got:

> err: Could not retrieve catalog from remote server: Error 400 on SERVER: Cannot reassign variable module_name at /etc/puppet/modules/cbpolicyd/manifests/init.pp:15 on node outbound-us2

I didn't know/follow that it was due to $module_name being a special
variable. I had this in my module:

class cbpolicyd {
 $module_name = "cbpolicyd"

this is the offending line, you don't have to specify this, it should already be set.

try putting a notice($module_name) here

 
 file {
   "/etc/policyd/cluebringer.conf":
     group => root,
     mode => 0644,
     source => lookupfile($module_name, "cluebringer.conf"),
     require => Package["cluebringer"],
     notify => Service["cbpolicyd"];
 }
 ... multiple file resources ...
}

Now I think I might be able to simplify lookupfile() by assuming
$module_name (or $caller_module_name) as an implicit argument within
lookupfile.rb[1] and thereby having to just use:

> source => lookupfile("cluebringer.conf")


-Naresh

[1]: http://dpaste.com/hold/308475/
Reply all
Reply to author
Forward
0 new messages