首页 > 解决方案 > Ansible win_xml 删除 xml 元素失败

问题描述

安装 iis 尝试从 applicationhost.config 中删除默认网站文档文件后,我在 ansible playbook 中运行以下任务。

  - name: Remove defaultDocument Files From applicationhost.config
    win_xml:
      path: C:\Windows\System32\inetsrv\Config\applicationHost.config
      xpath: /configuration/system.webServer/defaultDocument/files/*
      state: absent

播放失败并出现以下错误:

The full traceback is:
The property 'removed' cannot be found on this object. Verify that the property exists.
At line:162 char:21
+ ...             $result.removed += $result.removed + $removedNode.get_Out ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : PropertyNotFoundStrict

ScriptStackTrace:
at <ScriptBlock>, <No file>: line 162

fatal: [win2019-local-096]: FAILED! => {
    "changed": false,
    "msg": "Unhandled exception while executing module: The property 'removed' cannot be found on this object. Verify that the property exists."
}

标签: xmlansible

解决方案


原来这是一个问题,因为我正在使用 debug -vvvv 运行我的剧本,以便我可以调试输出。一旦我运行它而没有冗长,它就成功了。


推荐阅读