我正在使用(开源) puppet 3.8.5和未来的解析器。
在epp文件中,我这样说:
<%= $telegraf_mysql %>
<%= $telegraf_mysql == true %>
<% if $telegraf_mysql == true { -%>
yes, my sql
<% } else { -%>
no
<% } -%>如果我将$telegraf_mysql设置为false,我会看到
false
false
no但是如果我将$telegraf_mysql设置为true,我会看到
true
false
no在我期望看到的地方
true
true
yes, my sql有什么建议吗?我是不是误解了语法?在3.8和future中的语法是否与在4中不同,但我读到的文档并没有反映这一点?
更新
该值是在hiera中设置的,因此:
telegraf:
monitor_mysql: false然后在puppet (.pp文件)中这样:
$telegraf = hiera('telegraf')
$telegraf_mysql = $telegraf['monitor_mysql']发布于 2017-08-03 18:32:52
我不能重现这个:
# init.pp
class foo () {
file { '/tmp/foo':
ensure => file,
content => epp('foo/mytemplate.epp', {'telegraf_mysql' => false}),
}
file { '/tmp/bar':
ensure => file,
content => epp('foo/mytemplate.epp', {'telegraf_mysql' => true}),
}
}
include foo和
# mytemplate.epp
<%= $telegraf_mysql %>
<%= $telegraf_mysql == true %>
<% if $telegraf_mysql == true { -%>
yes, my sql
<% } else { -%>
no
<% } -%>然后
$ bundle exec puppet -V
3.8.5
$ bundle exec puppet apply manifests/init.pp --modulepath=/Users/alexharvey/git/modules/ --parser=future
...
$ cat /tmp/{foo,bar}
false
false
no
true
true
yes, my sql然后
$ PUPPET_GEM_VERSION=5.0.1 bundle update
...
$ bundle exec puppet apply manifests/init.pp --modulepath=/Users/alexharvey/git/modules/
Notice: Compiled catalog for alexs-macbook-pro-2.local in environment production in 0.07 seconds
Notice: Applied catalog in 0.03 seconds(未应用任何更改。)
https://stackoverflow.com/questions/45480678
复制相似问题