Ask Your Question
1

ERB - don't output variable value if current config file has a value?

asked 2015-06-05 04:38:00 -0500

qwerty_face gravatar image

updated 2015-06-05 04:38:48 -0500

To clarify the title there is a config file for some application that I have used Puppet to deploy, however the application encrypts certain variables at service startup rather than the plaintext that I am passing in through Puppet. Each time Puppet runs it wants to replace these hashed/encrypted strings.

Is there a way to tell Ruby/ERB/Puppet not to output from the <%= @myVar %> if there is already a string in that location in the configuration file already present on the server?

Hopefully that makes sense.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-06-05 11:31:56 -0500

banjer gravatar image

As you are seeing now, when deploying files using the ol' file resource, puppet will replace your file with whatever it generates, i.e. a static file from source or dynamic from content.

For your situation, where you only want to update specific lines in a file without disturbing the rest of the contents, I'd recommend using either augeas or something simpler like file_line.

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: 2015-06-05 04:38:00 -0500

Seen: 197 times

Last updated: Jun 05 '15