augeas for setting URIEncoding variable in tomcat, server.xml file.

611 views
Skip to first unread message

Pradeep Reddy

unread,
May 7, 2014, 8:40:44 PM5/7/14
to puppet...@googlegroups.com
Hi Team,

I am using below info in my manifest.  URIEncoding="UTF-8" is not present in server.xml.  Trying to inject URIEncoding using below augeas syntax.

 augeas { 'update_server.xml':
    lens            => 'Xml.lns',
    incl             => "/opt/apphome/apache-tomcat-7.0.53/conf/server.xml",
    context        => '/opt/apphome/apache-tomcat-7.0.53/conf/server.xml'/Connector port="8080"',
    changes       => flatten([
      "set Server/Service/Connector[1][#attribute/redirectport='8443']/#attribute/URIEncoding UTF-8",]),
  }

After executing getting below information.  URIEncoding="UTF-8" is not getting appended in server.xml.

Could someone please check and let me know, wehther i am using a wrong syntax.


Debug: Augeas[update_server.xml](provider=augeas): Opening augeas with root /, lens path , flags 64
Debug: Augeas[update_server.xml](provider=augeas): Augeas version 1.0.0 is installed
Debug: Augeas[update_server.xml](provider=augeas): Will attempt to save and only run if files changed
Debug: Augeas[update_server.xml](provider=augeas): sending command 'set' with params ["\"${brand::tomcat_installdir}/${brand::tomcat_version}/conf/server.xml\"/Connector port=\"8080\"/Server/Service/Connector[1][#attribute/redirectport='8443']/#attribute/URIEncoding", "UTF-8"]
Debug: Augeas[update_server.xml](provider=augeas): Skipping because no files were changed
Debug: Augeas[update_server.xml](provider=augeas): Closed the augeas connection

Regards,
Pradeeo.

Kenton Brede

unread,
May 8, 2014, 4:25:50 PM5/8/14
to puppet...@googlegroups.com
Try something like this:


augeas { 'update_server.xml':
  lens        => 'Xml.lns',
  context   => '/files/opt/apphome/apache-tomcat-7.0.53/conf/server.xml/Server/Service/Connector[*]/#attribute/',   
  incl         => "/opt/apphome/apache-tomcat-7.0.53/conf/server.xml",
  changes => ['ins URIEncoding after port[. = "8080"]',
                       'set URIEncoding UTF-8',
  ],   
}

The "context" is actually the path as augeas sees it.  I wildcarded "Connector" because there can be more than one.  For example "Connector[1]" and "Connector[2]."

For "changes" its actually doing this:

Insert URIEncoding after, Connector with "port="8080", and set URIEncoding to UTF-8.

It helps to use augtool if you haven't.  Try something like:

$ augtool --transform "Xml.lns incl /opt/apphome/apache-tomcat-7.0.53/conf/server.xml"
augtool> print /files/opt/apphome/apache-tomcat-7.0.53/conf/server.xml
augtool> print /files/opt/apphome/apache-tomcat-7.0.53/conf/server.xml/Server/Service/Connector[*]

Kent




--
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/6a327ad9-347a-493a-b32a-89b46645e22b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Kent Brede




Pradeep Reddy

unread,
May 8, 2014, 4:29:26 PM5/8/14
to puppet...@googlegroups.com

Thx Kent.

You received this message because you are subscribed to a topic in the Google Groups "Puppet Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/puppet-users/9h5JjWZpOYM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/CA%2BnSE3-%3D_xA2eP65yy95o2%3DZGEkH4ZhSj%3DhhUUWb%3Dvm5wMNpww%40mail.gmail.com.

Kenton Brede

unread,
May 8, 2014, 4:52:00 PM5/8/14
to puppet...@googlegroups.com
And that's not going to work so hot because you're going to keep getting this on every run:

Error: /Stage[main]/Test_module/Augeas[update_server.xml]: Could not evaluate: Saving failed, see debug

To avoid this you can use an "onlyif." 

onlyif  => 'match URIEncoding[. = "UTF-8"] size == 0',

This will match any URIEncoding="UTF-8" in any "Connector" section.  So it won't work properly if you already have URIEncoding="UTF-8" defined for another "Connector."

What a person needs to do is match port="8080" and URIEncoding="UTF-8."  But I'm pressed for time and need to get going.

Hopefully this will get you down the road a bit further.  Someone else may chime in here with a better solution.
Kent



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



--
Kent Brede




Reply all
Reply to author
Forward
0 new messages