sysctl module¶
Sysctl
¶
The sysctl settings, as a dict of key -> value.
Commands:
sysctl -a 2>/dev/null || true
Returns:
dict[str, Any]
Raises:
HostConnectionError
Examples:
Examples can be found in examples/modules/sysctl/sysctl_sysctl.py.
SysctlFile
¶
The raw text of one sysctl config file, or None when it is absent.
Commands:
test -e <path> && { printf '#reemote-sysctl-file\n'; cat -- <path>; }
Returns:
str | None
Raises:
CommandNotFoundError, HostConnectionError
Examples:
Examples can be found in examples/modules/sysctl/sysctl_sysctl_file.py.
SysctlFiles
¶
The persistent sysctl configuration, as a dict of file path -> settings.
Commands:
for f in /etc/sysctl.conf /etc/sysctl.d/*.conf; do test -f "$f" && { printf '#reemote-sysctl-files %s\n' "$f"; cat -- "$f"; }; done
Returns:
dict[str, dict[str, str]]
Raises:
CommandNotFoundError, HostConnectionError
Examples:
Examples can be found in examples/modules/sysctl/sysctl_sysctl_files.py.
conf
async
¶
conf(
ctx: OpContext,
settings: tuple[tuple[str, str | int], ...],
sysctl_file: str = "/etc/sysctl.d/99-reemote.conf",
present: bool = True,
reload: bool = True,
**kwargs: Any,
) -> AsyncGenerator[Command]
Ensure a whole sysctl config file matches the given settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
OpContext
|
Execution context for the operation. |
required |
settings
|
tuple[tuple[str, str | int], ...]
|
The |
required |
sysctl_file
|
str
|
The config file to manage. Defaults to "/etc/sysctl.d/99-reemote.conf". |
'/etc/sysctl.d/99-reemote.conf'
|
present
|
bool
|
Whether the file should exist. |
True
|
reload
|
bool
|
Run |
True
|
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Yields:
| Name | Type | Description |
|---|---|---|
Command |
AsyncGenerator[Command]
|
The spool transfer + elevated install (+ reload) when the
content differs, or a removal when |
Raises:
CommandNotFoundError, HostConnectionError
Examples:
Examples can be found in examples/modules/sysctl/sysctl_conf.py.
setting
async
¶
setting(
ctx: OpContext,
key: str,
value: str | int | list[str | int],
present: bool = True,
persist: bool = True,
sysctl_file: str = "/etc/sysctl.conf",
sysctl_set: bool = True,
reload: bool = True,
ignore_errors: bool = False,
**kwargs: Any,
) -> AsyncGenerator[Command]
Ensure one kernel parameter is set (or removed from persistence).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
OpContext
|
Execution context for the operation. |
required |
key
|
str
|
The sysctl parameter name (e.g. |
required |
value
|
str | int | list[str | int]
|
The desired value; a list joins with spaces, digits compare as ints against the runtime fact. |
required |
present
|
bool
|
Whether the setting should exist.
|
True
|
persist
|
bool
|
Whether to manage the persistence file. Defaults to True. |
True
|
sysctl_file
|
str
|
The config file to edit when |
'/etc/sysctl.conf'
|
sysctl_set
|
bool
|
Whether to apply the value to the
running kernel ( |
True
|
reload
|
bool
|
Run |
True
|
ignore_errors
|
bool
|
Append |
False
|
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Yields:
| Name | Type | Description |
|---|---|---|
Command |
AsyncGenerator[Command]
|
The runtime apply when the live value differs, and/or the spool transfer + elevated install (+ reload) when the file content differs. |
Raises:
CommandNotFoundError, HostConnectionError
Examples:
Examples can be found in examples/modules/sysctl/sysctl_setting.py.