Using XML module to insert new line

56 views
Skip to first unread message

shloco

unread,
Sep 29, 2023, 4:11:54 PM9/29/23
to Ansible Project
Hi folks 

I some help , I have xml as following structure 

<security-config>
<parameters>
<init-param>
<param-name>login.url</param-name>
<param-value>/login.action?os_destination=${originalurl}&amp;permissionViolation=true</param-value>
</init-param>
<init-param>
<param-name>link.login.url</param-name>
<param-value>/login.action</param-value>
</init-param>
<init-param>
<param-name>cookie.encoding</param-name>
<param-value>cNf</param-value>
</init-param>
<init-param>
<param-name>login.cookie.key</param-name>
<param-value>seraph.confluence</param-value>
</init-param>
<init-param>
<param-name>login.submit.url</param-name>
<param-value>/dologin.action</param-value>
</init-param>

<!--only basic authentication available-->
<init-param>
<param-name>authentication.type</param-name>
<param-value>os_authType</param-value>
</init-param>

<!-- Invalidate session on login to prevent session fixation attack -->
<init-param>
<param-name>invalidate.session.on.login</param-name>
<param-value>true</param-value>
</init-param>
<!-- Add names for session attributes that must not be copied to a new session when the old one gets invalidated.
Currently it is empty (i.e. all attributes will be copied). -->
<init-param>
<param-name>invalidate.session.exclude.list</param-name>
<param-value></param-value>
</init-param>
</parameters>


I need to insert the following lines inside  <parameters> </parameters>
<init-param>
<param-name>logout.url</param-name>
<param-value>http://google.com</param-value>
</init-param>

I tried the following but

- name: Test 1
community.general.xml:
path: config.xml
xpath: /security-config/parameters/init-param
add_children:
- init-param:
param-name: logout.url
param-value: http://google.com

the lines add in bottom of file like :

<init-param>
<param-name>invalidate.session.exclude.list</param-name>
<param-value/>
<init-param param-name="logout.url" param-value="http://google.com"/></init-param>



Reply all
Reply to author
Forward
0 new messages