ansible-playbook:“无法更新缓存:未知原因”

问题描述 投票:0回答:2

我正在尝试部署

kypo
网络靶场并遵循 其官方指南。使用
ansible-playbook
部署整个范围时,我卡在上面的错误:

TASK [docker : install prerequisites] ******************************************************************
fatal: [192.168.211.208]: FAILED! => {"changed": false, "msg": "Failed to update apt cache: unknown reason"}

我已经手动检查了

apt-get update
最初给我的通知:

N: Skipping acquire of configured file 'stable/binary-i386/Packages' as repository 'https://download.docker.com/linux/ubuntu focal InRelease' doesn't support architecture 'i386'

我按照this添加

[amd=64] to repository
清除了错误。现在
apt-get update
运行时没有任何警告或错误,但是 ansible-playbook 不断产生这个错误。

我改变了冗长级别并得到:

fatal: [192.168.211.208]: FAILED! => {
    "changed": false,
    "invocation": {
       "module_args": {
            "allow_unauthenticated": false,
            "autoclean": false,
            "autoremove": false,
            "cache_valid_time": 0,
            "deb": null,
            "default_release": null,
            "dpkg_options": "force-confdef,force-confold",
            "force": false,
            "force_apt_get": false,
            "install_recommends": null,
            "name": [
                "apt-transport-https",
                "ca-certificates"
            ],
            "only_upgrade": false,
            "package": [
                "apt-transport-https",
                "ca-certificates"
            ],
            "policy_rc_d": null,
            "purge": false,
            "state": "present",
            "update_cache": true,
            "update_cache_retries": 5,
            "update_cache_retry_max_delay": 12,
            "upgrade": null
        }
    },
    "msg": "Failed to update apt cache: unknown reason"
 }

我该如何解决这个问题?

ansible apt-get package-management
2个回答
2
投票

在 Kypo CRP 中,在播放 ansible 剧本时,错误实际上来自 openstack 的一个实例,我通过增加命令的冗长程度发现了这个

-vvvv
。主机一切正常。所以我寻找实例的变化,根本原因是没有互联网访问。一旦我设法将它们连接到外部世界,错误就消失了。


0
投票

对于任何人在未来第一次遇到这种情况,如果您确定没有连接或互联网问题:还有另一种解决方案。如果您的 apt 任务包括

update_cache: true
,请确保在远程计算机上运行
apt update
时没有警告或错误。 就我而言,kubernetes 列表缺少签名,这是一个不再使用的列表。 运行
sudo apt update
后得到的警告是:

W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://packages.cloud.google.com/apt kubernetes-xenial InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY B53DC80D13EDEF05

删除

/etc/apt/sources.list.d/kubernetes.list
导致运行
apt update
没有错误或警告,并修复了ansible问题。 然后任务顺利完成,我可以使用 apt 任务安装包,包括
update_cache: true
.

© www.soinside.com 2019 - 2024. All rights reserved.