Re: [Puppet Users] variable scope woes

2011-03-01 Thread Arnau Bria
On Mon, 28 Feb 2011 12:28:43 -0800 (PST)
draeath draeath wrote:

Hi,

you could add some notify to see what value has $my_role in some
classes.

http://www.devco.net/archives/2009/08/19/tips_and_tricks_for_puppet_debugging.php

We use same schema and variable scope works fine.

what puppet version?

Cheers,
Arnau

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



[Puppet Users] variable scope woes

2011-02-28 Thread draeath
OK - I may be doing this all wrong. If so, I would appreciate finding
out how it -should- be done.

The basic idea is this: a node sets some variables, includes some
classes (which autoload from modules). Some of the modules use
templates to fill in files.

In these templates, we try to access these variables, and fail to do
so. Here's some example code:

# site.pp
import "nodes/basenode.pp"
import "nodes/internal.pp"
import "nodes/external.pp"

# from the node .pp, imported from site.pp
node 'mirror.example.com' {
$my_role = "mirror"
include iptables
include basenode
include sendmail
include sshkeys
}

# from modules/sshkeys/manifests/init.pp
class sshkeys {
file { "/root/.ssh":
ensure => directory;
"/root/.ssh/authorized_keys2":
ensure => file,
mode => 644,
owner => root,
group => root,
content => template("authorized_keys2.erb"),
}
}

# from authorized_keys2.erb
<% if my_role=="mirror" %>
SSH KEY DATA GOES HERE
<% end %>

When this node checks in, the template cannot resolve $my_role, and so
the SSH key(s) are not written in.

--

Previously, everything (except the template file) was included in one
monolithic site.pp, and it all worked. It's only after I've split all
the classes out into modules that this started to happen. (I also
removed the nodes from inside site.pp and put them in files, imported
as above. I've looked through some documentation and haven't been able
to figure this out. No help was to be found on freenode either.

NOTE: I just grabbed my_role as it's the most critical variable that
gives me this issue. Other variables note related to node "roles" seem
to have problems as well, for example sticking hostnames in iptables
configuration.

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