细节:

细节:

谁能告诉我为什么这把旧钥匙为我工作与apt-key模块ansible-playbook这把新钥匙没有(404)?

初始密钥在短时间内有效(当我开发这些脚本时),但当它过期时(2019-12-06),apt 的 update_cache(正确地)开始失败,并且建议切换到新密钥,我无法使用该apt-key模块。它没有 ansible-playbook 也能正常工作:

$ wget -O- https://build.opensuse.org/projects/home:jgeboski/public_key | sudo apt-key add -

在浏览器中查看这两个地址时,它们的行为似乎大致相同。不过标头略有不同。文件扩展名也是如此。

细节:

这是我的脚本的相关部分。其他一些apt-keyapt-repositoryapt用途都运行良好。

- name: "Install purple-facebook: key"
  become: yes
  apt_key:
#    url: https://build.opensuse.org/projects/home:jgeboski/public_key
    url: https://download.opensuse.org/repositories/home:jgeboski/xUbuntu_18.04/Release.key

- name: "Install purple-facebook: repo"
  become: yes
  apt_repository:
    repo: "deb https://download.opensuse.org/repositories/home:/jgeboski/xUbuntu_18.04/ /"

- name: "Install purple-facebook: package"
  apt:
    pkg: purple-facebook

如果我使用新密钥,它将会 404。运行的所有输出都带有-vvvv标志。

fatal: [localhost]: FAILED! => {
    "changed": false, 
    "invocation": {
        "module_args": {
            "data": null, 
            "file": null, 
            "id": null, 
            "key": null, 
            "keyring": null, 
            "keyserver": null, 
            "state": "present", 
            "url": "https://build.opensuse.org/projects/home:jgeboski/public_key", 
            "validate_certs": true
        }
    }, 
    "msg": "Failed to download key at https://build.opensuse.org/projects/home:jgeboski/public_key: HTTP Error 404: Not Found"
}

如果我使用旧密钥,它首先会失败update_cache: yes(这是的默认设置apt-repository)。

The full traceback is:
WARNING: The below traceback may *not* be related to the actual failure.
  File "/tmp/ansible_apt_repository_payload_drREvW/ansible_apt_repository_payload.zip/ansible/modules/packaging/os/apt_repository.py", line 548, in main
  File "/usr/lib/python2.7/dist-packages/apt/cache.py", line 559, in update
    raise FetchFailedException(e)

fatal: [localhost]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "codename": null,
            "filename": null,
            "install_python_apt": true,
            "mode": null,
            "repo": "deb http://download.opensuse.org/repositories/home:/jgeboski/xUbuntu_18.04/ /",
            "state": "present",
            "update_cache": true,
            "validate_certs": true
        }
    },
    "msg": "apt cache update failed"
}

背景:

我正在自动化个人电脑设置,出于实际原因,也为了了解有关 Ansible 和 Ansible-playbooks 的更多信息。

谢谢!

答案1

解决方案是使用更完整的地址。

我获得的初始 URL:

https://build.opensuse.org/projects/home:jgeboski/public_key

作品:

https://build.opensuse.org/projects/home:jgeboski/public_key.pub

答案2

您可以使用选项运行剧本-vvv,这将为您提供有关出了什么问题的更多线索,另一个选项是添加到将忽略证书验证的validate_certs: no任务中。name: "Install purple-facebook: key"

相关内容