Rex::C...:Sysctl(3pm)

πŸ’– Rex::Commands::Sysctl πŸ’–

okay bestie, gather round, it's a Perl module moment ✨ β€” this is Rex::Commands::Sysctl, part of the User Contributed Perl Documentation (that's the 3pm corner of the manual-verse, iykyk), and it is literally here to let you play with sysctl. πŸŽ€


🌸 NAME 🌸

Rex::Commands::Sysctl β€” Manipulate sysctl πŸ¦‹


✨ DESCRIPTION ✨

So like, with this module you can set and get sysctl parameters. That's the whole vibe. πŸ’…

Little heads-up, bestie: Version <= 1.0: all these functions will not be reported. πŸ‘€

And also β€” super important, no cap β€” all these functions are not idempotent. So don't come for me when they do the thing multiple times, because that's just who they are. 😭


🌈 SYNOPSIS 🌈

use Rex::Commands::Sysctl;

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

look at her go 🫢


πŸ‘‘ EXPORTED FUNCTIONS πŸ‘‘

πŸ“ sysctl($key [, $val [, %options]])

This function will read the sysctl key $key. Easy. Slay. ⭐

If $val is given, then this function will set the sysctl key $key. Now we're cooking. πŸ”₯

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

If both $val and the ensure option are used, the sysctl key is modified and the value may persist in /etc/sysctl.conf β€” depending on whether the 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";
}

fr fr, remember: these functions are not idempotent, and on Version <= 1.0 they will not be reported. Not me warning you twice β€” okay maybe it's me. πŸ™ˆ

and that's the whole page, bestie πŸ§šπŸ’œ this was perl v5.40.1 dated 2025-10-03 β€” periodt. go forth and tune those kernels, main character energy only. πŸ’…πŸŒΈ

πŸ“¦ where this page comes from