diff --git a/changelogs/fragments/dnf-security.yaml b/changelogs/fragments/dnf-security.yaml new file mode 100644 index 00000000000..cc8577afe4b --- /dev/null +++ b/changelogs/fragments/dnf-security.yaml @@ -0,0 +1,2 @@ +bugfixes: + - Replace usage of private dnf.Base() attribute by future dnf API \ No newline at end of file diff --git a/lib/ansible/modules/dnf.py b/lib/ansible/modules/dnf.py index 237b4439650..0401d491cb6 100644 --- a/lib/ansible/modules/dnf.py +++ b/lib/ansible/modules/dnf.py @@ -687,15 +687,25 @@ class DnfModule(YumDnf): rc=1 ) - filters = [] - if self.bugfix: - key = {'advisory_type__eq': 'bugfix'} - filters.append(base.sack.query().upgrades().filter(**key)) - if self.security: - key = {'advisory_type__eq': 'security'} - filters.append(base.sack.query().upgrades().filter(**key)) - if filters: - base._update_security_filters = filters + add_security_filters = getattr(base, "add_security_filters", None) + if callable(add_security_filters): + filters = {} + if self.bugfix: + filters.setdefault('types', []).append('bugfix') + if self.security: + filters.setdefault('types', []).append('security') + if filters: + add_security_filters('eq', **filters) + else: + filters = [] + if self.bugfix: + key = {'advisory_type__eq': 'bugfix'} + filters.append(base.sack.query().upgrades().filter(**key)) + if self.security: + key = {'advisory_type__eq': 'security'} + filters.append(base.sack.query().upgrades().filter(**key)) + if filters: + base._update_security_filters = filters return base