# Update packages with DNF and name wildcard

**URL:** <https://forum.ansible.com/t/update-packages-with-dnf-and-name-wildcard/1160>\
**Category:** Get Help\
**Tags:** community, update, ansible-core\
**Created:** [September 27, 2023, 11:37pm UTC](https://forum.ansible.com/t/update-packages-with-dnf-and-name-wildcard/1160 "2023-09-27T23:37:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![markfree](https://avatars.discourse-cdn.com/v4/letter/m/dfb087/32.png) [@markfree](https://forum.ansible.com/u/markfree)\
**Post date:** [September 27, 2023, 11:37pm UTC](https://forum.ansible.com/t/update-packages-with-dnf-and-name-wildcard/1160/1 "2023-09-27T23:37:13Z")

</div>

I tried to upgrade some packages with the APT/DNF modules.

To do this, I’ve set a variable with the package name and a wildcard.  
For example, let’s consider upgrading all `python3` packages with DNF.

```yaml
# Task
vars:
  package: "python3*"

tasks:
  - name: Update packages using DNF
    ansible.builtin.dnf:
      name: "{{ package }}"
      state: latest
      update_cache: yes
      update_only: true

```

This way the python3 packages won’t be upgraded because there’s no `python3*`.

```yaml
# Result
msg: Nothing to do
  rc: 0
  results:
  - Packages providing python3* not installed due to update_only specified

```

Unlike the APT module, the DNF module does not seems to support wildcards. Its documentation says I could use a list for this, but I would need to know and write all packages names.

**Is there a way to use a wildcard or, maybe, a regular expression with the DNF module?**

---

<div class="post-metadata">

**Author:** ![ads](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ads/32/747_2.png) [@ads](https://forum.ansible.com/u/ads)\
**Post date:** [September 28, 2023, 12:55am UTC](https://forum.ansible.com/t/update-packages-with-dnf-and-name-wildcard/1160/2 "2023-09-28T00:55:14Z")

</div>

Looks like (according to the documentation) you can only use “`*`” to upgrade all packages.

Another idea: use the `ansible.builtin.package_facts` module, loop over the result and only grab matching packages for upgrading with the `ansible.builtin.dnf` module. This way you can apply your pattern, or regex.

---

<div class="post-metadata">

**Author:** ![gwmngilfen](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/gwmngilfen/32/6_2.png) [@gwmngilfen](https://forum.ansible.com/u/gwmngilfen)\
**Post date:** [October 6, 2023, 8:41am UTC](https://forum.ansible.com/t/update-packages-with-dnf-and-name-wildcard/1160/3 "2023-10-06T08:41:48Z")

</div>

Hi @markfree! It looks like the post might be solved - could you check to see if the response by @ads worked for you?

If so, it would be _super_ helpful if you could click the ✔ on their post to accept the solution - it recognises the input of others, helps our volunteers find new issues to answer, and keeps the forum nice and tidy.

Thanks!  
(this is template reply, do feel free to reply if I’ve misunderstood the situation!)
