- name:ensure //logger/level value attributes are set to debug (idempotency)
win_xml:
path:"{{ win_output_dir }}\\log4j.xml"
xpath:'//logger/level[@value="error"]'
type:attribute
attribute:value
fragment:debug
count:yes
register:logger_level_value_attrs_again
- name:verify //logger/level value attributes again (idempotency)
assert:
that:
- logger_level_value_attrs_again.count == 0
- logger_level_value_attrs_again.changed == false
- logger_level_value_attrs_again.msg == 'The supplied xpath did not match any nodes. If this is unexpected, check your xpath is valid for the xml file at supplied path.'
# multiple text nodes
- name:ensure test books.xml is present
win_copy:
src:books.xml
dest:'{{ win_output_dir }}\books.xml'
- name:demonstrate multi text replace by replacing all title text elements
win_xml:
path:'{{ win_output_dir }}\books.xml'
xpath://works/title
type:text
fragment:_TITLE_TEXT_REMOVED_BY_WIN_XML_MODULE_
count:yes
register:multi_text
- name:verify multi text change
assert:
that:
- multi_text.changed == true
- multi_text.count == 5
- multi_text.msg == 'text changed'
- name:demonstrate multi text replace by replacing all title text elements again (idempotency)
win_xml:
path:'{{ win_output_dir }}\books.xml'
xpath://works/title
type:text
fragment:_TITLE_TEXT_REMOVED_BY_WIN_XML_MODULE_
count:yes
register:multi_text_again
- name:verify multi text again change (idempotency)
assert:
that:
- multi_text_again.changed == false
- multi_text_again.count == 5
- multi_text_again.msg == 'not changed'
# multiple element
#- name: ensure a fresh test books.xml is present
# win_copy:
# src: books.xml
# dest: '{{ win_output_dir }}\books.xml'
- name:demonstrate multi element should append new information element from fragment
win_xml:
path:'{{ win_output_dir }}\books.xml'
xpath://works/title
type:element
fragment:<information>This element added by ansible</information>
count:yes
register:multi_element
- name:verify multi element
assert:
that:
- multi_element.changed == true
- multi_element.count == 5
- multi_element.msg == 'element changed'
- name:demonstrate multi element unchanged (idempotency)
win_xml:
path:'{{ win_output_dir }}\books.xml'
xpath://works/title
type:element
fragment:<information>This element added by ansible</information>