Skip to content

Instantly share code, notes, and snippets.

@raphink
Created December 21, 2012 09:39
Show Gist options
  • Save raphink/4351767 to your computer and use it in GitHub Desktop.
Save raphink/4351767 to your computer and use it in GitHub Desktop.
define limits::limit ($user,$type,$item,$value,$file='/etc/security/limits.conf'){
$key = "$user/$type/$item"
$path_list = "domain[.=\"$user\"][type=\"$type\" and item=\"$item\"]"
$path_exact = "domain[.=\"$user\"][type=\"$type\" and item=\"$item\" and value=\"$value\"]"
augeas { "limits_conf/${key}/":
lens => 'Limits.lns',
incl => $file,
onlyif => "match $path_exact size==0",
changes => [
"rm $path_list",
"set domain[last()+1] $user",
"set domain[last()]/type $type",
"set domain[last()]/item $item",
"set domain[last()]/value $value",
],
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment