Ask Your Question

How can i replace a structure of a xml file and restart a service if neccessary

asked 2013-10-21 11:08:54 -0600

scoopex gravatar image

I would like to modify a xml structure like this:

  <authorizationStrategy class="">

The other parts of the file are also modified by the jenkins application.

What i want to do:

  • Drop all permission-nodes
  • Add a defined set of permission-nodes
  • Restart the jenkins service if the resulting ...
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2013-10-21 15:04:36 -0600

lavaman gravatar image

updated 2013-10-21 15:07:18 -0600

Augeas is the appropriate tool for this purpose. It exists to manage portions of formatted files while allowing content from other sources as well. However, the augeas resource type should be able to notify the service directly without the execs you have in there. You should probably looking at limiting the augeas commands to a certain subset of the file as described here:

Also, style-wise, you should put the changes in a var and use that in the augeas resource:

$test_changes = [ 'array', 
                  'commands' ]

augeas { 'jenkins.config':
    incl ...
edit flag offensive delete link more


That´s correct, another resource triggered the restarts :-( Thank you.

scoopex gravatar imagescoopex ( 2013-10-21 15:42:56 -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

1 follower


Asked: 2013-10-21 11:08:54 -0600

Seen: 740 times

Last updated: Oct 21 '13