It works as far as downloading the package, but the installation fails with a GPG check error:
FAILED! => {"changed": false, "msg": "Failed to validate GPG signature for foreman-release-3.10.0-1.el8.noarch: Public key for foreman-releaseyvnup2j9.rpm is not installed"}
I don’t know where foreman-releaseyvnup2j9.rpm is coming from, but it’s different with each run. For example, running it again fails to find a key for foreman-releasetimtkhr2.rpm.
Running dnf from the command line outside of Ansible works as expected.
I could just work around the problem by adding disable_gpg_check: true, but I’d rather not do that. Can anyone tell me why this is not using the correct package name when doing the GPG check?
That particular package contains the GPG key, so it’s a bit of chicken and egg (you could install it via other means, sure).
But (with my Foreman hat on), pulling that RPM via an HTTPS connection should be fine w/o checking GPG.
That’s also what we’re doing in the official collection:
You could install the key directly first, and then install the release rpm. The mangled filename might be incidental, but if you want to make sure the signature is good, then install the key first like so:
I guess Ansible first downloads that file to some temp location (so it can compare “is it installed already” and properly report changed), and during that it also gives it a “temp” name. Given rpm/yum/dnf will use the name from the RPM header, the filename doesn’t matter much anyway.
How would that improve the security of the “obtain the key” operation, given you’re still fetching the same key from the same host (well, CDN, but whatever)?
The signature will then be checked when you actually install packages from that repository.
I suppose that if the rpm is compromised by the same signing key found in the repo, the security is moot. If specific parts of the supply chain are somehow compromised, but also somehow the key is not, then we at least move the chicken and egg problem around to catch that.
Including the fingerprint from a trusted source would solve this, but I’m not sure of a reliable/programmatic way of doing that.