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.