When running the E2E configuration tests in GitHub Actions, the Ansible playbook fails to install Docker with the error "No package matching 'docker.io' is available". This occurs despite Docker being a standard Ubuntu package.
2025-09-24T06:46:09.136842Z INFO e2e_config_tests: status: "expected_failure", error: Command execution failed: Command 'ansible-playbook -v install-docker.yml' failed with exit code 2
Stdout: Using /home/runner/work/torrust-tracker-deployer/torrust-tracker-deployer/build/ansible/ansible.cfg as config file
PLAY [Install Docker (Simplified for E2E)] *************************************
TASK [Gathering Facts] *********************************************************
ok: [torrust-tracker-vm]
TASK [🐳 Starting simplified Docker installation] ******************************
ok: [torrust-tracker-vm] => {}
MSG:
🚀 Installing Docker CE via Ubuntu repositories on torrust-tracker-vm
TASK [Update apt cache] ********************************************************
ok: [torrust-tracker-vm] => {
"cache_update_time": 1758696352,
"cache_updated": false,
"changed": false
}
TASK [Install Docker from Ubuntu repositories] *********************************
task path: /home/runner/work/torrust-tracker-deployer/torrust-tracker-deployer/build/ansible/install-docker.yml:26
fatal: [torrust-tracker-vm]: FAILED! => {
"changed": false
}
MSG:
No package matching 'docker.io' is available
PLAY RECAP *********************************************************************
torrust-tracker-vm : ok=3 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
GitHub Actions containers can have stale APT package caches or incomplete repository configurations. The issue manifests in several ways:
-
Stale APT Cache: The
cache_valid_time: 3600parameter prevents cache updates if the cache appears recent, but the cache might be stale or incomplete in containerized environments. -
Container Environment Differences: GitHub Actions runners may have different repository configurations or missing universe/multiverse repositories compared to standard Ubuntu installations.
-
APT Backend Issues: Using the default APT backend in containerized environments can sometimes fail to properly update package lists.
The fix involves forcing APT cache updates and using more robust APT options in containerized environments:
- Remove cache validity constraints to ensure fresh package list retrieval
- Add
force_apt_getflag to bypass potential APT caching issues - Add debugging information to troubleshoot repository availability
- Ensure proper repository configuration verification
The fix was implemented in templates/ansible/install-docker.yml:
- - name: Update apt cache
+ - name: Force update apt cache for container environment
ansible.builtin.apt:
update_cache: true
- cache_valid_time: 3600
+ force_apt_get: true
when: ansible_os_family == "Debian"
+ - name: Ensure universe repository is available
+ ansible.builtin.shell: |
+ apt-cache policy docker.io || echo "docker.io not found"
+ apt list --installed | grep -E "(universe|multiverse)" | head -5 || echo "No universe/multiverse packages found"
+ register: repo_check
+ changed_when: false
+
+ - name: Display repository check results
+ ansible.builtin.debug:
+ var: repo_check.stdout_lines
+
- name: Install Docker from Ubuntu repositories
ansible.builtin.apt:
name:
- docker.io
state: present
+ force_apt_get: true
when: ansible_os_family == "Debian"Fixed in commit: f697165
Commit message: fix: force apt cache update in Docker installation for GitHub Actions containers
To prevent this issue in the future:
- Always use
force_apt_get: truein GitHub Actions environments when using Ansible apt module - Remove
cache_valid_timeconstraints in CI environments where fresh package lists are critical - Add debugging tasks to verify repository availability before attempting package installation
- Test playbooks in containerized environments that mirror GitHub Actions runners
- Consider using
update_cache: truewithforce_apt_get: truefor all package installations in CI
- Similar APT cache issues may occur with other packages in GitHub Actions environments
- This pattern should be applied to other Ansible playbooks that install packages in CI