我正在尝试使用puppet在我的系统上写一个文件,这是声明:
file { '/etc/salt/grains':
ensure => present,
content => template('pp_salt_manager/grains.erb'),
}
这是我真正简短的.erb文件:
<% @machine_info.each do |key, value| %>
<%= "#{key}: #{value}" %>
<% end %>
作为参考,这是machine_info:
$machine_info = {'deployment' => 'c7', 'local' => 'US', 'env' => 'stable'}
我的问题是,这是输出文件:
_ # Empty line
deployment: c7
_ # Another empty line
local: US
_ # Once again, an empty line
env: stable
如何让它看起来像这样:
deployment: c7
local: US
env: stable
提前致谢!
答案 0 :(得分:5)
使用“ - %&gt;”而不是“%&gt;”关闭可能会有所帮助:
<% @machine_info.each do |key, value| -%>
<%= "#{key}: #{value}" %>
<% end -%>
以下是puppet文档的链接: https://docs.puppetlabs.com/guides/templating.html#trim-mode