Ask Your Question

How to remove extra white spaces in a template in puppet

asked 2016-10-31 17:43:19 -0600

Arpitha gravatar image

updated 2016-11-09 22:20:43 -0600

ramindk gravatar image

I want to put a/few values in a file using puppet but when I do the following:

<% @_zoo_cfgs.each do |zooconfig| -%>
<%=zooconfig -%>
<% end -%>

I get the below content in the file. I have a new line and a tab before the content and a new line after the content as well:

But I want the below content:

with no extra white spaces in the file before or after the value. Could anyone please let me know how could this be done? Any help will be highly appreciated.

edit retag flag offensive close merge delete


Can you put your 'got' and 'wanted' content in a 'code' block? I can't tell a difference in how it's formatted

DarylW gravatar imageDarylW ( 2016-11-02 08:36:52 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2016-11-02 08:45:07 -0600

DarylW gravatar image

I can't tell a difference with the way you have your question formatted above. I'll try to answer what I can with what I can discern..

If I recreate your above example in a single .pp file for testing, this is the result that I get.

$_zoo_cfgs = ['one','two','three']

$content = inline_template('<% @_zoo_cfgs.each do |zooconfig| -%>
<%=zooconfig -%>
<% end -%>')


and the output

$ puppet apply test.pp
Notice: Scope(Class[main]): onetwothree
Notice: Compiled catalog for myhost in environment production in 0.05 seconds
Notice: Finished catalog run in 2.36 seconds

I see the entirety of the output on a single line, no whitespace before or after. Do you have an extra newline before or after the code that you have shown above? any whitespace in the template file outside of erb templating indicators <% ... %> will show up in the file?

edit flag offensive delete link more

answered 2016-11-07 08:22:14 -0600

<%= @_zoo_cfgs.join('') -%>
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2016-10-31 17:43:19 -0600

Seen: 573 times

Last updated: Nov 07 '16