canonical / canonical/cloud-init
Hash sum mismatch during `packages` module run if primary APT source was changed by `apt` module
- Dominant language
- Python
- Stars
- 3.8k
- Forks
- 1.1k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 18
Description
# Bug report
If the `apt` module of cloud-init is used to modify the primary APT source URI, and the `packages` module is configured to install packages, a series of errors can be seen, such as `Hash sum mismatch` and `Unexpected file size`. This is caused by `package_update` defaulting to `false`, meaning that the local APT state contains package lists from a mirror other than the one being queried. If these mirrors aren't perfectly synchronised, errors such as these will appear, and packages will fail to install.
## Steps to reproduce the problem
Boot the minimal Ubuntu 24.04 image using the following `cloud-config` example (results may vary depending on the sync state of the alternate chosen mirror):
```
#cloud-config
apt:
primary:
- arches: [default]
uri: http://some.other.mirror/ubuntu
packages:
- ca-certificates
- curl
- sudo
```
This is in contrast to the following `cloud-config`, which works perfectly every time:
```
#cloud-config
apt:
primary:
- arches: [default]
uri: http://some.other.mirror/ubuntu
package_update: true
packages:
- ca-certificates
- curl
- sudo
```
## Environment details
- Cloud-init version: 24.3.1-0ubuntu0~24.04.2
- Operating System Distribution: Ubuntu 24.04
- Cloud provider, platform or installer type: NoCloud
## cloud-init logs
Contributor guide
Assessment
This issue has not been assessed yet.