Managing multiline xml attributes with augeas

28 views
Skip to first unread message

Francois Herbert

unread,
Oct 21, 2016, 12:31:46 PM10/21/16
to Puppet Users
I'm trying to use the augeas resource type to manage a multiline attribute in an xml file. It looks like this:

<resolver:AttributeResolver
        xmlns:resolver="urn:mace:shibboleth:2.0:resolver" 
        xmlns:pc="urn:mace:shibboleth:2.0:resolver:pc"
        xmlns:ad="urn:mace:shibboleth:2.0:resolver:ad" 
        xmlns:dc="urn:mace:shibboleth:2.0:resolver:dc"
        xmlns:enc="urn:mace:shibboleth:2.0:attribute:encoder" 
        xmlns:sec="urn:mace:shibboleth:2.0:security"
        xsi:schemaLocation="urn:mace:shibboleth:2.0:resolver http://shibboleth.net/schema/idp/shibboleth-attribute-resolver.xsd
                            urn:mace:shibboleth:2.0:resolver:pc http://shibboleth.net/schema/idp/shibboleth-attribute-resolver-pc.xsd
                            urn:mace:shibboleth:2.0:resolver:ad http://shibboleth.net/schema/idp/shibboleth-attribute-resolver-ad.xsd
                            urn:mace:shibboleth:2.0:resolver:dc http://shibboleth.net/schema/idp/shibboleth-attribute-resolver-dc.xsd
                            urn:mace:shibboleth:2.0:attribute:encoder http://shibboleth.net/schema/idp/shibboleth-attribute-encoder.xsd
                            urn:mace:shibboleth:2.0:security http://shibboleth.net/schema/idp/shibboleth-security.xsd">

 As you can see, the xsi:schemaLocation is a multine value attribute. Using augtool, I can manually update this attribute using the Xml.lns lens and running:

set /files/attribute-resolver.xml/resolver:AttributeResolver/#attribute/xsi:schemaLocation 'urn:mace:shibboleth:2.0:resolver http://shibboleth.net/schema/idp/shibboleth-attribute-resolver.xsd\n        urn:mace:shibboleth:2.0:resolver:pc http://shibboleth.net/schema/idp/shibboleth-attribute-resolver-pc.xsd'


But using the augeas resource type I can't seem to get it right. Any of my '\n' are escaped so what ends up in the xml file is '\\n' which is incorrect. My manifest looks like this:
$changes = 'set resolver:AttributeResolver/#attribute/xsi:schemaLocation "urn:mace:shibboleth:2.0:resolver http://shibboleth.net/schema/idp/shibboleth-attribute-resolver.xsd\n        urn:mace:shibboleth:2.0:resolver:pc http://shibboleth.net/schema/idp/shibboleth-attribute-resolver-pc.xsd"


augeas
{ "attributeresolver_attributes_${name}":

    lens    => 'Xml.lns',

    incl    => $configfile,

    changes => $changes,

  }

I've tried changing the double quotes around to single quotes but still can't get it to write the '\n' correctly.

Any ideas?

Reply all
Reply to author
Forward
0 new messages