Ask Your Question

Augeas or alternative XML modification on Windows

asked 2014-01-13 06:02:20 -0600

updated 2014-01-13 06:05:14 -0600

I need to have my Puppet manifests modify XML files, and Augeas seems to be the perfect tool for that. However, the target machines are Windows, and Augeas is not available on there :-(

  • How can I get Augeas up running on Windows? I do not have sufficient skills to compile the whole thing from scratch and resolve dependencies, etc., but perhaps others have tried to walk down that path?
  • Are there any alternative solutions for Puppet at Windows that allow me to specify an XML file, an XPATH expression, and a value so that the XML file can be patched?
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2014-01-14 02:55:28 -0600

As @martezr also suggested I ended up writing a powershell script. I'm including it here in case anyone else is interested:

# The following line makes it possible to add an -Verbose arg. when invoking this script

param (
[string] $filename = $(throw "filename is a required parameter"),
[string] $xpath    = $(throw "xpath is a required parameter"),
[string] $value    = $(throw "value is a required parameter")

write-verbose "Received arguments:" 
write-verbose "filename:    ""$filename"""
write-verbose "xpath:       ""$xpath"""
write-verbose "value:       ""$value""`n"

$xml = [xml](Get-Content $filename)

try   {$nodes = $xml.SelectNodes($xpath)}
catch {}

if ($nodes.count -eq 0) {write-verbose "No match in XML file"}

    foreach ($node in ...
edit flag offensive delete link more


This works great, but I found I had to invert the logic.

spuder gravatar imagespuder ( 2015-06-29 12:14:07 -0600 )edit

I re-wrote much of this script to be able to modify attributes and text. Sharing for posterity.

spuder gravatar imagespuder ( 2015-06-29 15:23:07 -0600 )edit

answered 2014-01-13 19:27:47 -0600

An alternative option would be utilizing powershell through the exec puppet resource

edit flag offensive delete link more


Yes, quite right, and that was actually exactly what I ended up doing yesterday. It wasn't even that difficult 'cause powershell has very nice support for XML data.

MikaelBarfred gravatar imageMikaelBarfred ( 2014-01-14 02:45:55 -0600 )edit

Your Answer

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

Add Answer

Question Tools



Asked: 2014-01-13 06:02:20 -0600

Seen: 2,263 times

Last updated: Jan 14 '14