Apt repo preventing from completing a lab

Hi guys!

I’m taking the Ansible Advanced Course “Lab - Conditionals”.
At question #3, we are requested to deploy Apache in a set of server in our inventory, based on the OS distribution version. We have Ubuntu and CentOS based-operating systems as part of the managed hosts.

However, the task to install apache2 in the Ubuntu managed servers failed since there is an issue with the apt repos on them:

Playbook:

[thor@ansible-controller playbooks]$ cat install_apache.yml 
---
- name: Install apache
  hosts: all
  tasks:
  - name: "Install apache2 in Ubuntu"
    package:
      name: apache2
      state: present
    when: ansible_distribution == "Ubuntu"

  - name: "Install apache2 in Ubuntu"
    package:
      name: httpd
      state: present
    when: ansible_distribution == "CentOS"

Ansible execution playbook output:

[thor@ansible-controller playbooks]$ ansible-playbook -i inventory install_apache.yml 
 
PLAY [Install apache] ****************************************************************

TASK [Gathering Facts] ***************************************************************
ok: [web2]
ok: [web1]

TASK [Install apache2 in Ubuntu] *****************************************************
skipping: [web1]
[WARNING]: Updating cache and auto-installing missing dependency: python3-apt
fatal: [web2]: FAILED! => {"changed": false, "cmd": "apt-get update", "msg": "E: The repository 'http://archive.ubuntu.com/ubuntu lunar Release' no longer has a Release file.\nE: The repository 'http://archive.ubuntu.com/ubuntu lunar-updates Release' no longer has a Release file.\nE: The repository 'http://archive.ubuntu.com/ubuntu lunar-backports Release' no longer has a Release file.\nE: The repository 'http://security.ubuntu.com/ubuntu lunar-security Release' no longer has a Release file.", "rc": 100, "stderr": "E: The repository 'http://archive.ubuntu.com/ubuntu lunar Release' no longer has a Release file.\nE: The repository 'http://archive.ubuntu.com/ubuntu lunar-updates Release' no longer has a Release file.\nE: The repository 'http://archive.ubuntu.com/ubuntu lunar-backports Release' no longer has a Release file.\nE: The repository 'http://security.ubuntu.com/ubuntu lunar-security Release' no longer has a Release file.\n", "stderr_lines": ["E: The repository 'http://archive.ubuntu.com/ubuntu lunar Release' no longer has a Release file.", "E: The repository 'http://archive.ubuntu.com/ubuntu lunar-updates Release' no longer has a Release file.", "E: The repository 'http://archive.ubuntu.com/ubuntu lunar-backports Release' no longer has a Release file.", "E: The repository 'http://security.ubuntu.com/ubuntu lunar-security Release' no longer has a Release file."], "stdout": "Ign:1 http://archive.ubuntu.com/ubuntu lunar InRelease\nIgn:2 http://archive.ubuntu.com/ubuntu lunar-updates InRelease\nIgn:3 http://archive.ubuntu.com/ubuntu lunar-backports InRelease\nIgn:4 http://security.ubuntu.com/ubuntu lunar-security InRelease\nErr:5 http://archive.ubuntu.com/ubuntu lunar Release\n  404  Not Found [IP: 91.189.91.82 80]\nErr:6 http://archive.ubuntu.com/ubuntu lunar-updates Release\n  404  Not Found [IP: 91.189.91.82 80]\nErr:7 http://archive.ubuntu.com/ubuntu lunar-backports Release\n  404  Not Found [IP: 91.189.91.82 80]\nErr:8 http://security.ubuntu.com/ubuntu lunar-security Release\n  404  Not Found [IP: 91.189.92.24 80]\nReading package lists...\n", "stdout_lines": ["Ign:1 http://archive.ubuntu.com/ubuntu lunar InRelease", "Ign:2 http://archive.ubuntu.com/ubuntu lunar-updates InRelease", "Ign:3 http://archive.ubuntu.com/ubuntu lunar-backports InRelease", "Ign:4 http://security.ubuntu.com/ubuntu lunar-security InRelease", "Err:5 http://archive.ubuntu.com/ubuntu lunar Release", "  404  Not Found [IP: 91.189.91.82 80]", "Err:6 http://archive.ubuntu.com/ubuntu lunar-updates Release", "  404  Not Found [IP: 91.189.91.82 80]", "Err:7 http://archive.ubuntu.com/ubuntu lunar-backports Release", "  404  Not Found [IP: 91.189.91.82 80]", "Err:8 http://security.ubuntu.com/ubuntu lunar-security Release", "  404  Not Found [IP: 91.189.92.24 80]", "Reading package lists..."]}

TASK [Install apache2 in Ubuntu] *****************************************************
ok: [web1]

PLAY RECAP ***************************************************************************
web1                       : ok=2    changed=0    unreachable=0    failed=0    skipped=1    rescued=0    ignored=0   
web2                       : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

The root cause:

E: The repository 'http://archive.ubuntu.com/ubuntu lunar Release' no longer has a Release file.

The Ubuntu server is running Ubuntu 23.04 “Lunar Lobster”. That Ubuntu release is end-of-life, so its normal repositories no longer provide the lunar repositories:
archive.ubuntu.com
security.ubuntu.com

Solution
Set the following new repos in /etc/apt/sources.list on web2 node:

deb http://old-releases.ubuntu.com/ubuntu/ lunar main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu/ lunar-updates main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu/ lunar-security main restricted universe multiverse
deb http://old-releases.ubuntu.com/ubuntu/ lunar-backports main restricted universe multiverse

I checked it and facing same error.
It appears as Ubuntu 23.04 has been EOL since early 2024, Hence unable to download repository metadata.

Thanks for bringing this to our attention. I’ll inform the team to fix this and update you once this is resolved.

1 Like

Hey @maikycr28

The labs in the Ansible Advanced course have been revamped and updated.
This should not cause any issues now.