What can I do with erb templates in Puppet?

44 views
Skip to first unread message

Renu Chuppala

unread,
Nov 22, 2014, 12:24:43 AM11/22/14
to puppet...@googlegroups.com
Please provide me steps to modify the config files using templates in WINDOWS

Giacomo Vacca

unread,
Nov 22, 2014, 11:36:46 AM11/22/14
to puppet...@googlegroups.com
Take a look at Windows-related modules on the Forge:https://forge.puppetlabs.com/tags/windows

Spencer Krum

unread,
Nov 22, 2014, 1:21:07 PM11/22/14
to puppet...@googlegroups.com
Puppet provides the erb templating system so you can do variable expansion and replacement in your templates. The templates are processed on the puppet master and sent to the client (windows) as text. The windows client then replaces the old config file with the new one from the template.

Step 1) Copy an existing config file into your puppet module's template section. Name it config_file.erb

Step 2) Replace variables in the config file with puppet facts or variables from your manifests

Example:
If a line said:
listen_address = 192.168.0.5
You would change it to:
listen_address = <%= $::ipaddress %>

Step 3) Run Puppet on the client. Nothing should change on the first client, but all subsequent clients will be easier to configure.

Hope this helps,
Spencer

On Sat, Nov 22, 2014 at 12:24 AM, Renu Chuppala <rchu...@gmail.com> wrote:
Please provide me steps to modify the config files using templates in WINDOWS

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/45e3f9da-31e0-4311-8a9f-931918547ce8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Spencer Krum
(619)-980-7820

Rob Reynolds

unread,
Nov 24, 2014, 5:55:47 PM11/24/14
to puppet...@googlegroups.com
Short of what Spencer has pointed out, there is not a module out there (to my knowledge) that will let you edit xml files in place with XPath type settings on Windows. Yet. I'm sure this is a paint point for quite a few folks that would want to be able to update an XML file in place.  Augeas would be a good way of doing this if/when it started supporting Windows. Another would be a module specifically for this use case.


For more options, visit https://groups.google.com/d/optout.



--
Rob Reynolds
Developer, Puppet Labs

Join us at PuppetConf 2015, October 5-9 in Portland, OR - http://2015.puppetconf.com/
Register early to save 40%!

Spencer Krum

unread,
Nov 24, 2014, 7:47:03 PM11/24/14
to puppet...@googlegroups.com
Maybe file_line hacks?


For more options, visit https://groups.google.com/d/optout.



--
Spencer Krum
(619)-980-7820

Rob Reynolds

unread,
Nov 24, 2014, 7:49:31 PM11/24/14
to puppet...@googlegroups.com


On Mon, Nov 24, 2014 at 1:46 PM, Spencer Krum <krum.s...@gmail.com> wrote:
Maybe file_line hacks?

Maybe? I don't know. I threw together a thought earlier today on what this might look like as a custom type/provider - https://gist.github.com/ferventcoder/3e8cf9ff046fef16ad45
 

For more options, visit https://groups.google.com/d/optout.

Felix Frank

unread,
Nov 24, 2014, 10:38:47 PM11/24/14
to puppet...@googlegroups.com
On 11/24/2014 08:46 PM, Spencer Krum wrote:
> Maybe file_line hacks?

Not unlike exec { 'sed -i' }, I consider file_line to be a last resort
option to managing file contents. Avoid if at all possible.

Just my 2c.
Reply all
Reply to author
Forward
0 new messages