Ask Your Question
1

How to remove extra white spaces in a template in puppet

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

Arpitha gravatar image

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

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:

server.1=a1-dev-mem333.lab.lynx-connected.com:2888:3888

But I want the below content:

 server.1=a1-dev-mem333.lab.lynx-connected.com:2888:3888

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

Comments

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 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
0

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

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.

#test.pp
$_zoo_cfgs = ['one','two','three']

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

notice($content)

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
0

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

<%= @_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

Stats

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

Seen: 196 times

Last updated: Nov 07 '16