我正在尝试设置一个任务,该任务将向XML元素添加新属性(如果缺少)。我的XML文件很大,因此包含了它的一个片段:
<subsystem xmlns="urn:jboss:domain:undertow:7.0" default-server="default-server" default-virtual-host="default-host" default-servlet-container="default" default-security-domain="other">
<buffer-cache name="default"/>
<server name="default-server">
<http-listener name="default" socket-binding="http" redirect-socket="https" enable-http2="true"/>
<https-listener name="https" socket-binding="https" security-realm="ApplicationRealm" enable-http2="true"/>
<host name="default-host" alias="localhost">
<location name="/" handler="welcome-content"/>
<http-invoker security-realm="ApplicationRealm"/>
</host>
</server>
<servlet-container name="default">
<jsp-config/>
<websockets/>
</servlet-container>
<handlers>
<file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
</handlers>
</subsystem>
Ansible任务是
- name: Turn on proxy address forwarding support for http
xml:
path: /opt/keycloak-quickstarts-latest/keycloak-server/standalone/configuration/standalone.xml
xpath: //http-listener
value: "true"
attribute: "proxy-address-forwarding"
我的问题是上述任务失败,并显示Can't process Xpath / in order to spawn nodes!
。我已经尝试使用Ansible 2.7.8和2.8.1。
答案 0 :(得分:0)
对@ daniel-haley和@ matthew-l-daniel表示敬意,以下任务有效:
---
path: /opt/keycloak-quickstarts-latest/keycloak-server/standalone/configuration/standalone.xml
xpath: //undertow:http-listener
value: "true"
attribute: "proxy-address-forwarding"
namespaces:
domain: "urn:jboss:domain:8.0"
undertow: "urn:jboss:domain:undertow:7.0"
即使我尝试过它,也无法理解名称空间部分。