diff --git a/changelogs/fragments/77010-dnf-ensure-releasever-string.yml b/changelogs/fragments/77010-dnf-ensure-releasever-string.yml new file mode 100644 index 00000000000..bcfa7e148c6 --- /dev/null +++ b/changelogs/fragments/77010-dnf-ensure-releasever-string.yml @@ -0,0 +1,2 @@ +bugfixes: + - dnf - ensure releasever is passed into libdnf as string (https://github.com/ansible/ansible/issues/77010) diff --git a/lib/ansible/modules/dnf.py b/lib/ansible/modules/dnf.py index 5e264d67811..44f9a714dc0 100644 --- a/lib/ansible/modules/dnf.py +++ b/lib/ansible/modules/dnf.py @@ -656,6 +656,14 @@ class DnfModule(YumDnf): if self.releasever is not None: conf.substitutions['releasever'] = self.releasever + if conf.substitutions.get('releasever') is None: + self.module.warn( + 'Unable to detect release version (use "releasever" option to specify release version)' + ) + # values of conf.substitutions are expected to be strings + # setting this to an empty string instead of None appears to mimic the DNF CLI behavior + conf.substitutions['releasever'] = '' + # Set skip_broken (in dnf this is strict=0) if self.skip_broken: conf.strict = 0