[CentOS] dnf via ansible fails if baseurl is used on CentOS 8

Thu Nov 26 13:51:57 UTC 2020
Thomas Eriksson <thomas.eriksson at maxiv.lu.se>

Hi,


I ran into an odd issue on CentOS 8, anyone seen this?


When repos are configured to use baseurl instead of mirrorlist, the ansible dnf module fails.

It is as if it is ignoring the baseurl configuration.


#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=BaseOS&infra=$infra
baseurl=http://my.local.repo.server/$contentdir/$releasever/BaseOS/$basearch/os/


If trying to use the dnf module in ansible, dnf is still trying to find a mirror to use and fails.

ansible  test-build-0  -m dnf  -a "name=zsh state=present"
test-build-0 | FAILED! => {
    "changed": false,

    "msg": "Failed to download metadata for repo 'BaseOS': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried",

    "rc": 1,
    "results": []
}

Using dnf locally from the command line works fine with baseurl


If I re-configure with repos using mirrorlist again, ansible dnf works as expected.

Just looking for ideas...


/Thomas