0

i'm trying to learn something about ansible and the automation, unfortunately I'm getting frustrated at the early step. I just tried from debian 10 machine with ansible to write a yaml to upgrade 2 Oracle linux hosts, following a guide. What I've done is this yaml file :

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

When I launch it with ansible-playbook the result is:

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

from inside the hosts, I can run dnf upgrade flawless.

I tried to dnf clear, and various fixes found on dnf issue related but nothing had workd. I suspect that somethings permission related, but my knowledge is not enough to fix.

what to try?

any help is appreciated.

bind2lrz
  • 7
  • 4
  • You need Internet connectivity to download packages. – Michael Hampton Feb 24 '21 at 12:53
  • When you say - from inside the hosts it works - are there an HTTP_PROXY settings or so, that are automatically assigned with your interactive login? Conrete: The dnf module only outputs what the hosts dnf program responses. So this is not really an Ansible issue and not really an permission problem on the host (you would see other messages related to become/sudo) - but something on the host itself. – TRW Feb 25 '21 at 08:43
  • TRW unfortunately no http_proxy is involved In my environment, on the host itself I can run dnf upgrade and on the ansible host which runs on Debian, I reach public network ( idk if this is decisive, maybe not ) MichaelHampton I have internet connection in all the hosts involved, as i can run dnf upgrade on the individual hosts without problems, they are vms under the same subnet on KVM with natted virtual switch. – bind2lrz Feb 25 '21 at 09:09

1 Answers1

0

Did you ever find a solution to your problem?

Seems ansible doesn't play nicely with the $ociregion variable, remove it from your yum repo URL and you should be up and running

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

becomes:

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

Glenn
  • 1
  • 1