accessing out of class/scope variables in template

閲覧: 3 回
最初の未読メッセージにスキップ

Matt Zagrabelny

未読、
2019/08/16 10:32:262019/08/16
To: puppet...@googlegroups.com
Hello,

I'm running puppet 5.5 OSE.

I've got a class foo:

class foo {
    $bar = 'hi'
}

class foo::configure {
    file { '/tmp/foo.conf':
        content => template('foo/foo.conf.erb'),
    }
}

and then in the template:

<%= scope['foo::bar'] %>

but suppose I want to access an out of class variable:

<%= scope['baz::qux'] %>

That does not seem to work. Is there any way to access out of class variables in a template?

Thanks for any help!

-m

Henrik Lindberg

未読、
2019/08/16 13:15:022019/08/16
To: puppet...@googlegroups.com
That should work as long as `baz::qux` has been evaluated before
you evaluate this template.

Can also highly recommend switching to EPP (templates in Puppet
Language) instead of ERB (tempaltes in Ruby).

Your template would then be:

<%= $foo::bar %>

Best
- henrik

--

Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/

全員に返信
投稿者に返信
転送
新着メール 0 件