Ansible Dnf With Stream

Home » CentOS » Ansible Dnf With Stream
CentOS 2 Comments

I wish You a Merry Christmas. Have a great time.

Aside from that, I’m having a strange problem with dnf module on Ansible with CentOS Stream. I’m using Ansible 2.9 on RHEL 8.

TASK [Install basic packages on RedHat-like systems.]
********************************************************************
skipping: [malinka.ping.local]
skipping: [jezynka.ping.local]
skipping: [aegis.ping.local]
ok: [strategie.ping.local]
fatal: [stream.ping.local]: FAILED! => {“changed”: false, “failures”:
[“No package htop available.”], “msg”: “Failed to install some of the specified packages”, “rc”: 1, “results”: []}
changed: [python-cave.ping.local]
ok: [outpost.ping.local]
changed: [potemkin.ping.local]
changed: [rawhide.ping.local]

The task in question is:

– name: Install basic packages on RedHat-like systems.
dnf:
name:
– bash-completion
– htop
– mc
– vim
– mtr
– tree
– net-tools
state: latest
enablerepo: epel-modular, epel
when: ansible_os_family == ‘RedHat’

This task works on RHEL 8.3, CentOS 8.3, Fedora 33, but not in CentOS
Stream 8. I can install above packages (including htop) with no problem by hand:

sudo dnf –enablerepo=epel-modular,epel install htop Failed to set locale, defaulting to C.UTF-8
Librepo version: 1.12.0 with CURL_GLOBAL_ACK_EINTR support
(libcurl/7.61.1 OpenSSL/1.1.1g zlib/1.2.11 brotli/1.0.6 libidn2/2.2.0
libpsl/0.20.2 (+libidn2/2.2.0) libssh/0.9.4/openssl/zlib nghttp2/1.33.0) Last metadata expiration check: 0:25:46 ago on Thu Dec
24 14:44:50 2020. Dependencies resolved.
========================================================================
Package Architecture Version Repository Size
========================================================================
Installing: htop x86_64
2.2.0-6.el8 epel 112 k
[…]
Installed:
htop-2.2.0-6.el8.x86_64

I don’t get it why a separate “dnf update” task is running fine and this is not.


Łukasz Posadowski

2 thoughts on - Ansible Dnf With Stream

  • Hi Lukasz,

    I haven’t tested, but my instinct points at the “enablerepo” line. You’ve written “epel-modular, epel” with a space. YAML preserves the space, and passes it to dnf, and perhaps it’s causing a problem. Can you try it without the space?

    Regards, Anand

  • Fri, 25 Dec 2020 12:34:04 +0100
    Anand Buddhdev :

    What in the world, that worked. :) Thank You. I expect the space will cause the same error in RHEL 8.4.

    Problem solved. Or workarounded, which is fine by me.


    Łukasz Posadowski