Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions labs/package-repo-broken/cloud-init.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#cloud-config
runcmd:
- |
# 1. Create a broken repository file
# We use a non-existent codename like 'broken-release'
cat <<EOF > /etc/apt/sources.list.d/broken.list
deb http://archive.ubuntu.com/ubuntu/ broken-release main restricted
EOF

# 2. To ensure it really fails, we can also mess with the main sources.list
# But usually a single broken file in sources.list.d is enough to block apt update
# effectively with a non-zero exit code.
24 changes: 24 additions & 0 deletions labs/package-repo-broken/lab.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
id: package-repo-broken
name: Package Manager Repository Misconfigured
category: linux
difficulty: beginner
vm:
name: repo-lab
image: ubuntu-24.04-base.qcow2
memory: 1024
cpu: 1
disk: 10G
cloud_init: cloud-init.yaml
verify_script: verify.sh

description:
summary: "The system is unable to install or update software because the package manager's repository configuration is broken."
story: "A systems administrator tried to switch the server to a faster local repository mirror, but something went wrong. Now, every time you try to run 'apt update', you get errors about invalid URLs or missing release files. You need to identify the broken repository configuration and restore access to the official Ubuntu repositories."
objectives:
- Reproduce the repository update failure
- Identify the incorrectly configured source file in /etc/apt/sources.list.d/
- Restore a valid repository configuration and verify that 'apt update' succeeds
tags:
- linux
- apt
- maintenance
11 changes: 11 additions & 0 deletions labs/package-repo-broken/question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
### Scenario
You are trying to install a necessary utility on this server using `apt`, but you find that any attempt to update the package lists results in errors. It seems like the repository configuration has been tampered with or misconfigured, preventing the system from reaching the official Ubuntu sources.

### Objective
Diagnose the failure in the package manager, identify the problematic configuration file, and restore the system's ability to update and install software.

### Useful Commands
- `sudo apt update`
- `ls /etc/apt/sources.list.d/`
- `cat /etc/apt/sources.list`
- `sudo rm [file]`
38 changes: 38 additions & 0 deletions labs/package-repo-broken/solution.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
### The Issue
The Debian/Ubuntu package manager (`apt`) relies on repository definition files located in `/etc/apt/sources.list` and the `/etc/apt/sources.list.d/` directory. If any of these files contains an invalid URL, a non-existent release codename, or a malformed entry, the entire `apt update` process will fail with an error.

In this case, a file named `/etc/apt/sources.list.d/broken.list` was created with an invalid release name (`broken-release`), causing the package manager to stop functioning correctly.

### Step-by-Step Fix

1. **Reproduce the error**:
Run the update command to see the failure.
```bash
sudo apt update
```
You will see errors like: `The repository 'http://archive.ubuntu.com/ubuntu broken-release Release' does not have a Release file.`

2. **Locate the broken configuration**:
Check the contents of the sources directory.
```bash
ls /etc/apt/sources.list.d/
```
You will see a file named `broken.list`.

3. **Inspect the file**:
```bash
cat /etc/apt/sources.list.d/broken.list
```
Confirm that it points to a non-existent release.

4. **Remove the problematic file**:
```bash
sudo rm /etc/apt/sources.list.d/broken.list
```

5. **Verify the fix**:
Run the update command again.
```bash
sudo apt update
```
It should now complete successfully without repository errors.
7 changes: 7 additions & 0 deletions labs/package-repo-broken/solution.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# Remove the broken repository file
rm -f /etc/apt/sources.list.d/broken.list

# Run apt update to confirm fix
apt-get update
10 changes: 10 additions & 0 deletions labs/package-repo-broken/verify.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# Check if 'apt update' succeeds
if apt-get update; then
echo "SUCCESS: Package manager repositories are working correctly."
exit 0
else
echo "FAILURE: Package manager repository update failed."
exit 1
fi
Loading