我正在尝试设置一个任务,该任务将向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。
发布于 2019-07-06 00:56:07
Cudos转到@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"我没有理解命名空间部分,即使我已经尝试过了。
https://stackoverflow.com/questions/56874065
复制相似问题