From 2c372cc75c1c1d0da2d6f37c47196c80ef565548 Mon Sep 17 00:00:00 2001 From: Brian Witt Date: Mon, 22 Sep 2025 21:17:17 -0700 Subject: [PATCH] add REFERENCE and update param strings --- REFERENCE.md | 212 ++++++++++++++++++++++++++++++++++++++++++++ manifests/init.pp | 35 +++----- manifests/limits.pp | 63 ++++++++----- 3 files changed, 268 insertions(+), 42 deletions(-) create mode 100644 REFERENCE.md diff --git a/REFERENCE.md b/REFERENCE.md new file mode 100644 index 0000000..dfd141b --- /dev/null +++ b/REFERENCE.md @@ -0,0 +1,212 @@ +# Reference + + + +## Table of Contents + +### Classes + +* [`limits`](#limits): Manage user and group limits via Puppet + +### Defined types + +* [`limits::limits`](#limits--limits): Manage individual user/group limits + +## Classes + +### `limits` + +== Class: limits +This module manages the limits of the PAM module pam_limits. + +#### Examples + +##### + +```puppet +include limits +``` + +#### Parameters + +The following parameters are available in the `limits` class: + +* [`limits_dir`](#-limits--limits_dir) +* [`manage_limits_d_dir`](#-limits--manage_limits_d_dir) +* [`purge_limits_d_dir`](#-limits--purge_limits_d_dir) +* [`limits_file`](#-limits--limits_file) +* [`manage_limits_file`](#-limits--manage_limits_file) +* [`limits_file_owner`](#-limits--limits_file_owner) +* [`limits_file_group`](#-limits--limits_file_group) +* [`limits_file_mode`](#-limits--limits_file_mode) +* [`limits_template`](#-limits--limits_template) +* [`entries`](#-limits--entries) + +##### `limits_dir` + +Data type: `String[1]` + +Directory for individual limits config files + +##### `manage_limits_d_dir` + +Data type: `Boolean` + +Manage $limits_dir itself + +##### `purge_limits_d_dir` + +Data type: `Boolean` + +Purge $limits_dir + +##### `limits_file` + +Data type: `String[1]` + +Basic limits configuration file + +##### `manage_limits_file` + +Data type: `Boolean` + +Manage $limits_file + +##### `limits_file_owner` + +Data type: `String[1]` + +Owner of $limits_file + +##### `limits_file_group` + +Data type: `String[1]` + +Group $limits_file + +##### `limits_file_mode` + +Data type: `String[1]` + +Mode $limits_file + +##### `limits_template` + +Data type: `String[1]` + +Name of the template to use for $limits_file + +##### `entries` + +Data type: `Optional[Hash[String[1], Hash[Pattern[/\A[a-z][a-z0-9_]*\Z/], Data], 1]]` + +limits configuration file(s) entries + +## Defined types + +### `limits::limits` + +This defined type creates individual limit configuration files in the limits.d directory. +The title should be of the form user/limit_type if $user and $limit_type are not provided separately. + +#### Examples + +##### Setting file descriptor limits for all users + +```puppet +limits::limits{'*/nofile': + hard => 12345, + soft => 123, +} +``` + +##### Setting limits using both parameter + +```puppet +limits::limits{'root/nofile': + both => 1234, +} +``` + +##### Multiple settings in single file + +```puppet +limits::limits{'root/nofile': + both => 1234, + target => '01-root.conf', +} +limits::limits{'root/nproc': + both => 1234, + target => '01-root.conf', +} +``` + +#### Parameters + +The following parameters are available in the `limits::limits` defined type: + +* [`ensure`](#-limits--limits--ensure) +* [`user`](#-limits--limits--user) +* [`limit_type`](#-limits--limits--limit_type) +* [`hard`](#-limits--limits--hard) +* [`soft`](#-limits--limits--soft) +* [`both`](#-limits--limits--both) +* [`target`](#-limits--limits--target) + +##### `ensure` + +Data type: `Enum['absent', 'present']` + +Whether the limit configuration should be present or absent + +Default value: `present` + +##### `user` + +Data type: `Optional[String[1]]` + +The user or group name to apply limits to. If not specified, extracted from title + +Default value: `undef` + +##### `limit_type` + +Data type: `Optional[String[1]]` + +The type of limit to set (e.g., 'nofile', 'nproc', 'core'). If not specified, extracted from title + +Default value: `undef` + +##### `hard` + +Data type: `Optional[Variant[Integer, String]]` + +The hard limit value + +Default value: `undef` + +##### `soft` + +Data type: `Optional[Variant[Integer, String]]` + +The soft limit value + +Default value: `undef` + +##### `both` + +Data type: `Optional[Variant[Integer, String]]` + +Set both hard and soft limits to the same value (uses '-' in limits file) + +Default value: `undef` + +##### `target` + +Data type: `Optional[String[1]]` + +Name of file in `limits::limits_dir` directory where settings will be applied. +If provided, title with `.conf` extension will not be used as target file. + +Default value: `undef` + diff --git a/manifests/init.pp b/manifests/init.pp index 6ca3557..41e5762 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -3,38 +3,29 @@ # # This module manages the limits of the PAM module pam_limits. # -# @example -# include limits -# # @param limits_dir -# Directory for individual limits config files -# +# Directory for individual limits config files # @param manage_limits_d_dir -# Manage $limits_dir itself -# +# Manage $limits_dir itself # @param purge_limits_d_dir -# Purge $limits_dir -# +# Purge $limits_dir # @param limits_file -# Basic limits configuration file -# +# Basic limits configuration file # @param manage_limits_file -# Manage $limits_file -# +# Manage $limits_file # @param limits_file_owner -# Owner of $limits_file -# +# Owner of $limits_file # @param limits_file_group -# Group $limits_file -# +# Group $limits_file # @param limits_file_mode -# Mode $limits_file -# +# Mode $limits_file # @param limits_template -# Name of the template to use for $limits_file -# +# Name of the template to use for $limits_file # @param entries -# limits configuration file(s) entries +# limits configuration file(s) entries +# +# @example +# include limits # class limits ( String[1] $limits_dir, diff --git a/manifests/limits.pp b/manifests/limits.pp index 880f2cc..f179138 100644 --- a/manifests/limits.pp +++ b/manifests/limits.pp @@ -1,27 +1,50 @@ -# == Define: limits::limits +# @summary Manage individual user/group limits # -# Parameters: -# $title - should be of the form user/limit_type if $user and $limt_type are not present -# $user - user -# $limit_type - limit type / item -# $hard - hard limit -# $soft - soft limit -# $both - set both limits (-) -# $target - name of file in `limits::limits_dir` directory the settings will be applied. If provided, title with `.conf` extension will be not be used as target file. +# This defined type creates individual limit configuration files in the limits.d directory. +# The title should be of the form user/limit_type if $user and $limit_type are not provided separately. # -# Example: -# limits::limits{'*/nofile': -# hard => 12345, -# soft => 123, -# } -# limits::limits{'root/nofile': both => 1234; } +# @param ensure +# Whether the limit configuration should be present or absent # -# Example of multiple settings in single file -# limits::limits{'root/nofile': both => 1234, target => '01-root.conf' } -# limits::limits{'root/nproc': both => 1234, target => '01-root.conf' } +# @param user +# The user or group name to apply limits to. If not specified, extracted from title # -# Manages: -# limit file in limits.d with the values provided +# @param limit_type +# The type of limit to set (e.g., 'nofile', 'nproc', 'core'). If not specified, extracted from title +# +# @param hard +# The hard limit value +# +# @param soft +# The soft limit value +# +# @param both +# Set both hard and soft limits to the same value (uses '-' in limits file) +# +# @param target +# Name of file in `limits::limits_dir` directory where settings will be applied. +# If provided, title with `.conf` extension will not be used as target file. +# +# @example Setting file descriptor limits for all users +# limits::limits{'*/nofile': +# hard => 12345, +# soft => 123, +# } +# +# @example Setting limits using both parameter +# limits::limits{'root/nofile': +# both => 1234, +# } +# +# @example Multiple settings in single file +# limits::limits{'root/nofile': +# both => 1234, +# target => '01-root.conf', +# } +# limits::limits{'root/nproc': +# both => 1234, +# target => '01-root.conf', +# } define limits::limits ( Enum['absent', 'present'] $ensure = present, Optional[String[1]] $user = undef,