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:
fatal: [182.168.1.2]: FAILED! => {"changed": false, "msg": "No package matching 'micro/jammy-updates' is available"}
My playbook:
---
- 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
There is a micro package in Jammy updates so my guess would be that your jammy.sources.list file doesn’t contain updates? Could you post the content of that file here?
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:
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.
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:
deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ jammy-updates main restricted universe multiverse
Into?
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.