Repository navigation
Stop cloud-init's apt-configure crashing on the indexers - #49
Conversation
With no apt mirrors configured, apt-configure reads them from the datasource and fails with KeyError: 'security'. Name the mirrors, and keep it from writing apt sources or mirror lists. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude reviewThis is a small, well-scoped change. It adds a cloud-init drop-in ( No issues found. claude-sonnet-5-5 at high effort · requested by TakGN · re-run with |
indexers-amst1shows failedcloud-config.serviceandcloud-init-main.service: cloud-init'sapt-configurecrashes withKeyError: 'security'infind_apt_mirror_info. This adds/etc/cloud/cloud.cfg.d/99-ipni-apt.cfgon the indexers only (hardening_fix_cloud_init_apt, off by default, on ingroup_vars/indexers), where the cloud config directory exists.Why not just
generate_mirrorlists: falseRead in Debian 13's source (
25.1.4-1+deb13u1, with its mirrorlist patch),cc_apt_configure.apply_apt:find_apt_mirror_infofirst. With noapt.primaryconfigured,update_mirror_infotakes the datasource's mirror dict and reads["security"]: the crash.generate_mirrorlists; if false, andpreserve_sources_listis not true, it rewrites the apt sources.So
generate_mirrorlists: falsealone would not avoid the crash. The file therefore sets:primary,securityupdate_mirror_inforeturns these and never reads the datasource's dictgenerate_mirrorlists: false/etc/apt/mirrors/*.listpreserve_sources_list: trueThe URIs are Debian's own. With the two flags above they go unused; if higher-priority config (user-data, vendor-data) turned rewriting back on, the result would still be valid sources.
99-overrides the image's01_debian_cloud.cfg.Still true of
apply_apt_config: with no apt proxy orconfconfigured, it removes cloud-init's own proxy/conf files if present. This change does not alter that.What this does not do
systemctl reset-failed cloud-config.service cloud-init-main.serviceonly clears systemd's state. Neither was run.apt-configureon the same instance: it runs once per instance and a failed run keeps its semaphore. So the file matters when it runs again (new instance ID, orcloud-init clean), and a clean reboot alone does not prove the fix.site.ymlwrites the file. A reinstall that wipes the disk will hit the crash again.Tested
--syntax-checkon all seven playbooks,yamllint .,ansible-lint(production profile, 0 failures).truefor both indexers and is not set in inventory for the IPFS or infra boxes (the role default isfalse).Not tested
site.yml, nocloud-init.securityon Cherry's image (MAAS datasource or its config) is still an inference. The fix does not depend on it.indexers-chic1also gets the file; its cloud-init is currently clean.site.ymlapplies from CI after approval. Suggested check afterwards, onindexers-amst1:sudo cloud-init single --name apt_configure --frequency always, then confirm the apt sources are unchanged.🤖 Generated with Claude Code