# Diff result between AAP / ansible cmdline dnf

**URL:** <https://forum.ansible.com/t/diff-result-between-aap-ansible-cmdline-dnf/8257>\
**Category:** Get Help\
**Tags:** aap, dnf\
**Created:** [September 4, 2024, 10:15am UTC](https://forum.ansible.com/t/diff-result-between-aap-ansible-cmdline-dnf/8257 "2024-09-04T10:15:54Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marc010](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/marc010/32/4640_2.png) [@Marc010](https://forum.ansible.com/u/Marc010)\
**Post date:** [September 4, 2024, 10:15am UTC](https://forum.ansible.com/t/diff-result-between-aap-ansible-cmdline-dnf/8257/1 "2024-09-04T10:15:54Z")

</div>

Using the ansible.builtin.ansible module I try to update remote servers. Running my playbook from ansible cmdline it all works fine. Using the same playbook in AAP I get an error:  
“Failed to download metadata … Cannot download reponsd.xml All mirrors where tried”

The repo server is avaiable, no firewall obstructions (running playbook from cmdline works) Also running dnf update as root on a failing server works.

Any suggestions?

Code:

```auto
- name: Upgrade all packages using DNF
  block:
    - name: Executing DNF clean cache and update packages
      ansible.builtin.dnf:
        name: '*'
        update_cache: true
        state: latest
      register: updated_packages

    - name: List of updated packages
      ansible.builtin.debug:
        var: updated_packages.results|d()
      when: updated_packages

```

---

<div class="post-metadata">

**Author:** ![jiholland](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jiholland/32/11273_2.png) [@jiholland](https://forum.ansible.com/u/jiholland)\
**Post date:** [September 17, 2024, 6:00pm UTC](https://forum.ansible.com/t/diff-result-between-aap-ansible-cmdline-dnf/8257/2 "2024-09-17T18:00:27Z")

</div>

Hi.  
It might be a missing or old/out-of-date certificate in the execution environment you are using in AAP, since dnf uses ssl. What (base) image are you building your execution environment on?

---

<div class="post-metadata">

**Author:** ![Marc010](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/marc010/32/4640_2.png) [@Marc010](https://forum.ansible.com/u/Marc010)\
**Post date:** [September 19, 2024, 7:43am UTC](https://forum.ansible.com/t/diff-result-between-aap-ansible-cmdline-dnf/8257/3 "2024-09-19T07:43:33Z")

</div>

Default exeution env based on RHEL9. Don’t think it a certificate issue since the playbook works on other servers within the same VLAN’s correctly. Somehow on some servers dnf won’t work. Neither when I’m using the builtin dnf module nor using shell cmd. Running it from cmdline, directly without execution nodes of course, all works fine. I’m not lost that soon but now I am 😉

---

<div class="post-metadata">

**Author:** ![jiholland](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jiholland/32/11273_2.png) [@jiholland](https://forum.ansible.com/u/jiholland)\
**Post date:** [September 19, 2024, 8:02am UTC](https://forum.ansible.com/t/diff-result-between-aap-ansible-cmdline-dnf/8257/4 "2024-09-19T08:02:38Z")

</div>

OK. Then it is probably an issue with the python interpreter. Try setting the [ansible\_python\_interpreter](https://docs.ansible.com/ansible/latest/reference_appendices/interpreter_discovery.html) variable in your inventory as a hostvars variable for the servers where dnf does not work. Example:

```yaml
$ cat inventory/host_vars/server1/ansible.yml
ansible_host: "192.0.2.10"
ansible_python_interpreter: "/usr/bin/python3.9"

```

---

<div class="post-metadata">

**Author:** ![Marc010](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/marc010/32/4640_2.png) [@Marc010](https://forum.ansible.com/u/Marc010)\
**Post date:** [September 19, 2024, 8:03am UTC](https://forum.ansible.com/t/diff-result-between-aap-ansible-cmdline-dnf/8257/5 "2024-09-19T08:03:52Z")

</div>

'm going to try this, tnx

---

<div class="post-metadata">

**Author:** ![Marc010](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/marc010/32/4640_2.png) [@Marc010](https://forum.ansible.com/u/Marc010)\
**Post date:** [September 19, 2024, 9:50am UTC](https://forum.ansible.com/t/diff-result-between-aap-ansible-cmdline-dnf/8257/6 "2024-09-19T09:50:22Z")

</div>

> [@jiholland](#):
>
> `ansible_python_interpreter: "/usr/bin/python3.9"`

Tried it, no change sadly enough

---

<div class="post-metadata">

**Author:** ![jiholland](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jiholland/32/11273_2.png) [@jiholland](https://forum.ansible.com/u/jiholland)\
**Post date:** [September 19, 2024, 10:11am UTC](https://forum.ansible.com/t/diff-result-between-aap-ansible-cmdline-dnf/8257/7 "2024-09-19T10:11:20Z")

</div>

What is the Python version and location on the servers where dnf is not working?

```yaml
$ python3 --version
$ which python3

```

---

<div class="post-metadata">

**Author:** ![Denney-tech](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/denney-tech/32/1556_2.png) [@Denney-tech](https://forum.ansible.com/u/Denney-tech)\
**Post date:** [September 19, 2024, 3:09pm UTC](https://forum.ansible.com/t/diff-result-between-aap-ansible-cmdline-dnf/8257/8 "2024-09-19T15:09:36Z")

</div>

The yum/dnf modules specifically need to use `/usr/libexec/platform-python` to run, since the required libraries are only available under the OS’ python. Ansible does have a redirect feature for this module, so you don’t necessarily need to specify the `ansible_python_interpreter` here.

I’m more curious to know what version of Ansible you’re using on CLI, and what version you’re using on AAP’s EE.

---

<div class="post-metadata">

**Author:** ![jiholland](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jiholland/32/11273_2.png) [@jiholland](https://forum.ansible.com/u/jiholland)\
**Post date:** [September 24, 2024, 8:19am UTC](https://forum.ansible.com/t/diff-result-between-aap-ansible-cmdline-dnf/8257/9 "2024-09-24T08:19:08Z")

</div>

@Denney-tech I didn’t know that it was possible to redirect to a specific version of Python directly from the ansible.builtin.dnf module. What is that parameter called? I can’t seem to find it in the [documentation](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/dnf_module.html).

---

<div class="post-metadata">

**Author:** ![shertel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/shertel/32/1241_2.png) [@shertel](https://forum.ansible.com/u/shertel)\
**Post date:** [September 24, 2024, 12:57pm UTC](https://forum.ansible.com/t/diff-result-between-aap-ansible-cmdline-dnf/8257/10 "2024-09-24T12:57:00Z")

</div>

The module can respawn itself under the correct interpreter [ansible/lib/ansible/modules/dnf.py at devel · ansible/ansible · GitHub](https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/dnf.py#L490-L501)

---

<div class="post-metadata">

**Author:** ![Denney-tech](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/denney-tech/32/1556_2.png) [@Denney-tech](https://forum.ansible.com/u/Denney-tech)\
**Post date:** [September 24, 2024, 1:27pm UTC](https://forum.ansible.com/t/diff-result-between-aap-ansible-cmdline-dnf/8257/11 "2024-09-24T13:27:24Z")

</div>

@jiholland As @shertel linked, the module itself is hardcoded to do this automatically.

For other modules, you can specify the `ansible_python_interpreter` variable at the task level, in case you ever run into other exceptions that don’t need (or can’t) run with the default or more broadly defined interpreter.
