1Rex::Commands::Sysctl(3U)ser Contributed Perl DocumentatiRoenx::Commands::Sysctl(3)
2
3
4
6 Rex::Commands::Sysctl - Manipulate sysctl
7
9 With this module you can set and get sysctl parameters.
10
11 Version <= 1.0: All these functions will not be reported.
12
13 All these functions are not idempotent.
14
16 use Rex::Commands::Sysctl;
17
18 my $data = sysctl "net.ipv4.tcp_keepalive_time";
19 sysctl "net.ipv4.tcp_keepalive_time" => 1800;
20
22 sysctl($key [, $val [, %options]])
23 This function will read the sysctl key $key.
24
25 If $val is given, then this function will set the sysctl key $key.
26
27 task "tune", "server01", sub {
28 if( sysctl("net.ipv4.ip_forward") == 0 ) {
29 sysctl "net.ipv4.ip_forward" => 1;
30 }
31 };
32
33 If both $val and ensure option are used, the sysctl key is modified and
34 the value may persist in /etc/sysctl.conf depending if ensure option is
35 "present" or "absent".
36
37 With ensure => "present", if the key already exists in the file, it
38 will be updated to the new value.
39
40 task "forwarding", "server01", sub {
41 sysctl "net.ipv4.ip_forward" => 1, ensure => "present";
42 }
43
44
45
46perl v5.32.1 2021-03-06 Rex::Commands::Sysctl(3)