Xml_set_value fonction problem

10 views
Skip to first unread message

thierry thunot

unread,
Jan 31, 2025, 2:18:28 AMJan 31
to help-cfengine
Hello everyone,
I am having difficulty editing an xml file.

In particular that of the wazuh agent to be deployed automatically by cf.
I need to set a tag value. I use the xml_set_value function which seems very simple to use.

The only problem is that the basic Wazuh configuration file has two sections with the same tag. therefore, the xml_set_status function does not work.

....
vars:
#                "adresse_wazuh_manager" string => "10.54.1.40";
                "fic_conf_wazuh"        string => "/var/ossec/etc/ossec.conf";
files:
        "${fic_conf_wazuh}"
                perms      => mog("550","root","root"),
                edit_xml   => xml_set_value("10.54.1.40","/ossec_config/client/server/address"),
                classes    => results("bundle","relance_wazuh_agent"),
                comment    => "/?\ --------- Configuration wazuh agent";
......




file to edit:

!--
  Wazuh - Agent - Default configuration for debian 12
  More info at: https://documentation.wazuh.com
  Mailing list: https://groups.google.com/forum/#!forum/wazuh
-->

<ossec_config>
  <client>
    <server>
      <address>XXXXXX</address>
      <port>1514</port>
      <protocol>tcp</protocol>
    </server>
    <config-profile>debian, debian12</config-profile>
    <notify_time>10</notify_time>
    <time-reconnect>60</time-reconnect>
    <auto_restart>yes</auto_restart>
    <crypto_method>aes</crypto_method>
  </client>
....
 </ossec_config>

<ossec_config>
  <localfile>
    <log_format>journald</log_format>
    <location>journald</location>
  </localfile>
......
</ossec_config>

Thank's for your help

Lars Erik Wik

unread,
Jan 31, 2025, 4:16:18 AMJan 31
to help-cfengine
Hi there,

What is the error message you get? Is it perhaps `parser error : Extra content at the end of the document`?

The XLM that you reference does not look valid. Not because of duplicate tags. However, it breaks the following rule: "XML documents must contain one root element that is the parent of all other elements". See https://www.w3schools.com/xml/xml_syntax.asp.

Hope this helps :)

thierry thunot

unread,
Feb 3, 2025, 7:50:38 AMFeb 3
to help-cfengine
That's exactly it, the file is malformed
I will share it with the Wazuh developers

Thank's
Reply all
Reply to author
Forward
0 new messages