首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用ansible XML设置节点属性

无法使用ansible XML设置节点属性
EN

Stack Overflow用户
提问于 2019-07-03 23:59:49
回答 1查看 647关注 0票数 1

我正在尝试设置一个任务,该任务将向XML元素添加新属性(如果缺少)。我的XML文件非常大,所以我包含了它的一个片段:

代码语言:javascript
复制
        <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任务是

代码语言:javascript
复制
- 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。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-07-06 00:56:07

Cudos转到@daniel haley和@matthew-l-daniel,执行以下任务:

代码语言:javascript
复制
---
          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"

我没有理解命名空间部分,即使我已经尝试过了。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56874065

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档