On 1 Jun., 13:18, David Schmitt <[email protected]> wrote:
> Paul schrieb:
>
> >> > define railsproject($name, $uid, $gid, $userpass, $sqlpass) {
> >> > mysql_database { "${name}_staging": ensure => present }
> >> > mysql_database { "${name}_production": ensure => present}
>
> >> > ....more stuff...
> >> > }
>
> > Thanks all, it works. Is this documented or have you figured this out
> > by trial and error? I'm not trying to blame the docs, it's just that I
> > couldn't find anything about the ${} rule.
>
> See http://reductivelabs.com/trac/puppet/wiki/LanguageTutorial#quoting
Indeed, shame on me ;) But if you take that literally brackets
shouldn't be needed.
>
> > Apparently there seem to be more differences between classes and
> > defines wrt. scope. When I use template("foo.erb") inside a define() I
> > don't have direct access to facts or other variables (fex. the $name).
> > However scope.lookupvar('name') works. Is this expected behaviour?
>
> No. What version of puppet are you using? How did your ERB look like?
Version is 0.24.8, I'm testing with:
-------------------------
<% tags.each do |tag| -%>
TAG: <%= tag %>
<% end -%>
SCOPE LOOKUP <%= scope.lookupvar('name') %>
SCOPE LOOKUP <%= scope.lookupvar('ipaddress_eth0') %>
<VirtualHost <%= $ipaddress_eth0 %>:80>
ServerName www.<%= $name %>.xxx.net
result:
--------------------------
TAG: railsproject
TAG: test
TAG: class
TAG: railsnode
TAG: node
TAG: dev
TAG: main
SCOPE LOOKUP test
SCOPE LOOKUP 78.xx.xx.66
<VirtualHost :80>
ServerName www..xxx.net
The call to template() is inside the define railsproject():
define railsproject($name, $uid, $gid, $userpass, $sqlpass) {
file {
"/etc/apache2/sites-available/${name}-apache":
owner => root, group => root, mode => 644,
content => template("vhosts/apache-rails-template.erb");
}
....more stuff...
}
Hmm, just tested with a simple class templatetest { file { "foo":
template("foo.erb") }}, same result. Something is messed up ;(
thanks
Paul
>
> Regards, DavidS
>
> --
> dasz.at OG Tel: +43 (0)664 2602670 Web:http://dasz.at
> Klosterneuburg UID: ATU64260999
>
> FB-Nr.: FN 309285 g FB-Gericht: LG Korneuburg
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en
-~----------~----~----~----~------~----~------~--~---