Rex::Co...::Sysctl(3)

πŸ“¦ version 1.14.3, in nixos 26.05, nixpkgs unstable

πŸ’– NAME πŸ’–

okay so bestie, welcome to the Rex::Co...::Sysctl(3) page from the User Contributed Perl Documentation. the star of the show is Rex::Commands::Sysctl - Manipulate sysctl. it's giving sysctl management, and it's lowkey iconic. πŸ’…

πŸ¦‹ DESCRIPTION πŸ¦‹

With this module you can set and get sysctl parameters. no cap.

Version <= 1.0: All these functions will not be reported.

🚨 heads up, bestie: All these functions are not idempotent. so yeah, the docs are saying the quiet part loud β€” don't expect these to be neat little repeat-safe operations. 😭

✨ SYNOPSIS ✨

use Rex::Commands::Sysctl;

my $data = sysctl "net.ipv4.tcp_keepalive_time";
sysctl "net.ipv4.tcp_keepalive_time" => 1800;

🌸 EXPORTED FUNCTIONS 🌸

πŸ’… sysctl($key [, $val [, %options]]) πŸ’…

This function will read the sysctl key $key.

If $val is given, then this function will set the sysctl key $key.

task "tune", "server01", sub {
  if( sysctl("net.ipv4.ip_forward") == 0 ) {
    sysctl "net.ipv4.ip_forward" => 1;
  }
};

If both $val and ensure option are used, the sysctl key is modified and the value may persist in /etc/sysctl.conf depending if ensure option is "present" or "absent".

With ensure => "present", if the key already exists in the file, it will be updated to the new value.

task "forwarding", "server01", sub {
  sysctl "net.ipv4.ip_forward" => 1, ensure => "present";
}

okay that's the whole page, bestie 🫢 β€” brought to you by perl v5.42.3, dated 2023-08-05, and signed Rex::Co...::Sysctl(3). mwah πŸ’‹

πŸ“¦ where this page comes from