使用 DNF 升级剧本下载元数据失败

使用 DNF 升级剧本下载元数据失败

我正在尝试学习一些有关 ansible 和自动化的知识,不幸的是,我在早期阶段就感到沮丧。我刚刚尝试从使用 ansible 的 Debian 10 机器编写一个 yaml 来升级 2 个 Oracle Linux 主机,按照指南进行操作。我所做的是这个 yaml 文件:

root@deb-ansible-01:/opt/install_packages# cat upgrade.yaml
---
- hosts: puppa
  remote_user: root
  tasks:
    - name: dnf upgrade
      become: true
      become_user: root
      dnf:
        name: '*'
        state: latest

当我使用 ansible-playbook 启动它时,结果是:

root@deb-ansible-01:/opt/install_packages# ansible-playbook upgrade.yaml

PLAY [puppa] ******************************************************************************************************************************************

TASK [Gathering Facts] ********************************************************************************************************************************
ok: [ora-puppa-002]
ok: [ora-puppa-001]

TASK [dnf upgrade] ************************************************************************************************************************************
fatal: [ora-puppa-001]: FAILED! => {"changed": false, "msg": "Failed to download metadata for repo 'ol8_baseos_latest': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried", "rc": 1, "results": []}
fatal: [ora-puppa-002]: FAILED! => {"changed": false, "msg": "Failed to download metadata for repo 'ol8_baseos_latest':     : Cannot download repodata/repomd.xml: All mirrors were tried", "rc": 1, "results": []}
        to retry, use: --limit @/opt/install_packages/upgrade.retry

PLAY RECAP ********************************************************************************************************************************************
ora-puppa-001              : ok=1    changed=0    unreachable=0    failed=1
ora-puppa-002              : ok=1    changed=0    unreachable=0    failed=1

从主机内部,我可以完美运行 dnf 升级。

我尝试清除 dnf,并找到与 dnf 问题相关的各种修复方法,但都没有奏效。我怀疑某些东西与权限有关,但我的知识还不足以修复。

尝试什么?

任何帮助都将受到赞赏。

答案1

您找到解决问题的方法了吗?

似乎 ansible 与 $ociregion 变量不能很好地兼容,将其从 yum repo URL 中删除,然后就可以正常运行了

baseurl = http://yum$ociregion.oracle.com/repo/OracleLinux/OL8/baseos/latest/$basearch/

变成:

baseurl = http://yum.oracle.com/repo/OracleLinux/OL8/baseos/latest/$basearch/

相关内容