# Apt module does not find package

**URL:** <https://forum.ansible.com/t/apt-module-does-not-find-package/8775>\
**Category:** Get Help\
**Created:** [September 25, 2024, 9:30pm UTC](https://forum.ansible.com/t/apt-module-does-not-find-package/8775 "2024-09-25T21:30:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Enio\_Junior](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/enio_junior/32/4875_2.png) [@Enio\_Junior](https://forum.ansible.com/u/Enio_Junior)\
**Post date:** [September 25, 2024, 9:30pm UTC](https://forum.ansible.com/t/apt-module-does-not-find-package/8775/1 "2024-09-25T21:30:31Z")

</div>

I’m trying to create my first playbook, and I want to install the package “micro”.  
When I’m connected to the server, I can install it, but when I run the playbook, the message is:

```auto
fatal: [182.168.1.2]: FAILED! => {"changed": false, "msg": "No package matching 'micro/jammy-updates' is available"}

```

My playbook:

```auto
---
- name: Criação de um ambiente de desenvolvimento em background
  hosts: lab
  gather_facts: no
  tasks:
    - name: Atualizando pacotes
      become: yes
      ansible.builtin.apt:
        update_cache: yes
        upgrade: yes
    - name: Remove sources.list antiga
      become: yes
      ansible.builtin.file:
        path: /etc/sources.list*
        state: absent
    - name: Adiciona sources.list nova
      become: yes
      ansible.builtin.copy:
        src: jammy.sources.list
        dest: /etc/sources.list
        owner: root
        group: root
        mode: 0644
    - name: Atualizando pacotes com nova sources.list
      become: yes
      ansible.builtin.apt:
        update_cache: yes
        upgrade: yes
    - name: Remove pacotes desnecessários
      become: yes
      ansible.builtin.apt:
        pkg:
          - nano
        state: absent
    - name: Instala pacotes necessários
      become: yes
      ansible.builtin.apt:
        pkg:
          - micro
          - snapd
        state: present

```

---

<div class="post-metadata">

**Author:** ![chris](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/chris/32/293_2.png) [@chris](https://forum.ansible.com/u/chris)\
**Post date:** [September 26, 2024, 8:22am UTC](https://forum.ansible.com/t/apt-module-does-not-find-package/8775/2 "2024-09-26T08:22:26Z")

</div>

There is a [micro package in Jammy updates](https://packages.ubuntu.com/search?suite=jammy-updates&searchon=names&keywords=micro) so my guess would be that your `jammy.sources.list` file doesn’t contain `updates`? Could you post the content of that file here?

---

<div class="post-metadata">

**Author:** ![Enio\_Junior](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/enio_junior/32/4875_2.png) [@Enio\_Junior](https://forum.ansible.com/u/Enio_Junior)\
**Post date:** [September 27, 2024, 3:15pm UTC](https://forum.ansible.com/t/apt-module-does-not-find-package/8775/3 "2024-09-27T15:15:40Z")

</div>

The sources.list file that comes by default has broken repositories (I would even say abandoned). This way I replaced it with the standard Ubuntu repositories:

```auto
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ jammy main restricted universe multiverse
# deb-src http://archive.ubuntu.com/ubuntu/ jammy main restricted universe multiverse

deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ jammy-updates main restricted universe multiverse
# deb-src http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted universe multiverse

deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ jammy-security main restricted universe multiverse
# deb-src http://archive.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse

deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ jammy-backports main restricted universe multiverse
# deb-src http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse

#deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ jammy partner
# deb-src http://archive.canonical.com/ubuntu/ jammy partner

```

When I use apt directly on the machine via ssh, no error is given, only when called by ansible-playbook.

---

<div class="post-metadata">

**Author:** ![chris](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/chris/32/293_2.png) [@chris](https://forum.ansible.com/u/chris)\
**Post date:** [September 27, 2024, 3:26pm UTC](https://forum.ansible.com/t/apt-module-does-not-find-package/8775/4 "2024-09-27T15:26:30Z")

</div>

That is odd, perhaps this is caused by some environment variables or something – these might differ when you SSH to the server compared to when Ansible is run?

All I can think of it to try changing:

```auto
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ jammy-updates main restricted universe multiverse

```

Into?

```auto
deb [arch=armhf] http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted universe multiverse

```

Or is the `ports.ubuntu.com` domain required for `armhf`?

Sorry I can’t think of another cause or answer to this. 🤷‍♀️
