【问题标题】:Ansible get_url module: Unable to find a checksum for fileAnsible get_url 模块:找不到文件的校验和
【发布时间】:2020-11-11 16:30:59
【问题描述】:

我正在尝试使用以下方法获取 ActiveMQ Artemis:


- name: Download the ActiveMQ Artemis artifact
  get_url:
    url: "https://www.apache.org/dyn/closer.cgi?filename=activemq/activemq-artemis/{{ artemis_version }}/apache-artemis-{{ artemis_version }}-bin.tar.gz&action=download"
    dest: "/tmp/apache-artemis-{{ artemis_version }}-bin.tar.gz"
    #with fixed checksumm it works but breaks the idea of the version to be a variable.
    #checksum: "sha512:4990a6b742b08bff6a4c7b310d2610565b08a2a02e1a7aec065460d16f8a6fe3d4fe91a8040839f93d7c2eab09fd6a79848fb130f9820559ee3e81dcf8d51ead"
    #Getting "Unable to find a checksum for file 'closer.cgi' in 'https://downloads.apache.org/activemq/activemq-artemis/2.16.0/apache-artemis-2.16.0-bin.tar.gz.sha512'"
    checksum: "sha512:https://downloads.apache.org/activemq/activemq-artemis/{{ artemis_version }}/apache-artemis-{{ artemis_version }}-bin.tar.gz.sha512"
    #Also getting: fatal: [dev-broker-01]: FAILED! => {"changed": false, "dest": "/tmp/apache-artemis-2.16.0-bin.tar.gz", "elapsed": 0, "msg": "Request failed: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:618)>", "url": "https://www.apache.org/dyn/closer.cgi?filename=activemq/activemq-artemis/2.16.0/apache-artemis-2.16.0-bin.tar.gz&action=download"}
    validate_certs: no

并得到:“无法在 'https://downloads.apache.org/activemq/activemq-artemis/2.16.0/apache-artemis-2.16.0-bin 中找到文件 'closer.cgi' 的校验和.tar.gz.sha512'" 它没有从 dest 获取文件名:“/tmp/apache-artemis-{{ artemis_version }}-bin.tar.gz”

在验证证书时也遇到了一些问题。

有什么办法可以解决这两个问题吗?

【问题讨论】:

  • 我认为您处于某种代理环境中,因此您需要将代理的 CA 添加到远程计算机的信任库中
  • 我在代理后面,但在更改为 url 后:“downloads.apache.org/activemq/activemq-artemis{{ artemis_version }}/apache-artemis-{{ artemis_version }}-bin.tar.gz” 我没有有这个问题了。谢谢。

标签: ansible checksum geturl


【解决方案1】:

该错误似乎表明它正在寻找文件closer.cgi 的校验和,而不是实际的tar.gz 文件。校验和 URL 中的文件名是:apache-artemis-2.16.0-bin.tar.gz

另一种指定校验和的方法是只提供校验和字符串(不带文件名)。虽然为此我们需要在获得它之前提出几个任务。

如下所示:

- uri:
    url: "https://downloads.apache.org/activemq/activemq-artemis/{{ artemis_version }}/apache-artemis-{{ artemis_version }}-bin.tar.gz.sha512"
    return_content: true
  register: url_sha512
- set_fact:
    artemis_checksum: "{{ url_sha512.content.split('  ')[0] }}"      # there are 2 spaces
- get_url:
    url: "https://www.apache.org/dyn/closer.cgi?filename=activemq/activemq-artemis/{{ artemis_version }}/apache-artemis-{{ artemis_version }}-bin.tar.gz&action=download"
    dest: "/tmp/apache-artemis-{{ artemis_version }}-bin.tar.gz"
    checksum: "sha512:{{ artemis_checksum }}"
    # I was able to download without having below parameter
    # validate_certs: no

更新:

当站点目录无法浏览,文件必须从镜像 URL 中获取时,这种方法很有用。

【讨论】:

  • 我喜欢这个解决方案作为一种解决方法。我可以使用它:url:“downloads.apache.org/activemq/activemq-artemis{{ artemis_version }}/apache-artemis-{{ artemis_version }}-bin.tar.gz”,即与校验和中的相同 URL。如果我们必须使用查找镜像的 URL,也许可以编辑您的答案以说明这只是一个解决方案,因此我可以将其标记为解决方案。
  • 这很好。我不知道文件的直接 URL 可用。如果是这样,那绝对是可取的。我更新了我的答案以解释它何时有用。
  • 谢谢。我最终使用了您的 Keycloak 解决方案,因为校验和上没有文件名。还开了一张票,所以他们将来会添加它 - issues.redhat.com/browse/KEYCLOAK-16251
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-06-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-08-01
相关资源
最近更新 更多