Skip to content

Apply sysctl with full sysctl.d precedence - #104

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

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

Conversation

@speijnik

Copy link
Copy Markdown
Contributor

ansible.posix.sysctl with reload: true runs sysctl -p <sysctl_file>, which
applies that one file in isolation. Writing /etc/sysctl.d/50-incus-deploy.conf
therefore pushes these values into the running kernel even where a
higher-numbered drop-in is meant to override them, so the live values disagree
with what a reboot would produce.

Observed on a host where /usr/lib/sysctl.d/55-map-count.conf sets
vm.max_map_count=1048576 and a Ceph drop-in sets fs.aio-max-nr=2097152.
After a run the kernel reported the 50-incus-deploy.conf values:

# sysctl fs.aio-max-nr vm.max_map_count
fs.aio-max-nr = 524288
vm.max_map_count = 262144

A plain sysctl --system restored the intended ones:

# sysctl fs.aio-max-nr vm.max_map_count
fs.aio-max-nr = 2097152
vm.max_map_count = 1048576

Defer the reload and run sysctl --system once from a handler, so the applied
state matches the file precedence. meta: flush_handlers keeps the values live
for the roles that run afterwards rather than deferring them to the end of the
play. Also replaces eleven sysctl -p invocations with one.

sysctl -p reads a single file, so reloading 50-incus-deploy.conf sets values
that a higher-numbered drop-in is meant to override. The live kernel then
disagrees with what a reboot would produce.

Defer the reload and run sysctl --system once after the files are in place.

Signed-off-by: Stephan Peijnik-Steinwender <speijnik@eoscloud.io>
@stgraber
stgraber merged commit 2d1b38b into lxc:main Sep 29, 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