【问题标题】:Modify curl command to ansible uri module将 curl 命令修改为 ansible uri 模块
【发布时间】:2023-02-04 05:14:31
【问题描述】:

我一直在尝试通过 ansible uri 模块执行以下 curl 命令 (网址、用户名和密码已更改,只是为了保护隐私)

curl -u "username:password" "https://company.abc.apps.company.eu/qps/rest/1.0/download/ca/downloadbinary/" --header "Content-Type: application/xml" --data-raw "<ServiceRequest><data><DownloadBinary><platform>LINUX_UBUNTU</platform><architecture>ARM_64</architecture></DownloadBinary></data></ServiceRequest>" -o file.deb

我目前的剧本任务是:

- name: Download Binaries?
  ansible.builtin.uri:
    url: https://company.abc.apps.company.eu/qps/rest/1.0/download/ca/downloadbinary/
    url_username: username
    url_password: password
    force_basic_auth: true
    headers:
      Content-Type: application/xml
    body_format: raw 
    body: "<ServiceRequest><data><DownloadBinary><platform>LINUX_UBUNTU</platform><architecture>ARM_64</architecture></DownloadBinary></data></ServiceRequest>"
    dest: file.deb

我从该站点收到的错误消息如下:

<?xml version="1.0" encoding="UTF-8"?>
<ServiceResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://companty.abc.apps.company.eu/qps/xsd/1.0/ca/downloadbinary.xsd">
  <responseCode>OPERATION_NOT_SUPPORTED</responseCode>
  <responseErrorDetails>
    <errorMessage>Operation not supported for this object using this method.</errorMessage>
    <errorResolution>Refer to the QPS guide for authorized operation for this domain object.</errorResolution>
  </responseErrorDetails>
</ServiceResponse>

有谁知道我在这里做错了什么?

感谢:D

【问题讨论】:

    标签: curl ansible uri qualys


    【解决方案1】:

    如果有人想知道,这是一个 POST 方法。所以,我需要添加 method: POST 作为模块的一部分。

    - name: Download Binaries?
      ansible.builtin.uri:
        url: https://company.abc.apps.company.eu/qps/rest/1.0/download/ca/downloadbinary/
        url_username: username
        url_password: password
        method: POST
        force_basic_auth: true
        headers:
          Content-Type: application/xml
        body_format: raw 
        body: "<ServiceRequest><data><DownloadBinary><platform>LINUX_UBUNTU</platform><architecture>ARM_64</architecture></DownloadBinary></data></ServiceRequest>"
        dest: file.deb
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-30
      • 2014-08-01
      • 1970-01-01
      相关资源
      最近更新 更多