Skip to content

system_settings: write sysctl settings to /etc/sysctl.d - #102

Merged
stgraber merged 1 commit into
lxc:mainfrom
eoscloud:fix/system-settings-sysctl-file
Sep 28, 2026
Merged

stgraber merged 1 commit into
lxc:mainfrom
eoscloud:fix/system-settings-sysctl-file

Conversation

@speijnik

Copy link
Copy Markdown
Contributor

The system_settings role called ansible.posix.sysctl without sysctl_file, so all eleven settings were written to the module's default of /etc/sysctl.conf.

procps reads /etc/sysctl.conf last, after every sysctl.d directory, so anything this role sets silently overrides drop-ins that other software ships for itself — regardless of the precedence those files were numbered for.

We hit this on hyperconverged hosts running Incus alongside Ceph. cephadm installs /etc/sysctl.d/90-ceph-<fsid>-osd.conf asking for fs.aio-max-nr = 2097152, and then its own sysctl --system re-read /etc/sysctl.conf last and put the value back to this role's 524288. Incus' own packaged /usr/lib/sysctl.d/50-incus.conf asks for 16777216 and was overridden the same way, as was the distro's 55-map-count.conf for vm.max_map_count.

This writes the settings to /etc/sysctl.d/50-incus-deploy.conf instead, so they participate in the normal sysctl.d ordering like every other package's defaults. The 50- prefix keeps them below anything an administrator or another package numbers higher.

Because existing deployments already have these keys in /etc/sysctl.conf, where they would keep winning forever, a second task removes them from that file. It uses reload: false, since re-reading /etc/sysctl.conf after the removal would only re-apply whatever unrelated content that file still holds and cannot restore drop-in values anyway; the first task's own reload already applies the intended values, and the rest resolves at next boot.

The settings list moves to vars/main.yml so the apply and cleanup tasks cannot drift apart.

No behaviour change is intended for hosts that do not have competing drop-ins: the same eleven values are still applied, just from a file that respects sysctl.d precedence.

The sysctl task relied on the ansible.posix.sysctl default of
/etc/sysctl.conf. procps reads that file last, after every sysctl.d
directory, so these values silently overrode drop-ins that other
software ships for itself, regardless of the intended precedence.

Write them to /etc/sysctl.d/50-incus-deploy.conf instead and remove any
copies an earlier run left in /etc/sysctl.conf. The settings list moves
to vars/ so both tasks stay in sync.

Signed-off-by: Stephan Peijnik-Steinwender <speijnik@eoscloud.io>
@stgraber
stgraber merged commit aaa50db into lxc:main Sep 28, 2026
3 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants